@adobe/acc-js-sdk 1.1.34 → 1.1.36
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/docs/changeLog.html +14 -0
- package/docs/connecting.html +17 -0
- package/package-lock.json +58 -43
- package/package.json +1 -1
- package/src/application.js +5 -3
- package/src/client.js +71 -17
- package/test/imBearerToken.test.js +61 -0
package/docs/changeLog.html
CHANGED
|
@@ -3,6 +3,20 @@ layout: page
|
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
<section class="changelog"><h1>Version 1.1.36</h1>
|
|
7
|
+
<h2>2023/07/28</h2>
|
|
8
|
+
<li>
|
|
9
|
+
Fixed the `uploadAemAsset` method when used from a browser, using fetch for HTTP requests.
|
|
10
|
+
</li>
|
|
11
|
+
</section>
|
|
12
|
+
|
|
13
|
+
<section class="changelog"><h1>Version 1.1.35</h1>
|
|
14
|
+
<h2>2023/07/25</h2>
|
|
15
|
+
<li>
|
|
16
|
+
Added `sessionInfo` parameter to `ofImsBearerToken` function. When this parameter is used, the logon call will make sure user and server informations are returned. See <a href="https://opensource.adobe.com/acc-js-sdk/connecting.html"></a> for more information.
|
|
17
|
+
</li>
|
|
18
|
+
</section>
|
|
19
|
+
|
|
6
20
|
<section class="changelog"><h1>Version 1.1.34</h1>
|
|
7
21
|
<h2>2023/07/25</h2>
|
|
8
22
|
<li>
|
package/docs/connecting.html
CHANGED
|
@@ -140,6 +140,23 @@ const connectionParameters = sdk.ConnectionParameters.ofBearerToken(
|
|
|
140
140
|
"ims_bearer_token");
|
|
141
141
|
</pre>
|
|
142
142
|
|
|
143
|
+
<p>
|
|
144
|
+
One caveat with ofImsBearerToken mechanism is that logon will not actually call any SOAP logon APIs. The bearer token is just stored in memory and will be passed along with subsequent calls.
|
|
145
|
+
</p>
|
|
146
|
+
<p>
|
|
147
|
+
This can be a concern because "xtk:session#Logon" and "xtk:session#BearerTokenLogon" return a session info object containing information about the server and the logged user.
|
|
148
|
+
This includes the server version and build number, the list of active packages, etc. This information is not available when using ofImsBearerToken.
|
|
149
|
+
</p>
|
|
150
|
+
<p>
|
|
151
|
+
In Version 1.1.35 of the SDK, it is possible to get this information consistently with other Logon method by passing the "sessionInfo" option to the ofImsBearerToken call.
|
|
152
|
+
</p>
|
|
153
|
+
<pre class="code">
|
|
154
|
+
const connectionParameters = sdk.ConnectionParameters.ofImsBearerToken(
|
|
155
|
+
"https://myInstance.campaign.adobe.com",
|
|
156
|
+
"ims_bearer_token",
|
|
157
|
+
{ sessionInfo: true });
|
|
158
|
+
</pre>
|
|
159
|
+
|
|
143
160
|
|
|
144
161
|
<h2>Login with Session token</h2>
|
|
145
162
|
<p>
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/acc-js-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.36",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@adobe/acc-js-sdk",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.36",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.2.1",
|
|
@@ -3041,9 +3041,10 @@
|
|
|
3041
3041
|
}
|
|
3042
3042
|
},
|
|
3043
3043
|
"node_modules/jest-snapshot/node_modules/semver": {
|
|
3044
|
-
"version": "7.
|
|
3044
|
+
"version": "7.5.4",
|
|
3045
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
|
3046
|
+
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
|
3045
3047
|
"dev": true,
|
|
3046
|
-
"license": "ISC",
|
|
3047
3048
|
"dependencies": {
|
|
3048
3049
|
"lru-cache": "^6.0.0"
|
|
3049
3050
|
},
|
|
@@ -3357,26 +3358,6 @@
|
|
|
3357
3358
|
"node": ">=v12.22.7"
|
|
3358
3359
|
}
|
|
3359
3360
|
},
|
|
3360
|
-
"node_modules/jsdom/node_modules/tough-cookie": {
|
|
3361
|
-
"version": "4.1.2",
|
|
3362
|
-
"license": "BSD-3-Clause",
|
|
3363
|
-
"dependencies": {
|
|
3364
|
-
"psl": "^1.1.33",
|
|
3365
|
-
"punycode": "^2.1.1",
|
|
3366
|
-
"universalify": "^0.2.0",
|
|
3367
|
-
"url-parse": "^1.5.3"
|
|
3368
|
-
},
|
|
3369
|
-
"engines": {
|
|
3370
|
-
"node": ">=6"
|
|
3371
|
-
}
|
|
3372
|
-
},
|
|
3373
|
-
"node_modules/jsdom/node_modules/universalify": {
|
|
3374
|
-
"version": "0.2.0",
|
|
3375
|
-
"license": "MIT",
|
|
3376
|
-
"engines": {
|
|
3377
|
-
"node": ">= 4.0.0"
|
|
3378
|
-
}
|
|
3379
|
-
},
|
|
3380
3361
|
"node_modules/jsesc": {
|
|
3381
3362
|
"version": "2.5.2",
|
|
3382
3363
|
"dev": true,
|
|
@@ -4053,9 +4034,10 @@
|
|
|
4053
4034
|
"license": "MIT"
|
|
4054
4035
|
},
|
|
4055
4036
|
"node_modules/semver": {
|
|
4056
|
-
"version": "6.3.
|
|
4037
|
+
"version": "6.3.1",
|
|
4038
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
|
4039
|
+
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
|
4057
4040
|
"dev": true,
|
|
4058
|
-
"license": "ISC",
|
|
4059
4041
|
"bin": {
|
|
4060
4042
|
"semver": "bin/semver.js"
|
|
4061
4043
|
}
|
|
@@ -4274,6 +4256,20 @@
|
|
|
4274
4256
|
"node": ">=8.0"
|
|
4275
4257
|
}
|
|
4276
4258
|
},
|
|
4259
|
+
"node_modules/tough-cookie": {
|
|
4260
|
+
"version": "4.1.3",
|
|
4261
|
+
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
|
|
4262
|
+
"integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
|
|
4263
|
+
"dependencies": {
|
|
4264
|
+
"psl": "^1.1.33",
|
|
4265
|
+
"punycode": "^2.1.1",
|
|
4266
|
+
"universalify": "^0.2.0",
|
|
4267
|
+
"url-parse": "^1.5.3"
|
|
4268
|
+
},
|
|
4269
|
+
"engines": {
|
|
4270
|
+
"node": ">=6"
|
|
4271
|
+
}
|
|
4272
|
+
},
|
|
4277
4273
|
"node_modules/tr46": {
|
|
4278
4274
|
"version": "3.0.0",
|
|
4279
4275
|
"license": "MIT",
|
|
@@ -4324,6 +4320,14 @@
|
|
|
4324
4320
|
"dev": true,
|
|
4325
4321
|
"license": "MIT"
|
|
4326
4322
|
},
|
|
4323
|
+
"node_modules/universalify": {
|
|
4324
|
+
"version": "0.2.0",
|
|
4325
|
+
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
|
|
4326
|
+
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
|
|
4327
|
+
"engines": {
|
|
4328
|
+
"node": ">= 4.0.0"
|
|
4329
|
+
}
|
|
4330
|
+
},
|
|
4327
4331
|
"node_modules/update-browserslist-db": {
|
|
4328
4332
|
"version": "1.0.10",
|
|
4329
4333
|
"dev": true,
|
|
@@ -4464,8 +4468,9 @@
|
|
|
4464
4468
|
}
|
|
4465
4469
|
},
|
|
4466
4470
|
"node_modules/word-wrap": {
|
|
4467
|
-
"version": "1.2.
|
|
4468
|
-
"
|
|
4471
|
+
"version": "1.2.5",
|
|
4472
|
+
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
|
|
4473
|
+
"integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==",
|
|
4469
4474
|
"engines": {
|
|
4470
4475
|
"node": ">=0.10.0"
|
|
4471
4476
|
}
|
|
@@ -6618,7 +6623,9 @@
|
|
|
6618
6623
|
},
|
|
6619
6624
|
"dependencies": {
|
|
6620
6625
|
"semver": {
|
|
6621
|
-
"version": "7.
|
|
6626
|
+
"version": "7.5.4",
|
|
6627
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
|
6628
|
+
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
|
6622
6629
|
"dev": true,
|
|
6623
6630
|
"requires": {
|
|
6624
6631
|
"lru-cache": "^6.0.0"
|
|
@@ -6808,18 +6815,6 @@
|
|
|
6808
6815
|
"requires": {
|
|
6809
6816
|
"xmlchars": "^2.2.0"
|
|
6810
6817
|
}
|
|
6811
|
-
},
|
|
6812
|
-
"tough-cookie": {
|
|
6813
|
-
"version": "4.1.2",
|
|
6814
|
-
"requires": {
|
|
6815
|
-
"psl": "^1.1.33",
|
|
6816
|
-
"punycode": "^2.1.1",
|
|
6817
|
-
"universalify": "^0.2.0",
|
|
6818
|
-
"url-parse": "^1.5.3"
|
|
6819
|
-
}
|
|
6820
|
-
},
|
|
6821
|
-
"universalify": {
|
|
6822
|
-
"version": "0.2.0"
|
|
6823
6818
|
}
|
|
6824
6819
|
}
|
|
6825
6820
|
},
|
|
@@ -7242,7 +7237,9 @@
|
|
|
7242
7237
|
"version": "2.1.2"
|
|
7243
7238
|
},
|
|
7244
7239
|
"semver": {
|
|
7245
|
-
"version": "6.3.
|
|
7240
|
+
"version": "6.3.1",
|
|
7241
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
|
7242
|
+
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
|
7246
7243
|
"dev": true
|
|
7247
7244
|
},
|
|
7248
7245
|
"shebang-command": {
|
|
@@ -7379,6 +7376,17 @@
|
|
|
7379
7376
|
"is-number": "^7.0.0"
|
|
7380
7377
|
}
|
|
7381
7378
|
},
|
|
7379
|
+
"tough-cookie": {
|
|
7380
|
+
"version": "4.1.3",
|
|
7381
|
+
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
|
|
7382
|
+
"integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
|
|
7383
|
+
"requires": {
|
|
7384
|
+
"psl": "^1.1.33",
|
|
7385
|
+
"punycode": "^2.1.1",
|
|
7386
|
+
"universalify": "^0.2.0",
|
|
7387
|
+
"url-parse": "^1.5.3"
|
|
7388
|
+
}
|
|
7389
|
+
},
|
|
7382
7390
|
"tr46": {
|
|
7383
7391
|
"version": "3.0.0",
|
|
7384
7392
|
"requires": {
|
|
@@ -7408,6 +7416,11 @@
|
|
|
7408
7416
|
"version": "1.13.6",
|
|
7409
7417
|
"dev": true
|
|
7410
7418
|
},
|
|
7419
|
+
"universalify": {
|
|
7420
|
+
"version": "0.2.0",
|
|
7421
|
+
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
|
|
7422
|
+
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg=="
|
|
7423
|
+
},
|
|
7411
7424
|
"update-browserslist-db": {
|
|
7412
7425
|
"version": "1.0.10",
|
|
7413
7426
|
"dev": true,
|
|
@@ -7493,7 +7506,9 @@
|
|
|
7493
7506
|
}
|
|
7494
7507
|
},
|
|
7495
7508
|
"word-wrap": {
|
|
7496
|
-
"version": "1.2.
|
|
7509
|
+
"version": "1.2.5",
|
|
7510
|
+
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
|
|
7511
|
+
"integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA=="
|
|
7497
7512
|
},
|
|
7498
7513
|
"wrap-ansi": {
|
|
7499
7514
|
"version": "7.0.0",
|
package/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -1365,9 +1365,11 @@ class Application {
|
|
|
1365
1365
|
* The server version, formatted as major.minor.servicePack (ex: 8.2.10)
|
|
1366
1366
|
* @type {string}
|
|
1367
1367
|
*/
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1368
|
+
const majNumber = EntityAccessor.getAttributeAsString(serverInfo, "majNumber");
|
|
1369
|
+
const minNumber = EntityAccessor.getAttributeAsString(serverInfo, "minNumber");
|
|
1370
|
+
const servicePack = EntityAccessor.getAttributeAsString(serverInfo, "servicePack");
|
|
1371
|
+
if (majNumber && minNumber && servicePack)
|
|
1372
|
+
this.version = majNumber + "." + minNumber + "." + servicePack;
|
|
1371
1373
|
/**
|
|
1372
1374
|
* The Campaign instance name
|
|
1373
1375
|
* @type {string}
|
package/src/client.js
CHANGED
|
@@ -657,13 +657,22 @@ const fileUploader = (client) => {
|
|
|
657
657
|
if(headers['Authorization'] === undefined || headers['Authorization'] === '' || headers['Authorization'] === 'null') {
|
|
658
658
|
throw 'Bearer token is missing';
|
|
659
659
|
}
|
|
660
|
+
// Serialize json data (required for fetch)
|
|
661
|
+
const jsonData = JSON.stringify({
|
|
662
|
+
'assetDownloadUrl': assetDownloadUrl
|
|
663
|
+
});
|
|
660
664
|
|
|
661
|
-
|
|
665
|
+
var response = await client._makeHttpCall({
|
|
662
666
|
url: url,
|
|
663
667
|
method: 'POST',
|
|
664
|
-
data:
|
|
668
|
+
data: jsonData,
|
|
665
669
|
headers: headers
|
|
666
670
|
});
|
|
671
|
+
|
|
672
|
+
// response is returned as string when using fetch(in browser)
|
|
673
|
+
// & returned as json using axios(nodejs).
|
|
674
|
+
if(typeof response === 'string')
|
|
675
|
+
response = JSON.parse(response);
|
|
667
676
|
if(response.publishedURL)
|
|
668
677
|
return response;
|
|
669
678
|
else
|
|
@@ -1412,6 +1421,52 @@ class Client {
|
|
|
1412
1421
|
delete this._observabilityContext.session;
|
|
1413
1422
|
}
|
|
1414
1423
|
|
|
1424
|
+
_updateSessionInfo(sessionInfo, soapCall) {
|
|
1425
|
+
this._sessionInfo = sessionInfo;
|
|
1426
|
+
this._installedPackages = {};
|
|
1427
|
+
const userInfo = DomUtil.findElement(sessionInfo, "userInfo");
|
|
1428
|
+
if (!userInfo)
|
|
1429
|
+
throw CampaignException.UNEXPECTED_SOAP_RESPONSE(soapCall, `userInfo structure missing`);
|
|
1430
|
+
let pack = DomUtil.getFirstChildElement(userInfo, "installed-package");
|
|
1431
|
+
while (pack) {
|
|
1432
|
+
const name = `${DomUtil.getAttributeAsString(pack, "namespace")}:${DomUtil.getAttributeAsString(pack, "name")}`;
|
|
1433
|
+
this._installedPackages[name] = name;
|
|
1434
|
+
pack = DomUtil.getNextSiblingElement(pack);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
async _fetchSessionInfo() {
|
|
1439
|
+
const userInfoPromise = this.NLWS.xml.xtkSession.getUserInfo();
|
|
1440
|
+
const testPromise = this.test();
|
|
1441
|
+
const all = Promise.all([userInfoPromise, testPromise]);
|
|
1442
|
+
const values = await all;
|
|
1443
|
+
|
|
1444
|
+
const sessionInfo = DomUtil.newDocument("sessionInfo");
|
|
1445
|
+
const sessionInfoRoot = sessionInfo.documentElement;
|
|
1446
|
+
const userInfo = sessionInfo.importNode(values[0], true);
|
|
1447
|
+
sessionInfoRoot.appendChild(userInfo);
|
|
1448
|
+
const serverInfo = sessionInfo.createElement('serverInfo');
|
|
1449
|
+
sessionInfoRoot.appendChild(serverInfo);
|
|
1450
|
+
const test = values[1];
|
|
1451
|
+
if (test["date"])
|
|
1452
|
+
serverInfo.setAttribute("serverDate", new Date(Date.parse(test["date"])).toISOString());
|
|
1453
|
+
serverInfo.setAttribute("instanceName", test["instance"]);
|
|
1454
|
+
if (test["version"]) {
|
|
1455
|
+
const versionParts = test["version"].split(".");
|
|
1456
|
+
serverInfo.setAttribute("majNumber", versionParts[0]);
|
|
1457
|
+
serverInfo.setAttribute("minNumber", versionParts[1]);
|
|
1458
|
+
serverInfo.setAttribute("servicePack", versionParts[2]);
|
|
1459
|
+
}
|
|
1460
|
+
let buildNumber = test["build"];
|
|
1461
|
+
// Alternative method to get the build number (not available unless server has been upgraded at least once)
|
|
1462
|
+
if (!buildNumber)
|
|
1463
|
+
buildNumber = await this.getOption("NmsServer_LastPostUpgrade", false);
|
|
1464
|
+
if (!buildNumber)
|
|
1465
|
+
throw CampaignException.UNEXPECTED_SOAP_RESPONSE(undefined, `buildNumber structure missing for both /r/test and NmsServer_LastPostUpgrade option`);
|
|
1466
|
+
serverInfo.setAttribute("buildNumber", buildNumber);
|
|
1467
|
+
return sessionInfoRoot;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1415
1470
|
/**
|
|
1416
1471
|
* Login to an instance
|
|
1417
1472
|
*/
|
|
@@ -1466,8 +1521,18 @@ class Client {
|
|
|
1466
1521
|
that._sessionToken = "";
|
|
1467
1522
|
that._securityToken = "";
|
|
1468
1523
|
that._bearerToken = credentials._bearerToken;
|
|
1469
|
-
|
|
1470
|
-
|
|
1524
|
+
|
|
1525
|
+
// With IMS Bearer token, we do not call the Logon or BearerTokenLogon method any more. As a consequence,
|
|
1526
|
+
// we do not have the user and server information returned by those methods, so we need to get the corresponding
|
|
1527
|
+
// information by other means
|
|
1528
|
+
if (!this._connectionParameters._options.sessionInfo) {
|
|
1529
|
+
that._onLogon();
|
|
1530
|
+
return Promise.resolve();
|
|
1531
|
+
}
|
|
1532
|
+
return that._fetchSessionInfo().then((sessionInfo) => {
|
|
1533
|
+
that._updateSessionInfo(sessionInfo, undefined);
|
|
1534
|
+
that._onLogon();
|
|
1535
|
+
});
|
|
1471
1536
|
}
|
|
1472
1537
|
else if (credentials._type == "UserPassword" || credentials._type == "BearerToken") {
|
|
1473
1538
|
const soapCall = that._prepareSoapCall("xtk:session", credentials._type === "UserPassword" ? "Logon" : "BearerTokenLogon", true, false, this._connectionParameters._options.extraHttpHeaders);
|
|
@@ -1493,19 +1558,8 @@ class Client {
|
|
|
1493
1558
|
}
|
|
1494
1559
|
return this._makeSoapCall(soapCall).then(function() {
|
|
1495
1560
|
const sessionToken = soapCall.getNextString();
|
|
1496
|
-
|
|
1497
|
-
that.
|
|
1498
|
-
that._installedPackages = {};
|
|
1499
|
-
const userInfo = DomUtil.findElement(that._sessionInfo, "userInfo");
|
|
1500
|
-
if (!userInfo)
|
|
1501
|
-
throw CampaignException.UNEXPECTED_SOAP_RESPONSE(soapCall, `userInfo structure missing`);
|
|
1502
|
-
var pack = DomUtil.getFirstChildElement(userInfo, "installed-package");
|
|
1503
|
-
while (pack) {
|
|
1504
|
-
const name = `${DomUtil.getAttributeAsString(pack, "namespace")}:${DomUtil.getAttributeAsString(pack, "name")}`;
|
|
1505
|
-
that._installedPackages[name] = name;
|
|
1506
|
-
pack = DomUtil.getNextSiblingElement(pack);
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1561
|
+
const sessionInfo = soapCall.getNextDocument();
|
|
1562
|
+
that._updateSessionInfo(sessionInfo, soapCall);
|
|
1509
1563
|
const securityToken = soapCall.getNextString();
|
|
1510
1564
|
soapCall.checkNoMoreArgs();
|
|
1511
1565
|
// Sanity check: we should have both a session token and a security token.
|
|
@@ -171,4 +171,65 @@ describe('IMS Bearer Toekn', function () {
|
|
|
171
171
|
// when using one of the Logon methods (Logno or BearertokenLogon)
|
|
172
172
|
expect(application.packages).toBeUndefined();
|
|
173
173
|
});
|
|
174
|
+
|
|
175
|
+
it('Should logon with IMS Bearer Token and return session info. No version string or date', async () => {
|
|
176
|
+
const client = await makeImsClient({ sessionInfo: true });
|
|
177
|
+
// As session info is asked, GetUserInfo and /r/test will be called
|
|
178
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<redir status='OK' build='9236' sha1='cc45440' instance='xxx_mkt_prod1' sourceIP='193.104.215.11' host='xxxol.campaign.adobe.com' localHost='xxxol-mkt-prod1-1'/>`));
|
|
179
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
180
|
+
client._transport.mockReturnValueOnce(Mock.GET_USER_INFO_RESPONSE);
|
|
181
|
+
await client.NLWS.xtkSession.logon();
|
|
182
|
+
expect(client.isLogged()).toBe(true);
|
|
183
|
+
expect(client.application.buildNumber).toBe("9236");
|
|
184
|
+
expect(client.application.version).toBe(undefined);
|
|
185
|
+
expect(client.application.instanceName).toBe("xxx_mkt_prod1");
|
|
186
|
+
expect(client.application.operator.login).toBe("admin");
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('Should logon with IMS Bearer Token and return session info', async () => {
|
|
190
|
+
const client = await makeImsClient({ sessionInfo: true });
|
|
191
|
+
// As session info is asked, GetUserInfo and /r/test will be called
|
|
192
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<redir status='OK' date='2021-08-27 08:02:07.963-07' version='8.5.1' build='9236' sha1='cc45440' instance='xxx_mkt_prod1' sourceIP='193.104.215.11' host='xxxol.campaign.adobe.com' localHost='xxxol-mkt-prod1-1'/>`));
|
|
193
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
194
|
+
client._transport.mockReturnValueOnce(Mock.GET_USER_INFO_RESPONSE);
|
|
195
|
+
await client.NLWS.xtkSession.logon();
|
|
196
|
+
expect(client.isLogged()).toBe(true);
|
|
197
|
+
expect(client.application.buildNumber).toBe("9236");
|
|
198
|
+
expect(client.application.version).toBe("8.5.1");
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('Should logon with IMS Bearer Token and return session info. Build number is missing from /r/test', async () => {
|
|
202
|
+
const client = await makeImsClient({ sessionInfo: true });
|
|
203
|
+
// As session info is asked, GetUserInfo and /r/test will be called
|
|
204
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<redir status='OK' date='2021-08-27 08:02:07.963-07'/>`));
|
|
205
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
206
|
+
client._transport.mockReturnValueOnce(Mock.GET_USER_INFO_RESPONSE);
|
|
207
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
208
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
209
|
+
<SOAP-ENV:Body>
|
|
210
|
+
<GetOptionResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
211
|
+
<pstrValue xsi:type='xsd:string'>9999</pstrValue>
|
|
212
|
+
<pbtType xsi:type='xsd:byte'>6</pbtType>
|
|
213
|
+
</GetOptionResponse>
|
|
214
|
+
</SOAP-ENV:Body>
|
|
215
|
+
</SOAP-ENV:Envelope>`));
|
|
216
|
+
// As build number is missing getOption will be called
|
|
217
|
+
await client.NLWS.xtkSession.logon();
|
|
218
|
+
expect(client.isLogged()).toBe(true);
|
|
219
|
+
expect(client.application.buildNumber).toBe("9999");
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('Should fail to logon with IMS Bearer Token because build number is missing', async () => {
|
|
223
|
+
const client = await makeImsClient({ sessionInfo: true });
|
|
224
|
+
// As session info is asked, GetUserInfo and /r/test will be called
|
|
225
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<redir status='OK' date='2021-08-27 08:02:07.963-07'/>`));
|
|
226
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
227
|
+
client._transport.mockReturnValueOnce(Mock.GET_USER_INFO_RESPONSE);
|
|
228
|
+
client._transport.mockReturnValueOnce(Mock.GET_OPTION_NOTFOUND_RESPONSE);
|
|
229
|
+
// As build number is missing getOption will be called
|
|
230
|
+
await expect(async() => {
|
|
231
|
+
await client.NLWS.xtkSession.logon();
|
|
232
|
+
}).rejects.toMatchObject({ errorCode: "SDK-000007" });
|
|
233
|
+
});
|
|
234
|
+
|
|
174
235
|
});
|