@adobe/acc-js-sdk 1.1.3 → 1.1.6

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/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, optionalCharset, charset, extraHttpHeaders) {
29
- const call = new SoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString, optionalCharset, charset, extraHttpHeaders);
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,7 @@ 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
382
  const env = DomUtil.parse(request.data).documentElement;
383
383
  const body = hasChildElement(env, "SOAP-ENV:Body");
384
384
  const method = hasChildElement(body, "m:Document");
@@ -394,7 +394,7 @@ describe('SOAP', function() {
394
394
 
395
395
  const call = makeSoapMethodCall(undefined, "xtk:session", "Document", "$session$", "$security$");
396
396
  call.writeDocument("p", doc.documentElement);
397
- const request = call._createHTTPRequest(URL);
397
+ const [ request ] = call._createHTTPRequest(URL);
398
398
  const env = DomUtil.parse(request.data).documentElement;
399
399
  const body = hasChildElement(env, "SOAP-ENV:Body");
400
400
  const method = hasChildElement(body, "m:Document");
@@ -408,7 +408,7 @@ describe('SOAP', function() {
408
408
  const call = makeSoapMethodCall(undefined, "xtk:session", "Document", "$session$", "$security$");
409
409
  call.writeDocument("p", null);
410
410
  call.writeDocument("q", undefined);
411
- const request = call._createHTTPRequest(URL);
411
+ const [ request ] = call._createHTTPRequest(URL);
412
412
  const env = DomUtil.parse(request.data).documentElement;
413
413
  const body = hasChildElement(env, "SOAP-ENV:Body");
414
414
  const method = hasChildElement(body, "m:Document");
@@ -704,14 +704,14 @@ describe('SOAP', function() {
704
704
 
705
705
  it("Should support no encoding", function() {
706
706
  const call = makeSoapMethodCall(undefined, "xtk:session", "Empty");
707
- const request = call._createHTTPRequest(URL);
707
+ const [ request ] = call._createHTTPRequest(URL);
708
708
  assert.equal(request.url, URL);
709
709
  assert.equal(request.headers["Content-type"], "application/soap+xml");
710
710
  });
711
711
 
712
712
  it("Should support UTF-8 encoding", function() {
713
- const call = makeSoapMethodCall(undefined, "xtk:session", "Empty", undefined, undefined, undefined, "UTF-8");
714
- 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);
715
715
  assert.equal(request.url, URL);
716
716
  assert.equal(request.headers["Content-type"], "application/soap+xml;charset=UTF-8");
717
717
  });
@@ -723,7 +723,7 @@ describe('SOAP', function() {
723
723
  expect(client._connectionParameters._options.charset).toBe('UTF-8');
724
724
  const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
725
725
  expect (soapCall._charset).toBe('UTF-8');
726
- const request = soapCall._createHTTPRequest(URL);
726
+ const [ request ] = soapCall._createHTTPRequest(URL);
727
727
  assert.equal(request.headers["Content-type"], "application/soap+xml;charset=UTF-8");
728
728
  })
729
729
 
@@ -734,7 +734,7 @@ describe('SOAP', function() {
734
734
  expect(client._connectionParameters._options.charset).toBe('');
735
735
  const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
736
736
  expect (soapCall._charset).toBe('');
737
- const request = soapCall._createHTTPRequest(URL);
737
+ const [ request ] = soapCall._createHTTPRequest(URL);
738
738
  assert.equal(request.headers["Content-type"], "application/soap+xml");
739
739
  })
740
740
 
@@ -745,7 +745,7 @@ describe('SOAP', function() {
745
745
  expect(client._connectionParameters._options.charset).toBe('ISO-8859-1');
746
746
  const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
747
747
  expect (soapCall._charset).toBe('ISO-8859-1');
748
- const request = soapCall._createHTTPRequest(URL);
748
+ const [ request ] = soapCall._createHTTPRequest(URL);
749
749
  assert.equal(request.headers["Content-type"], "application/soap+xml;charset=ISO-8859-1");
750
750
  })
751
751
  });
@@ -833,7 +833,7 @@ describe("Campaign exception", () => {
833
833
 
834
834
  it("Should have HTTP request", () => {
835
835
  const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$");
836
- const request = call._createHTTPRequest(URL);
836
+ const [ request ] = call._createHTTPRequest(URL);
837
837
  assert.equal(request.url, URL);
838
838
  })
839
839
 
@@ -842,13 +842,13 @@ describe("Campaign exception", () => {
842
842
  describe("User agent", () => {
843
843
  it("Should set user agent", () => {
844
844
  const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$", "My User Agent");
845
- const request = call._createHTTPRequest(URL);
845
+ const [ request ] = call._createHTTPRequest(URL);
846
846
  expect(request.headers['User-Agent']).toBe("My User Agent");
847
847
  })
848
848
 
849
849
  it("Should support no user agent", () => {
850
850
  const call = makeSoapMethodCall(undefined, "xtk:session", "Date", "$session$", "$security$", undefined);
851
- const request = call._createHTTPRequest(URL);
851
+ const [ request ] = call._createHTTPRequest(URL);
852
852
  expect(request.headers['User-Agent']).toBeUndefined();
853
853
  })
854
854
  })
@@ -869,7 +869,7 @@ describe("Campaign exception", () => {
869
869
  describe('Extra Http headers', () => {
870
870
  it("Should take additional headers", () => {
871
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);
872
+ const [ request ] = call._createHTTPRequest(URL);
873
873
  expect(request.headers['User-Agent']).toBe("My User Agent");
874
874
  expect(request.headers['X-ACC-UI-Version']).toBe("1.0");
875
875
  expect(request.headers['SoapAction']).toBe("xtk:session#Date");
@@ -877,12 +877,26 @@ describe("Campaign exception", () => {
877
877
 
878
878
  it("Should override default headers headers", () => {
879
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);
880
+ const [ request ] = call._createHTTPRequest(URL);
881
881
  expect(request.headers['User-Agent']).toBe("My User Agent");
882
882
  expect(request.headers['X-ACC-UI-Version']).toBe("1.0");
883
883
  expect(request.headers['SoapAction']).toBe("My soap action");
884
884
  });
885
885
  });
886
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
+
887
901
  });
888
902
 
@@ -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
- }