@itwin/rpcinterface-full-stack-tests 3.0.0-dev.175 → 3.0.0-dev.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/Settings.d.ts.map +1 -1
- package/lib/common/Settings.js +0 -3
- package/lib/common/Settings.js.map +1 -1
- package/lib/dist/bundled-tests.js +28823 -50482
- package/lib/dist/bundled-tests.js.map +1 -1
- package/lib/frontend/setup/IModelSession.d.ts.map +1 -1
- package/lib/frontend/setup/IModelSession.js +34 -5
- package/lib/frontend/setup/IModelSession.js.map +1 -1
- package/lib/frontend/setup/TestContext.d.ts.map +1 -1
- package/lib/frontend/setup/TestContext.js +5 -2
- package/lib/frontend/setup/TestContext.js.map +1 -1
- package/package.json +21 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelSession.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/IModelSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"IModelSession.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/IModelSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAa,MAAM,sBAAsB,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD,qBAAa,aAAa;IAEjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,cAAc,CAAgB;IAEtC,OAAO,CAAC,OAAO,CAAC,CAAuB;IAEvC,OAAO;WAQa,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAiD1F,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI9C,IAAI,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAYnD"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
+
var m = o[Symbol.asyncIterator], i;
|
|
5
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
6
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
7
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
8
|
+
};
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.IModelSession = void 0;
|
|
4
11
|
/*---------------------------------------------------------------------------------------------
|
|
@@ -7,9 +14,10 @@ exports.IModelSession = void 0;
|
|
|
7
14
|
*--------------------------------------------------------------------------------------------*/
|
|
8
15
|
const chai_1 = require("chai");
|
|
9
16
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
10
|
-
const imodelhub_client_1 = require("@bentley/imodelhub-client");
|
|
11
17
|
const projects_client_1 = require("@itwin/projects-client");
|
|
12
18
|
const core_common_1 = require("@itwin/core-common");
|
|
19
|
+
const imodels_client_management_1 = require("@itwin/imodels-client-management");
|
|
20
|
+
const imodels_access_frontend_1 = require("@itwin/imodels-access-frontend");
|
|
13
21
|
class IModelSession {
|
|
14
22
|
constructor(iTwinId, imodelId, changesetId) {
|
|
15
23
|
this.iTwinId = iTwinId;
|
|
@@ -18,6 +26,8 @@ class IModelSession {
|
|
|
18
26
|
this._imodelVersion = changesetId ? core_common_1.IModelVersion.asOfChangeSet(changesetId) : core_common_1.IModelVersion.latest();
|
|
19
27
|
}
|
|
20
28
|
static async create(requestContext, iModelData) {
|
|
29
|
+
var e_1, _a;
|
|
30
|
+
var _b;
|
|
21
31
|
let iTwinId;
|
|
22
32
|
let imodelId;
|
|
23
33
|
// Turn the iTwin name into an id
|
|
@@ -41,11 +51,30 @@ class IModelSession {
|
|
|
41
51
|
else
|
|
42
52
|
iTwinId = iModelData.iTwinId;
|
|
43
53
|
if (iModelData.useName) {
|
|
44
|
-
const imodelClient = new
|
|
45
|
-
const imodels =
|
|
46
|
-
|
|
54
|
+
const imodelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${(_b = process.env.IMJS_URL_PREFIX) !== null && _b !== void 0 ? _b : ""}api.bentley.com/imodels` } });
|
|
55
|
+
const imodels = imodelClient.iModels.getRepresentationList({
|
|
56
|
+
authorization: imodels_access_frontend_1.AccessTokenAdapter.toAuthorizationCallback(await core_frontend_1.IModelApp.getAccessToken()),
|
|
57
|
+
urlParams: {
|
|
58
|
+
projectId: iTwinId,
|
|
59
|
+
name: iModelData.name,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
try {
|
|
63
|
+
for (var imodels_1 = __asyncValues(imodels), imodels_1_1; imodels_1_1 = await imodels_1.next(), !imodels_1_1.done;) {
|
|
64
|
+
const iModel = imodels_1_1.value;
|
|
65
|
+
imodelId = iModel.id;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
70
|
+
finally {
|
|
71
|
+
try {
|
|
72
|
+
if (imodels_1_1 && !imodels_1_1.done && (_a = imodels_1.return)) await _a.call(imodels_1);
|
|
73
|
+
}
|
|
74
|
+
finally { if (e_1) throw e_1.error; }
|
|
75
|
+
}
|
|
76
|
+
if (!imodelId)
|
|
47
77
|
throw new Error(`The iModel ${iModelData.name} does not exist in iTwin ${iTwinId}.`);
|
|
48
|
-
imodelId = imodels[0].wsgId;
|
|
49
78
|
}
|
|
50
79
|
else
|
|
51
80
|
imodelId = iModelData.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelSession.js","sourceRoot":"","sources":["../../../src/frontend/setup/IModelSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IModelSession.js","sourceRoot":"","sources":["../../../src/frontend/setup/IModelSession.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+BAA8B;AAC9B,wDAAuE;AACvE,4DAA4G;AAE5G,oDAAmD;AAEnD,gFAAiE;AACjE,4EAAoE;AAEpE,MAAa,aAAa;IASxB,YAAoB,OAAe,EAAE,QAAgB,EAAE,WAAoB;QACzE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,2BAAa,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,2BAAa,CAAC,MAAM,EAAE,CAAC;IACxG,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,cAA2B,EAAE,UAAsB;;;QAC5E,IAAI,OAAO,CAAC;QACZ,IAAI,QAAQ,CAAC;QAEb,iCAAiC;QACjC,IAAI,UAAU,CAAC,YAAY,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,SAAS;gBACvB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;YAE/E,MAAM,MAAM,GAAG,IAAI,sCAAoB,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAY,MAAM,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE;gBAC7D,MAAM,EAAE;oBACN,YAAY,EAAE,UAAU,CAAC,SAAS;oBAClC,YAAY,EAAE,4CAA0B,CAAC,IAAI;oBAC7C,UAAU,EAAE,IAAI;iBACjB;aAAC,CAAC,CAAC;YAEN,IAAI,SAAS,CA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AAC,WAAW,IAAI,CAAC,CAAC,CAAC,iCAAiC;QAErL,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,aAAa;QACxB,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI;YACF,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;YAC3D,IAAI,CAAC,OAAO,GAAG,MAAM,oCAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YACvG,IAAA,aAAM,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;SAC/B;QAAC,OAAO,CAAM,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;SACpE;QAED,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAlFD,sCAkFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { expect } from \"chai\";\r\nimport { CheckpointConnection, IModelApp } from \"@itwin/core-frontend\";\r\nimport { Project as ITwin, ProjectsAccessClient, ProjectsSearchableProperty } from \"@itwin/projects-client\";\r\nimport { IModelData } from \"../../common/Settings\";\r\nimport { IModelVersion } from \"@itwin/core-common\";\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { IModelsClient } from \"@itwin/imodels-client-management\";\r\nimport { AccessTokenAdapter } from \"@itwin/imodels-access-frontend\";\r\n\r\nexport class IModelSession {\r\n\r\n public iTwinId: string;\r\n public iModelId: string;\r\n public changesetId?: string;\r\n private _imodelVersion: IModelVersion;\r\n\r\n private _iModel?: CheckpointConnection;\r\n\r\n private constructor(iTwinId: string, imodelId: string, changesetId?: string) {\r\n this.iTwinId = iTwinId;\r\n this.iModelId = imodelId;\r\n this.changesetId = changesetId;\r\n\r\n this._imodelVersion = changesetId ? IModelVersion.asOfChangeSet(changesetId) : IModelVersion.latest();\r\n }\r\n\r\n public static async create(requestContext: AccessToken, iModelData: IModelData): Promise<IModelSession> {\r\n let iTwinId;\r\n let imodelId;\r\n\r\n // Turn the iTwin name into an id\r\n if (iModelData.useITwinName) {\r\n if (!iModelData.iTwinName)\r\n throw new Error(`The iModel has no iTwin name, so it cannot get the iTwin.`);\r\n\r\n const client = new ProjectsAccessClient();\r\n const iTwinList: ITwin[] = await client.getAll(requestContext, {\r\n search: {\r\n searchString: iModelData.iTwinName,\r\n propertyName: ProjectsSearchableProperty.Name,\r\n exactMatch: true,\r\n }});\r\n\r\n if (iTwinList.length === 0)\r\n throw new Error(`ITwin ${iModelData.iTwinName} was not found for the user.`);\r\n else if (iTwinList.length > 1)\r\n throw new Error(`Multiple iTwins named ${iModelData.iTwinName} were found for the user.`);\r\n\r\n iTwinId = iTwinList[0].id;\r\n } else\r\n iTwinId = iModelData.iTwinId!;\r\n\r\n if (iModelData.useName) {\r\n const imodelClient = new IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? \"\"}api.bentley.com/imodels`}});\r\n const imodels = imodelClient.iModels.getRepresentationList({\r\n authorization: AccessTokenAdapter.toAuthorizationCallback(await IModelApp.getAccessToken()),\r\n urlParams: {\r\n projectId: iTwinId,\r\n name: iModelData.name,\r\n },\r\n });\r\n for await (const iModel of imodels) {\r\n imodelId = iModel.id;\r\n break;\r\n }\r\n if (!imodelId)\r\n throw new Error(`The iModel ${iModelData.name} does not exist in iTwin ${iTwinId}.`);\r\n } else\r\n imodelId = iModelData.id!;\r\n\r\n console.log(`Using iModel { name:${iModelData.name}, id:${iModelData.id}, iTwinId:${iModelData.iTwinId}, changesetId:${iModelData.changeSetId} }`); // eslint-disable-line no-console\r\n\r\n return new IModelSession(iTwinId, imodelId, iModelData.changeSetId);\r\n }\r\n\r\n public async getConnection(): Promise<CheckpointConnection> {\r\n return undefined === this._iModel ? this.open() : this._iModel;\r\n }\r\n\r\n public async open(): Promise<CheckpointConnection> {\r\n try {\r\n // eslint-disable-next-line no-console\r\n console.log(`Environment: ${process.env.IMJS_URL_PREFIX}`);\r\n this._iModel = await CheckpointConnection.openRemote(this.iTwinId, this.iModelId, this._imodelVersion);\r\n expect(this._iModel).to.exist;\r\n } catch (e: any) {\r\n throw new Error(`Failed to open test iModel. Error: ${e.message}`);\r\n }\r\n\r\n return this._iModel;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestContext.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAoB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"TestContext.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AAQpE,OAAO,EAAoB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,qBAAa,WAAW;IACf,oBAAoB,EAAG,WAAW,CAAC;IACnC,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAEhC,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,EAAE,QAAQ,CAAC;IAE1B,OAAO;IAGP,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAA0B;WAE/B,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAQpD,+EAA+E;IAC/E,OAAO,CAAC,uBAAuB;YAMjB,UAAU;CA2CzB"}
|
|
@@ -10,10 +10,11 @@ const core_bentley_1 = require("@itwin/core-bentley");
|
|
|
10
10
|
const core_common_1 = require("@itwin/core-common");
|
|
11
11
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
12
|
const frontend_1 = require("@itwin/oidc-signin-tool/lib/cjs/frontend");
|
|
13
|
+
const imodels_access_frontend_1 = require("@itwin/imodels-access-frontend");
|
|
14
|
+
const imodels_client_management_1 = require("@itwin/imodels-client-management");
|
|
13
15
|
const Settings_1 = require("../../common/Settings");
|
|
14
16
|
const SideChannels_1 = require("../../common/SideChannels");
|
|
15
17
|
const IModelSession_1 = require("./IModelSession");
|
|
16
|
-
const imodelhub_client_1 = require("@bentley/imodelhub-client");
|
|
17
18
|
/* eslint-disable no-console */
|
|
18
19
|
/* eslint-disable @typescript-eslint/indent */
|
|
19
20
|
class TestContext {
|
|
@@ -34,6 +35,7 @@ class TestContext {
|
|
|
34
35
|
core_common_1.BentleyCloudRpcManager.initializeClient({ info, uriPrefix }, (0, Settings_1.getRpcInterfaces)(this.settings));
|
|
35
36
|
}
|
|
36
37
|
async initialize() {
|
|
38
|
+
var _a;
|
|
37
39
|
(0, chai_1.expect)(this.settings.users.length).to.be.gte(1, `Unexpected number of users found in settings - got ${this.settings.users.length}, expected at least 2`);
|
|
38
40
|
(0, chai_1.expect)(this.settings.iModels.length).to.be.gte(1, `Unexpected number of iModels found in settings - got ${this.settings.iModels.length}, expected at least 1`);
|
|
39
41
|
// Print out the configuration
|
|
@@ -55,11 +57,12 @@ class TestContext {
|
|
|
55
57
|
if (undefined !== this.settings.clientConfiguration)
|
|
56
58
|
this.clientAccessToken = await (0, SideChannels_1.getClientAccessTokenFromBackend)();
|
|
57
59
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
60
|
+
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${(_a = process.env.IMJS_URL_PREFIX) !== null && _a !== void 0 ? _a : ""}api.bentley.com/imodels` } });
|
|
58
61
|
await core_frontend_1.NoRenderApp.startup({
|
|
59
62
|
applicationVersion: PACKAGE_VERSION,
|
|
60
63
|
applicationId: this.settings.gprid,
|
|
61
64
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.adminUserAccessToken),
|
|
62
|
-
hubAccess: new
|
|
65
|
+
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
63
66
|
});
|
|
64
67
|
this.iModelWithChangesets = await IModelSession_1.IModelSession.create(this.adminUserAccessToken, this.settings.iModel);
|
|
65
68
|
this.iTwinId = this.iModelWithChangesets.iTwinId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestContext.js","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA8B;AAC9B,sDAAoE;AACpE,oDAAyE;AACzE,wDAAmD;AACnD,uEAEkD;AAClD,oDAAmE;AACnE,4DAAsG;AACtG,mDAAgD;
|
|
1
|
+
{"version":3,"file":"TestContext.js","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA8B;AAC9B,sDAAoE;AACpE,oDAAyE;AACzE,wDAAmD;AACnD,uEAEkD;AAClD,4EAAuE;AACvE,gFAAiE;AACjE,oDAAmE;AACnE,4DAAsG;AACtG,mDAAgD;AAIhD,+BAA+B;AAC/B,8CAA8C;AAE9C,MAAa,WAAW;IAUtB,YAAoB,GAAsB;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAGM,MAAM,CAAC,KAAK,CAA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+B,CAAC,IAAI,CAAC,oBAAoB,CAAC;YACnF,SAAS,EAAE,IAAI,+CAAqB,CAAC,YAAY,CAAC;SACnD,CAAC,CAAC;QAEH,IAAI,CAAC,oBAAoB,GAAG,MAAM,6BAAa,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACxG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;QACjD,IAAI,IAAI,CAAC,QAAQ,CAAC,sBAAsB;YACtC,IAAI,CAAC,cAAc,GAAG,MAAM,6BAAa,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAEzG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACjC,CAAC;;AAxEH,kCAyEC;AA5DgB,qBAAS,GAAiB,SAAS,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { expect } from \"chai\";\r\nimport { AccessToken, Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { BentleyCloudRpcManager, OpenAPIInfo } from \"@itwin/core-common\";\r\nimport { NoRenderApp } from \"@itwin/core-frontend\";\r\nimport {\r\n getAccessTokenFromBackend, TestBrowserAuthorizationClientConfiguration, TestFrontendAuthorizationClient, TestUserCredentials,\r\n} from \"@itwin/oidc-signin-tool/lib/cjs/frontend\";\r\nimport { FrontendIModelsAccess } from \"@itwin/imodels-access-frontend\";\r\nimport { IModelsClient } from \"@itwin/imodels-client-management\";\r\nimport { getRpcInterfaces, Settings } from \"../../common/Settings\";\r\nimport { getClientAccessTokenFromBackend, getProcessEnvFromBackend } from \"../../common/SideChannels\";\r\nimport { IModelSession } from \"./IModelSession\";\r\n\r\ndeclare const PACKAGE_VERSION: string;\r\n\r\n/* eslint-disable no-console */\r\n/* eslint-disable @typescript-eslint/indent */\r\n\r\nexport class TestContext {\r\n public adminUserAccessToken!: AccessToken;\r\n public clientAccessToken?: AccessToken;\r\n\r\n public iModelWithChangesets?: IModelSession;\r\n public iModelForWrite?: IModelSession;\r\n public iTwinId?: string;\r\n\r\n public settings: Settings;\r\n\r\n private constructor(env: NodeJS.ProcessEnv) {\r\n this.settings = new Settings(env);\r\n }\r\n private static _instance?: TestContext = undefined;\r\n\r\n public static async instance(): Promise<TestContext> {\r\n if (this._instance === undefined) {\r\n this._instance = new TestContext(await getProcessEnvFromBackend());\r\n await this._instance.initialize();\r\n }\r\n return this._instance;\r\n }\r\n\r\n /** Initialize configuration for the rpc interfaces used by the application. */\r\n private initializeRpcInterfaces(info: OpenAPIInfo) {\r\n // Url without trailing slash\r\n const uriPrefix: string = this.settings.Backend.location.replace(/\\/$/, \"\");\r\n BentleyCloudRpcManager.initializeClient({ info, uriPrefix }, getRpcInterfaces(this.settings));\r\n }\r\n\r\n private async initialize() {\r\n expect(this.settings.users.length).to.be.gte(1, `Unexpected number of users found in settings - got ${this.settings.users.length}, expected at least 2`);\r\n expect(this.settings.iModels.length).to.be.gte(1, `Unexpected number of iModels found in settings - got ${this.settings.iModels.length}, expected at least 1`);\r\n\r\n // Print out the configuration\r\n console.log(this.settings.toString());\r\n\r\n // Configure iTwin.js frontend logging to go to the console\r\n Logger.initializeToConsole();\r\n Logger.setLevelDefault(this.settings.logLevel === undefined ? LogLevel.Warning : this.settings.logLevel);\r\n\r\n if (undefined !== this.settings.oidcClientId) {\r\n this.adminUserAccessToken = await getAccessTokenFromBackend({\r\n email: this.settings.users[0].email,\r\n password: this.settings.users[0].password,\r\n } as TestUserCredentials, {\r\n clientId: this.settings.oidcClientId,\r\n redirectUri: this.settings.oidcRedirect,\r\n scope: this.settings.oidcScopes,\r\n authority: this.settings.oidcAuthority,\r\n } as TestBrowserAuthorizationClientConfiguration);\r\n }\r\n\r\n if (undefined !== this.settings.clientConfiguration)\r\n this.clientAccessToken = await getClientAccessTokenFromBackend();\r\n\r\n this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });\r\n\r\n const iModelClient = new IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? \"\"}api.bentley.com/imodels`}});\r\n await NoRenderApp.startup({\r\n applicationVersion: PACKAGE_VERSION,\r\n applicationId: this.settings.gprid,\r\n authorizationClient: new TestFrontendAuthorizationClient(this.adminUserAccessToken),\r\n hubAccess: new FrontendIModelsAccess(iModelClient),\r\n });\r\n\r\n this.iModelWithChangesets = await IModelSession.create(this.adminUserAccessToken, this.settings.iModel);\r\n this.iTwinId = this.iModelWithChangesets.iTwinId;\r\n if (this.settings.runiModelWriteRpcTests)\r\n this.iModelForWrite = await IModelSession.create(this.adminUserAccessToken, this.settings.writeIModel);\r\n\r\n console.log(\"TestSetup: Done\");\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/rpcinterface-full-stack-tests",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.179",
|
|
4
4
|
"description": "Test the full iTwin.js Core stack (frontend and backend) using standard RPC interfaces",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,18 +18,21 @@
|
|
|
18
18
|
"url": "http://www.bentley.com"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@itwin/
|
|
23
|
-
"@itwin/
|
|
24
|
-
"@itwin/
|
|
25
|
-
"@itwin/
|
|
26
|
-
"@itwin/core-
|
|
27
|
-
"@itwin/core-
|
|
28
|
-
"@itwin/
|
|
29
|
-
"@itwin/
|
|
21
|
+
"@itwin/imodels-access-backend": "~0.3.0",
|
|
22
|
+
"@itwin/imodels-access-frontend": "~0.3.0",
|
|
23
|
+
"@itwin/imodels-client-authoring": "~0.3.0",
|
|
24
|
+
"@itwin/imodels-client-management": "~0.3.0",
|
|
25
|
+
"@itwin/build-tools": "3.0.0-dev.179",
|
|
26
|
+
"@itwin/core-bentley": "3.0.0-dev.179",
|
|
27
|
+
"@itwin/core-common": "3.0.0-dev.179",
|
|
28
|
+
"@itwin/core-frontend": "3.0.0-dev.179",
|
|
29
|
+
"@itwin/core-geometry": "3.0.0-dev.179",
|
|
30
|
+
"@itwin/core-quantity": "3.0.0-dev.179",
|
|
31
|
+
"@itwin/certa": "3.0.0-dev.179",
|
|
32
|
+
"@itwin/eslint-plugin": "3.0.0-dev.179",
|
|
30
33
|
"@itwin/oidc-signin-tool": "3.0.0",
|
|
31
|
-
"@itwin/presentation-common": "3.0.0-dev.
|
|
32
|
-
"@itwin/presentation-frontend": "3.0.0-dev.
|
|
34
|
+
"@itwin/presentation-common": "3.0.0-dev.179",
|
|
35
|
+
"@itwin/presentation-frontend": "3.0.0-dev.179",
|
|
33
36
|
"@itwin/service-authorization": "^0.4.0",
|
|
34
37
|
"chai": "^4.1.2",
|
|
35
38
|
"chai-as-promised": "^7",
|
|
@@ -40,9 +43,10 @@
|
|
|
40
43
|
"puppeteer": "chrome-86"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
|
-
"@itwin/core-backend": "3.0.0-dev.
|
|
44
|
-
"@itwin/express-server": "3.0.0-dev.
|
|
45
|
-
"@itwin/
|
|
46
|
+
"@itwin/core-backend": "3.0.0-dev.179",
|
|
47
|
+
"@itwin/express-server": "3.0.0-dev.179",
|
|
48
|
+
"@itwin/imodels-access-backend": "~0.3.0",
|
|
49
|
+
"@itwin/presentation-backend": "3.0.0-dev.179",
|
|
46
50
|
"@itwin/projects-client": "^0.3.0",
|
|
47
51
|
"@types/chai": "^4.1.4",
|
|
48
52
|
"@types/chai-as-promised": "^7",
|
|
@@ -80,5 +84,6 @@
|
|
|
80
84
|
"test:integration": "npm-run-all -r -p start:backend test:integration:chrome",
|
|
81
85
|
"test:integration:chrome": "certa -r chrome",
|
|
82
86
|
"webpack:frontend": "webpack --config webpack.config.js 1>&2"
|
|
83
|
-
}
|
|
87
|
+
},
|
|
88
|
+
"readme": "# iTwin.js RPC Interface Integration Tests\r\n\r\nCopyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.\r\n\r\nThis package contains the iTwin.js RPC Interface integration tests and configuration setup to run them against a deployed backend.\r\n\r\n## Prerequisites\r\n\r\nRefer to the iTwin.js [prerequisites](https://github.com/iTwin/itwinjs-core#prerequisites)\r\n\r\n## Running the tests\r\n\r\nBefore running the tests, the environment needs to be setup. The easiest way is to configure a [.env] file in the working directory, the [template.env](./template.env) file has information about how to set one up and all the variables that need to be configured.\r\n\r\nAll test related settings are contained in the `process.env` variable and parsed by [Settings.ts](./setup/Settings.ts). If something required is missing or not configured properly, the tests will fail to setup.\r\n\r\n### Setting up the required context\r\n\r\nThe tests require an Project and iModel to be setup in order to run properly.\r\n\r\nThe iModel doesn't require anything special and can be a seed iModel.\r\n\r\n### Specifying users to be used for testing\r\n\r\nThe tests require a single user to be specified. The user's access rules required are:\r\n\r\n1. User1 - full access to the Project and an iModel (requires iModelHub Read iModel Project Role)\r\n - i.e., \"user_with_access_username\" in the `.env` file.\r\n\r\n### Specifying the backend\r\n\r\nIf the specified address for the backend is \"localhost\", you must have built a backend and start it.\r\n\r\nIf you do not specify the address to be \"localhost\" for the backend, you must specify a valid URL to a hosted backend.\r\n\r\n### Configuring OIDC\r\n\r\nBy default the tests will retrieve valid OIDC tokens on behalf of each user specified in `environment` in order to make API calls. However,\r\nif you wish to use JWTs instead, you may set the `oidc_client_id` environment variable which will use OIDC authentication instead of SAML.\r\n\r\nIn order to run the integration tests they need to have a valid OIDC client id which can be obtains by performing the following steps:\r\n\r\n1. Go to the \"[Register your application](https://developer.bentley.com/register/)\" page and sign in\r\n1. Click 'New App'\r\n1. Select \"SPA\" application\r\n1. Specify a client name (can be anything you want)\r\n1. Add `http://localhost:5000` as a redirect url\r\n1. Hit 'Next' to finish\r\n\r\n### Actually running the tests\r\n\r\nOnce all the required environment variables are setup, to run the integration tests:\r\n\r\n1. Install dependencies: `npm install`\r\n2. Clean output: `npm run clean`\r\n3. Build source: `npm run build`\r\n4. Run tests: `npm test:integration`\r\n\r\n## Development instructions\r\n\r\nThe base 'after all' and 'before all' hooks are implemented in TestSetup.test.ts. Any cleanup and setup steps should be added here.\r\n\r\nThe `TestContext` class follows the singleton pattern and will automatically be setup when its static instance is invoked via its `TestContext.instance()`.\r\nThe setup uses a [.env file](./.env) and `process.env` to populate the `TestContext`.\r\n"
|
|
84
89
|
}
|