@adobe/acc-js-sdk 1.1.2 → 1.1.5
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/.github/workflows/npm-publish.yml +1 -1
- package/CHANGELOG.md +29 -0
- package/README.md +188 -21
- package/compile.js +1 -1
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/samples/011 - basics - packages.js +60 -0
- package/samples/utils.js +3 -1
- package/src/application.js +11 -4
- package/src/client.js +89 -16
- package/src/index.js +3 -1
- package/src/soap.js +44 -18
- package/src/testUtil.js +2 -2
- package/src/transport.js +17 -2
- package/test/application.test.js +11 -0
- package/test/client.hasPackage.test.js +6 -6
- package/test/client.test.js +415 -4
- package/test/soap.test.js +76 -28
- package/.vscode/launch.json +0 -22
package/test/soap.test.js
CHANGED
|
@@ -25,8 +25,8 @@ const sdk = require('../src/index.js');
|
|
|
25
25
|
|
|
26
26
|
const URL = "https://soap-test/nl/jsp/soaprouter.jsp";
|
|
27
27
|
|
|
28
|
-
function makeSoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString,
|
|
29
|
-
const call = new SoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString,
|
|
28
|
+
function makeSoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString, pushDownOptions, extraHttpHeaders) {
|
|
29
|
+
const call = new SoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString, pushDownOptions, extraHttpHeaders);
|
|
30
30
|
return call;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -145,7 +145,7 @@ describe('SOAP', function() {
|
|
|
145
145
|
|
|
146
146
|
it('Should build an mostly empty SOAP call', function() {
|
|
147
147
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty"); // no auth
|
|
148
|
-
const request = call._createHTTPRequest(URL);
|
|
148
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
149
149
|
assert.equal(request.url, URL);
|
|
150
150
|
assert.equal(request.method, "POST");
|
|
151
151
|
assert.equal(request.headers["Content-type"], "application/soap+xml");
|
|
@@ -161,7 +161,7 @@ describe('SOAP', function() {
|
|
|
161
161
|
|
|
162
162
|
it('Should have set authentication tokens', function() {
|
|
163
163
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty", "$session$", "$security$");
|
|
164
|
-
const request = call._createHTTPRequest(URL);
|
|
164
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
165
165
|
assert.equal(request.headers["X-Security-Token"], "$security$", "Security token matches");
|
|
166
166
|
assert.equal(request.headers["Cookie"], "__sessiontoken=$session$", "Session token matches");
|
|
167
167
|
const env = DomUtil.parse(request.data).documentElement;
|
|
@@ -176,7 +176,7 @@ describe('SOAP', function() {
|
|
|
176
176
|
const expected = [ "false", "false", "false", "true", "true", "true", "false", "true", "false"];
|
|
177
177
|
for (var i=0; i<values.length; i++)
|
|
178
178
|
call.writeBoolean(`p${i}`, values[i]);
|
|
179
|
-
const request = call._createHTTPRequest(URL);
|
|
179
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
180
180
|
const env = DomUtil.parse(request.data).documentElement;
|
|
181
181
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
182
182
|
const method = hasChildElement(body, "m:Boolean");
|
|
@@ -191,7 +191,7 @@ describe('SOAP', function() {
|
|
|
191
191
|
const expected = [ "0", "0", "0", "1", "2", "-3", "1", "0", "0", "7", "127", "12", "100", "5", "6", "-5", "-6"];
|
|
192
192
|
for (var i=0; i<values.length; i++)
|
|
193
193
|
call.writeByte(`p${i}`, values[i]);
|
|
194
|
-
const request = call._createHTTPRequest(URL);
|
|
194
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
195
195
|
const env = DomUtil.parse(request.data).documentElement;
|
|
196
196
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
197
197
|
const method = hasChildElement(body, "m:Byte");
|
|
@@ -206,7 +206,7 @@ describe('SOAP', function() {
|
|
|
206
206
|
const expected = [ "0", "0", "0", "1", "2", "-3", "1", "0", "0", "7", "500", "12", "100", "5", "6", "-5", "-6"];
|
|
207
207
|
for (var i=0; i<values.length; i++)
|
|
208
208
|
call.writeShort(`p${i}`, values[i]);
|
|
209
|
-
const request = call._createHTTPRequest(URL);
|
|
209
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
210
210
|
const env = DomUtil.parse(request.data).documentElement;
|
|
211
211
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
212
212
|
const method = hasChildElement(body, "m:Short");
|
|
@@ -221,7 +221,7 @@ describe('SOAP', function() {
|
|
|
221
221
|
const expected = [ "0", "0", "0", "1", "2", "-3", "1", "0", "0", "7", "500", "12", "100", "5", "6", "-5", "-6"];
|
|
222
222
|
for (var i=0; i<values.length; i++)
|
|
223
223
|
call.writeLong(`p${i}`, values[i]);
|
|
224
|
-
const request = call._createHTTPRequest(URL);
|
|
224
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
225
225
|
const env = DomUtil.parse(request.data).documentElement;
|
|
226
226
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
227
227
|
const method = hasChildElement(body, "m:Long");
|
|
@@ -236,7 +236,7 @@ describe('SOAP', function() {
|
|
|
236
236
|
const expected = [ "0", "0", "0", "1", "2", "-3", "1", "0", "0", "7", "500", "12"];
|
|
237
237
|
for (var i=0; i<values.length; i++)
|
|
238
238
|
call.writeInt64(`p${i}`, values[i]);
|
|
239
|
-
const request = call._createHTTPRequest(URL);
|
|
239
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
240
240
|
const env = DomUtil.parse(request.data).documentElement;
|
|
241
241
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
242
242
|
const method = hasChildElement(body, "m:Int64");
|
|
@@ -251,7 +251,7 @@ describe('SOAP', function() {
|
|
|
251
251
|
const expected = [ "0", "0", "0", "1", "2", "-3", "1", "0", "0", "7", "500", "12", "100", "5.1", "5.9", "-5.1", "-5.9"];
|
|
252
252
|
for (var i=0; i<values.length; i++)
|
|
253
253
|
call.writeFloat(`p${i}`, values[i]);
|
|
254
|
-
const request = call._createHTTPRequest(URL);
|
|
254
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
255
255
|
const env = DomUtil.parse(request.data).documentElement;
|
|
256
256
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
257
257
|
const method = hasChildElement(body, "m:Float");
|
|
@@ -266,7 +266,7 @@ describe('SOAP', function() {
|
|
|
266
266
|
const expected = [ "0", "0", "0", "1", "2", "-3", "1", "0", "0", "7", "500", "12", "100", "5.1", "5.9", "-5.1", "-5.9"];
|
|
267
267
|
for (var i=0; i<values.length; i++)
|
|
268
268
|
call.writeDouble(`p${i}`, values[i]);
|
|
269
|
-
const request = call._createHTTPRequest(URL);
|
|
269
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
270
270
|
const env = DomUtil.parse(request.data).documentElement;
|
|
271
271
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
272
272
|
const method = hasChildElement(body, "m:Double");
|
|
@@ -281,7 +281,7 @@ describe('SOAP', function() {
|
|
|
281
281
|
const expected = [ "", "", "0", "1", "2", "-3", "true", "false", "", "7", "500", "12", "1.e2", "5.1", "5.9", "-5.1", "-5.9", "Hello", "<>\""];
|
|
282
282
|
for (var i=0; i<values.length; i++)
|
|
283
283
|
call.writeString(`p${i}`, values[i]);
|
|
284
|
-
const request = call._createHTTPRequest(URL);
|
|
284
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
285
285
|
const env = DomUtil.parse(request.data).documentElement;
|
|
286
286
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
287
287
|
const method = hasChildElement(body, "m:String");
|
|
@@ -299,7 +299,7 @@ describe('SOAP', function() {
|
|
|
299
299
|
const expected = [ "", "", "2020-12-31T12:34:56.789Z", "2020-12-31T12:34:56.789Z", "2020-12-31T00:00:00.000Z"];
|
|
300
300
|
for (var i=0; i<values.length; i++)
|
|
301
301
|
call.writeTimestamp(`p${i}`, values[i]);
|
|
302
|
-
const request = call._createHTTPRequest(URL);
|
|
302
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
303
303
|
const env = DomUtil.parse(request.data).documentElement;
|
|
304
304
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
305
305
|
const method = hasChildElement(body, "m:Timestamp");
|
|
@@ -317,7 +317,7 @@ describe('SOAP', function() {
|
|
|
317
317
|
const expected = [ "", "", "2020-12-31T00:00:00.000Z", "2020-12-31T00:00:00.000Z", "2020-12-31T00:00:00.000Z"];
|
|
318
318
|
for (var i=0; i<values.length; i++)
|
|
319
319
|
call.writeDate(`p${i}`, values[i]);
|
|
320
|
-
const request = call._createHTTPRequest(URL);
|
|
320
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
321
321
|
const env = DomUtil.parse(request.data).documentElement;
|
|
322
322
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
323
323
|
const method = hasChildElement(body, "m:Date");
|
|
@@ -332,7 +332,7 @@ describe('SOAP', function() {
|
|
|
332
332
|
|
|
333
333
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Element", "$session$", "$security$");
|
|
334
334
|
call.writeElement("p", element);
|
|
335
|
-
const request = call._createHTTPRequest(URL);
|
|
335
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
336
336
|
const env = DomUtil.parse(request.data).documentElement;
|
|
337
337
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
338
338
|
const method = hasChildElement(body, "m:Element");
|
|
@@ -348,7 +348,7 @@ describe('SOAP', function() {
|
|
|
348
348
|
const element = call.createElement("root");
|
|
349
349
|
element.setAttribute("att", "Hello");
|
|
350
350
|
call.writeElement("p", element);
|
|
351
|
-
const request = call._createHTTPRequest(URL);
|
|
351
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
352
352
|
const env = DomUtil.parse(request.data).documentElement;
|
|
353
353
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
354
354
|
const method = hasChildElement(body, "m:Element");
|
|
@@ -362,7 +362,7 @@ describe('SOAP', function() {
|
|
|
362
362
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Element", "$session$", "$security$");
|
|
363
363
|
call.writeElement("p", null);
|
|
364
364
|
call.writeElement("q", undefined);
|
|
365
|
-
const request = call._createHTTPRequest(URL);
|
|
365
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
366
366
|
const env = DomUtil.parse(request.data).documentElement;
|
|
367
367
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
368
368
|
const method = hasChildElement(body, "m:Element");
|
|
@@ -378,7 +378,23 @@ describe('SOAP', function() {
|
|
|
378
378
|
|
|
379
379
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Document", "$session$", "$security$");
|
|
380
380
|
call.writeDocument("p", doc);
|
|
381
|
-
const request = call._createHTTPRequest(URL);
|
|
381
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
382
|
+
const env = DomUtil.parse(request.data).documentElement;
|
|
383
|
+
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
384
|
+
const method = hasChildElement(body, "m:Document");
|
|
385
|
+
const param = hasChildElement(method, "p");
|
|
386
|
+
const actualElement = hasChildElement(param, "root");
|
|
387
|
+
expect(actualElement).toBeTruthy();
|
|
388
|
+
expect(actualElement.getAttribute("att")).toBe("Hello");
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('Should support passing DOM elements instead of document parameters', function() {
|
|
392
|
+
const xml = '<root att="Hello"><child/></root>';
|
|
393
|
+
const doc = DomUtil.parse(xml);
|
|
394
|
+
|
|
395
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Document", "$session$", "$security$");
|
|
396
|
+
call.writeDocument("p", doc.documentElement);
|
|
397
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
382
398
|
const env = DomUtil.parse(request.data).documentElement;
|
|
383
399
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
384
400
|
const method = hasChildElement(body, "m:Document");
|
|
@@ -392,7 +408,7 @@ describe('SOAP', function() {
|
|
|
392
408
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Document", "$session$", "$security$");
|
|
393
409
|
call.writeDocument("p", null);
|
|
394
410
|
call.writeDocument("q", undefined);
|
|
395
|
-
const request = call._createHTTPRequest(URL);
|
|
411
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
396
412
|
const env = DomUtil.parse(request.data).documentElement;
|
|
397
413
|
const body = hasChildElement(env, "SOAP-ENV:Body");
|
|
398
414
|
const method = hasChildElement(body, "m:Document");
|
|
@@ -688,14 +704,14 @@ describe('SOAP', function() {
|
|
|
688
704
|
|
|
689
705
|
it("Should support no encoding", function() {
|
|
690
706
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty");
|
|
691
|
-
const request = call._createHTTPRequest(URL);
|
|
707
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
692
708
|
assert.equal(request.url, URL);
|
|
693
709
|
assert.equal(request.headers["Content-type"], "application/soap+xml");
|
|
694
710
|
});
|
|
695
711
|
|
|
696
712
|
it("Should support UTF-8 encoding", function() {
|
|
697
|
-
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty", undefined, undefined, undefined, "UTF-8");
|
|
698
|
-
const request = call._createHTTPRequest(URL);
|
|
713
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty", undefined, undefined, undefined, { charset: "UTF-8" });
|
|
714
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
699
715
|
assert.equal(request.url, URL);
|
|
700
716
|
assert.equal(request.headers["Content-type"], "application/soap+xml;charset=UTF-8");
|
|
701
717
|
});
|
|
@@ -707,7 +723,7 @@ describe('SOAP', function() {
|
|
|
707
723
|
expect(client._connectionParameters._options.charset).toBe('UTF-8');
|
|
708
724
|
const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
|
|
709
725
|
expect (soapCall._charset).toBe('UTF-8');
|
|
710
|
-
const request = soapCall._createHTTPRequest(URL);
|
|
726
|
+
const [ request ] = soapCall._createHTTPRequest(URL);
|
|
711
727
|
assert.equal(request.headers["Content-type"], "application/soap+xml;charset=UTF-8");
|
|
712
728
|
})
|
|
713
729
|
|
|
@@ -718,7 +734,7 @@ describe('SOAP', function() {
|
|
|
718
734
|
expect(client._connectionParameters._options.charset).toBe('');
|
|
719
735
|
const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
|
|
720
736
|
expect (soapCall._charset).toBe('');
|
|
721
|
-
const request = soapCall._createHTTPRequest(URL);
|
|
737
|
+
const [ request ] = soapCall._createHTTPRequest(URL);
|
|
722
738
|
assert.equal(request.headers["Content-type"], "application/soap+xml");
|
|
723
739
|
})
|
|
724
740
|
|
|
@@ -729,7 +745,7 @@ describe('SOAP', function() {
|
|
|
729
745
|
expect(client._connectionParameters._options.charset).toBe('ISO-8859-1');
|
|
730
746
|
const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
|
|
731
747
|
expect (soapCall._charset).toBe('ISO-8859-1');
|
|
732
|
-
const request = soapCall._createHTTPRequest(URL);
|
|
748
|
+
const [ request ] = soapCall._createHTTPRequest(URL);
|
|
733
749
|
assert.equal(request.headers["Content-type"], "application/soap+xml;charset=ISO-8859-1");
|
|
734
750
|
})
|
|
735
751
|
});
|
|
@@ -817,7 +833,7 @@ describe("Campaign exception", () => {
|
|
|
817
833
|
|
|
818
834
|
it("Should have HTTP request", () => {
|
|
819
835
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$");
|
|
820
|
-
const request = call._createHTTPRequest(URL);
|
|
836
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
821
837
|
assert.equal(request.url, URL);
|
|
822
838
|
})
|
|
823
839
|
|
|
@@ -826,13 +842,13 @@ describe("Campaign exception", () => {
|
|
|
826
842
|
describe("User agent", () => {
|
|
827
843
|
it("Should set user agent", () => {
|
|
828
844
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$", "My User Agent");
|
|
829
|
-
const request = call._createHTTPRequest(URL);
|
|
845
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
830
846
|
expect(request.headers['User-Agent']).toBe("My User Agent");
|
|
831
847
|
})
|
|
832
848
|
|
|
833
849
|
it("Should support no user agent", () => {
|
|
834
850
|
const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$", undefined);
|
|
835
|
-
const request = call._createHTTPRequest(URL);
|
|
851
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
836
852
|
expect(request.headers['User-Agent']).toBeUndefined();
|
|
837
853
|
})
|
|
838
854
|
})
|
|
@@ -850,5 +866,37 @@ describe("Campaign exception", () => {
|
|
|
850
866
|
expect(req.headers["X-Security-Token"].indexOf("$security$")).toBe(-1);
|
|
851
867
|
})
|
|
852
868
|
|
|
869
|
+
describe('Extra Http headers', () => {
|
|
870
|
+
it("Should take additional headers", () => {
|
|
871
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$", "My User Agent", undefined, { 'X-ACC-UI-Version': '1.0' });
|
|
872
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
873
|
+
expect(request.headers['User-Agent']).toBe("My User Agent");
|
|
874
|
+
expect(request.headers['X-ACC-UI-Version']).toBe("1.0");
|
|
875
|
+
expect(request.headers['SoapAction']).toBe("xtk:session#Date");
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
it("Should override default headers headers", () => {
|
|
879
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$", "My User Agent", undefined, { 'X-ACC-UI-Version': '1.0', 'SoapAction': 'My soap action' });
|
|
880
|
+
const [ request ] = call._createHTTPRequest(URL);
|
|
881
|
+
expect(request.headers['User-Agent']).toBe("My User Agent");
|
|
882
|
+
expect(request.headers['X-ACC-UI-Version']).toBe("1.0");
|
|
883
|
+
expect(request.headers['SoapAction']).toBe("My soap action");
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
describe('Adding method name in the URL', () => {
|
|
888
|
+
it("Should add the method name by default in the URL", () => {
|
|
889
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty", "$session$", "$security$");
|
|
890
|
+
call.finalize(URL);
|
|
891
|
+
expect(call.request.url).toBe("https://soap-test/nl/jsp/soaprouter.jsp?xtk:session#Empty");
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
it("Should be able to disable adding the method name by default in the URL", () => {
|
|
895
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty", "$session$", "$security$", undefined, { noMethodInURL: true });
|
|
896
|
+
call.finalize(URL);
|
|
897
|
+
expect(call.request.url).toBe("https://soap-test/nl/jsp/soaprouter.jsp");
|
|
898
|
+
});
|
|
899
|
+
});
|
|
900
|
+
|
|
853
901
|
});
|
|
854
902
|
|
package/.vscode/launch.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"type": "node",
|
|
9
|
-
"request": "launch",
|
|
10
|
-
"name": "Jest Current File",
|
|
11
|
-
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
|
12
|
-
"args": ["${relativeFile}"],
|
|
13
|
-
"console": "integratedTerminal",
|
|
14
|
-
"internalConsoleOptions": "neverOpen",
|
|
15
|
-
"windows": {
|
|
16
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
]
|
|
22
|
-
}
|