@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/client.test.js
CHANGED
|
@@ -25,7 +25,6 @@ const { HttpError } = require('../src/transport.js');
|
|
|
25
25
|
const { Cipher } = require('../src/crypto.js');
|
|
26
26
|
const { EntityAccessor } = require('../src/entityAccessor.js');
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
describe('ACC Client', function () {
|
|
30
29
|
|
|
31
30
|
describe('Init', function () {
|
|
@@ -2281,17 +2280,19 @@ describe('ACC Client', function () {
|
|
|
2281
2280
|
});
|
|
2282
2281
|
|
|
2283
2282
|
it("Should ignore protocol for local storage root key", async () => {
|
|
2283
|
+
const version = sdk.getSDKVersion().version; // "${version}" or similar
|
|
2284
|
+
|
|
2284
2285
|
var connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("http://acc-sdk:8080", "admin", "admin", {});
|
|
2285
2286
|
var client = await sdk.init(connectionParameters);
|
|
2286
|
-
expect(client._optionCache._storage._rootKey).toBe(
|
|
2287
|
+
expect(client._optionCache._storage._rootKey).toBe(`acc.js.sdk.${version}.acc-sdk:8080.cache.OptionCache$`);
|
|
2287
2288
|
|
|
2288
2289
|
connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("https://acc-sdk:8080", "admin", "admin", {});
|
|
2289
2290
|
client = await sdk.init(connectionParameters);
|
|
2290
|
-
expect(client._optionCache._storage._rootKey).toBe(
|
|
2291
|
+
expect(client._optionCache._storage._rootKey).toBe(`acc.js.sdk.${version}.acc-sdk:8080.cache.OptionCache$`);
|
|
2291
2292
|
|
|
2292
2293
|
connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("acc-sdk:8080", "admin", "admin", {});
|
|
2293
2294
|
client = await sdk.init(connectionParameters);
|
|
2294
|
-
expect(client._optionCache._storage._rootKey).toBe(
|
|
2295
|
+
expect(client._optionCache._storage._rootKey).toBe(`acc.js.sdk.${version}.acc-sdk:8080.cache.OptionCache$`);
|
|
2295
2296
|
})
|
|
2296
2297
|
|
|
2297
2298
|
it("Should support no storage", async () => {
|
|
@@ -2474,4 +2475,414 @@ describe('ACC Client', function () {
|
|
|
2474
2475
|
expect(json).toBe('{"#text":[],"extAccount":[{"id":"1816","name":"defaultPopAccount"},{"id":"1818","name":"defaultOther"},{"id":"1849","name":"billingReport"},{"id":"12070","name":"TST_EXT_ACCOUNT_POSTGRESQL"},{"id":"1817","name":"defaultEmailBulk"},{"id":"2087","name":"ffda"},{"id":"2088","name":"defaultEmailMid"}]}');
|
|
2475
2476
|
});
|
|
2476
2477
|
});
|
|
2478
|
+
|
|
2479
|
+
describe('Support for int type parameters such as nms:extAccount#UpdateMCSynchWkf', () => {
|
|
2480
|
+
it("Should call nms:extAccount#UpdateMCSynchWkf", async () => {
|
|
2481
|
+
const client = await Mock.makeClient();
|
|
2482
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2483
|
+
await client.NLWS.xtkSession.logon();
|
|
2484
|
+
|
|
2485
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
2486
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:wpp:default' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
2487
|
+
<SOAP-ENV:Body>
|
|
2488
|
+
<GetEntityIfMoreRecentResponse xmlns='urn:wpp:default' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
2489
|
+
<pdomDoc xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
2490
|
+
<schema name="extAccount" namespace="nms" xtkschema="xtk:schema">
|
|
2491
|
+
<element name="extAccount"></element>
|
|
2492
|
+
<methods>
|
|
2493
|
+
<method library="nms:messageCenter.js" name="UpdateMCSynchWkf" static="true" hidden="true">
|
|
2494
|
+
<parameters>
|
|
2495
|
+
<param name="extAccountId" type="int" desc="Message Center external account identifier"/>
|
|
2496
|
+
</parameters>
|
|
2497
|
+
</method>
|
|
2498
|
+
</methods>
|
|
2499
|
+
</schema>
|
|
2500
|
+
</pdomDoc>
|
|
2501
|
+
</GetEntityIfMoreRecentResponse>
|
|
2502
|
+
</SOAP-ENV:Body>
|
|
2503
|
+
</SOAP-ENV:Envelope>`));
|
|
2504
|
+
|
|
2505
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
2506
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:nms:extAccount' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
2507
|
+
<SOAP-ENV:Body>
|
|
2508
|
+
<UpdateMCSynchWkfResponse xmlns='urn:nms:extAccount' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
2509
|
+
</UpdateMCSynchWkfResponse>
|
|
2510
|
+
</SOAP-ENV:Body>
|
|
2511
|
+
</SOAP-ENV:Envelope>`));
|
|
2512
|
+
|
|
2513
|
+
await client.NLWS.nmsExtAccount.updateMCSynchWkf(1);
|
|
2514
|
+
})
|
|
2515
|
+
});
|
|
2516
|
+
|
|
2517
|
+
describe("Method-level HTTP headers", () => {
|
|
2518
|
+
it("Should set header", async () => {
|
|
2519
|
+
const client = await Mock.makeClient();
|
|
2520
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2521
|
+
await client.NLWS.xtkSession.logon();
|
|
2522
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2523
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2524
|
+
const queryDef = {
|
|
2525
|
+
"schema": "nms:extAccount",
|
|
2526
|
+
"operation": "select",
|
|
2527
|
+
"select": {
|
|
2528
|
+
"node": [
|
|
2529
|
+
{ "expr": "@id" },
|
|
2530
|
+
{ "expr": "@name" }
|
|
2531
|
+
]
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
const query = client.NLWS.headers({'X-Test': 'hello'}).xtkQueryDef.create(queryDef);
|
|
2535
|
+
|
|
2536
|
+
let headers = {};
|
|
2537
|
+
client.registerObserver({
|
|
2538
|
+
onSOAPCall: (soapCall) => {
|
|
2539
|
+
const request = soapCall.request;
|
|
2540
|
+
headers = request.headers;
|
|
2541
|
+
}
|
|
2542
|
+
});
|
|
2543
|
+
await query.executeQuery();
|
|
2544
|
+
expect(headers).toMatchObject({
|
|
2545
|
+
"SoapAction": "xtk:queryDef#ExecuteQuery",
|
|
2546
|
+
"X-Test": "hello"
|
|
2547
|
+
});
|
|
2548
|
+
});
|
|
2549
|
+
|
|
2550
|
+
it("Should support global and method-level http headers", async () => {
|
|
2551
|
+
const client = await Mock.makeClient({
|
|
2552
|
+
extraHttpHeaders: {
|
|
2553
|
+
"X-Test": "world",
|
|
2554
|
+
"X-Test-Global": "global"
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2558
|
+
await client.NLWS.xtkSession.logon();
|
|
2559
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2560
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2561
|
+
const queryDef = {
|
|
2562
|
+
"schema": "nms:extAccount",
|
|
2563
|
+
"operation": "select",
|
|
2564
|
+
"select": {
|
|
2565
|
+
"node": [
|
|
2566
|
+
{ "expr": "@id" },
|
|
2567
|
+
{ "expr": "@name" }
|
|
2568
|
+
]
|
|
2569
|
+
}
|
|
2570
|
+
};
|
|
2571
|
+
const query = client.NLWS.headers({'X-Test': 'hello'}).xtkQueryDef.create(queryDef);
|
|
2572
|
+
|
|
2573
|
+
let headers = {};
|
|
2574
|
+
client.registerObserver({
|
|
2575
|
+
onSOAPCall: (soapCall) => {
|
|
2576
|
+
const request = soapCall.request;
|
|
2577
|
+
headers = request.headers;
|
|
2578
|
+
}
|
|
2579
|
+
});
|
|
2580
|
+
await query.executeQuery();
|
|
2581
|
+
expect(headers).toMatchObject({
|
|
2582
|
+
"SoapAction": "xtk:queryDef#ExecuteQuery",
|
|
2583
|
+
"X-Test": "hello",
|
|
2584
|
+
"X-Test-Global": "global"
|
|
2585
|
+
});
|
|
2586
|
+
})
|
|
2587
|
+
|
|
2588
|
+
it("Should support undefined method headers", async () => {
|
|
2589
|
+
const client = await Mock.makeClient({
|
|
2590
|
+
extraHttpHeaders: {
|
|
2591
|
+
"X-Test": "world",
|
|
2592
|
+
"X-Test-Global": "global"
|
|
2593
|
+
}
|
|
2594
|
+
});
|
|
2595
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2596
|
+
await client.NLWS.xtkSession.logon();
|
|
2597
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2598
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2599
|
+
const queryDef = {
|
|
2600
|
+
"schema": "nms:extAccount",
|
|
2601
|
+
"operation": "select",
|
|
2602
|
+
"select": {
|
|
2603
|
+
"node": [
|
|
2604
|
+
{ "expr": "@id" },
|
|
2605
|
+
{ "expr": "@name" }
|
|
2606
|
+
]
|
|
2607
|
+
}
|
|
2608
|
+
};
|
|
2609
|
+
// missing headers
|
|
2610
|
+
const query = client.NLWS.headers().xtkQueryDef.create(queryDef);
|
|
2611
|
+
|
|
2612
|
+
let headers = {};
|
|
2613
|
+
client.registerObserver({
|
|
2614
|
+
onSOAPCall: (soapCall) => {
|
|
2615
|
+
const request = soapCall.request;
|
|
2616
|
+
headers = request.headers;
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
await query.executeQuery();
|
|
2620
|
+
expect(headers).toMatchObject({
|
|
2621
|
+
"SoapAction": "xtk:queryDef#ExecuteQuery",
|
|
2622
|
+
"X-Test": "world",
|
|
2623
|
+
"X-Test-Global": "global"
|
|
2624
|
+
});
|
|
2625
|
+
})
|
|
2626
|
+
|
|
2627
|
+
it("Should set http headers with an xml representation", async () => {
|
|
2628
|
+
const client = await Mock.makeClient();
|
|
2629
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2630
|
+
await client.NLWS.xtkSession.logon();
|
|
2631
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2632
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2633
|
+
const queryDef = DomUtil.parse(`
|
|
2634
|
+
<queryDef schema="nms:extAccount" operation="select">
|
|
2635
|
+
<select>
|
|
2636
|
+
<node expr="@id"/>
|
|
2637
|
+
<node expr="@name"/>
|
|
2638
|
+
</select>
|
|
2639
|
+
</queryDef>
|
|
2640
|
+
`);
|
|
2641
|
+
const query = client.NLWS
|
|
2642
|
+
.headers({'X-Test': 'hello', 'X-Test-Before': 'before'})
|
|
2643
|
+
.xml
|
|
2644
|
+
.headers({'X-Test': 'world', 'X-Test-After': 'after'})
|
|
2645
|
+
.xtkQueryDef.create(queryDef);
|
|
2646
|
+
let headers = {};
|
|
2647
|
+
client.registerObserver({
|
|
2648
|
+
onSOAPCall: (soapCall) => {
|
|
2649
|
+
const request = soapCall.request;
|
|
2650
|
+
headers = request.headers;
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
await query.executeQuery();
|
|
2654
|
+
console.log(headers);
|
|
2655
|
+
expect(headers).toMatchObject({
|
|
2656
|
+
"SoapAction": "xtk:queryDef#ExecuteQuery",
|
|
2657
|
+
"X-Test": "world",
|
|
2658
|
+
"X-Test-Before": "before",
|
|
2659
|
+
"X-Test-After": "after"
|
|
2660
|
+
});
|
|
2661
|
+
});
|
|
2662
|
+
});
|
|
2663
|
+
|
|
2664
|
+
describe("ACC-SDK HTTP headers", () => {
|
|
2665
|
+
|
|
2666
|
+
const collectHeaders = async (client, callback) => {
|
|
2667
|
+
let headers = {};
|
|
2668
|
+
client.registerObserver({
|
|
2669
|
+
onSOAPCall: (soapCall) => {
|
|
2670
|
+
const request = soapCall.request;
|
|
2671
|
+
headers = request.headers;
|
|
2672
|
+
},
|
|
2673
|
+
onHTTPCall: (request) => {
|
|
2674
|
+
headers = request.headers;
|
|
2675
|
+
}
|
|
2676
|
+
});
|
|
2677
|
+
await callback();
|
|
2678
|
+
return headers;
|
|
2679
|
+
};
|
|
2680
|
+
|
|
2681
|
+
it("Should set headers by default", async () => {
|
|
2682
|
+
const client = await Mock.makeClient();
|
|
2683
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2684
|
+
await client.NLWS.xtkSession.logon();
|
|
2685
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2686
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2687
|
+
const queryDef = {
|
|
2688
|
+
"schema": "nms:extAccount",
|
|
2689
|
+
"operation": "select",
|
|
2690
|
+
"select": {
|
|
2691
|
+
"node": [
|
|
2692
|
+
{ "expr": "@id" },
|
|
2693
|
+
{ "expr": "@name" }
|
|
2694
|
+
]
|
|
2695
|
+
}
|
|
2696
|
+
};
|
|
2697
|
+
const query = client.NLWS.xtkQueryDef.create(queryDef);
|
|
2698
|
+
|
|
2699
|
+
const headers = await collectHeaders(client, async() => {
|
|
2700
|
+
await query.executeQuery();
|
|
2701
|
+
});
|
|
2702
|
+
|
|
2703
|
+
expect(headers).toMatchObject({
|
|
2704
|
+
"ACC-SDK-Version": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version}`,
|
|
2705
|
+
"ACC-SDK-Auth": "UserPassword admin",
|
|
2706
|
+
"X-Query-Source": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version}`,
|
|
2707
|
+
});
|
|
2708
|
+
// This header is only set if "clientApp" connection parameter is set
|
|
2709
|
+
expect(headers["ACC-SDK-Client-App"]).toBeUndefined();
|
|
2710
|
+
});
|
|
2711
|
+
|
|
2712
|
+
it("Should disable ACC-SDK headers", async () => {
|
|
2713
|
+
const client = await Mock.makeClient({
|
|
2714
|
+
noSDKHeaders: true
|
|
2715
|
+
});
|
|
2716
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2717
|
+
await client.NLWS.xtkSession.logon();
|
|
2718
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2719
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2720
|
+
const queryDef = {
|
|
2721
|
+
"schema": "nms:extAccount",
|
|
2722
|
+
"operation": "select",
|
|
2723
|
+
"select": {
|
|
2724
|
+
"node": [
|
|
2725
|
+
{ "expr": "@id" },
|
|
2726
|
+
{ "expr": "@name" }
|
|
2727
|
+
]
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
const query = client.NLWS.xtkQueryDef.create(queryDef);
|
|
2731
|
+
|
|
2732
|
+
const headers = await collectHeaders(client, async() => {
|
|
2733
|
+
await query.executeQuery();
|
|
2734
|
+
});
|
|
2735
|
+
expect(headers["ACC-SDK-Version"]).toBeUndefined();
|
|
2736
|
+
expect(headers["ACC-SDK-Auth"]).toBeUndefined();
|
|
2737
|
+
expect(headers["X-Query-Source"]).toBe(`${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version}`);
|
|
2738
|
+
});
|
|
2739
|
+
|
|
2740
|
+
it("Should support ACC-SDK-Client-App header", async () => {
|
|
2741
|
+
const client = await Mock.makeClient({
|
|
2742
|
+
clientApp: 'Test client app'
|
|
2743
|
+
});
|
|
2744
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2745
|
+
await client.NLWS.xtkSession.logon();
|
|
2746
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2747
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2748
|
+
const queryDef = {
|
|
2749
|
+
"schema": "nms:extAccount",
|
|
2750
|
+
"operation": "select",
|
|
2751
|
+
"select": {
|
|
2752
|
+
"node": [
|
|
2753
|
+
{ "expr": "@id" },
|
|
2754
|
+
{ "expr": "@name" }
|
|
2755
|
+
]
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
const query = client.NLWS.xtkQueryDef.create(queryDef);
|
|
2759
|
+
|
|
2760
|
+
const headers = await collectHeaders(client, async() => {
|
|
2761
|
+
await query.executeQuery();
|
|
2762
|
+
});
|
|
2763
|
+
expect(headers).toMatchObject({
|
|
2764
|
+
"ACC-SDK-Version": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version}`,
|
|
2765
|
+
"ACC-SDK-Auth": "UserPassword admin",
|
|
2766
|
+
"ACC-SDK-Client-App": "Test client app",
|
|
2767
|
+
"X-Query-Source": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version},Test client app`,
|
|
2768
|
+
});
|
|
2769
|
+
});
|
|
2770
|
+
|
|
2771
|
+
it("Should set ACC-SDK headers on ping JSP", async () => {
|
|
2772
|
+
const client = await Mock.makeClient({
|
|
2773
|
+
clientApp: 'Test client app'
|
|
2774
|
+
});
|
|
2775
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2776
|
+
await client.NLWS.xtkSession.logon();
|
|
2777
|
+
const headers = await collectHeaders(client, async() => {
|
|
2778
|
+
client._transport.mockReturnValueOnce(Mock.PING);
|
|
2779
|
+
await client.ping();
|
|
2780
|
+
});
|
|
2781
|
+
expect(headers).toMatchObject({
|
|
2782
|
+
"ACC-SDK-Version": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version}`,
|
|
2783
|
+
"ACC-SDK-Auth": "UserPassword admin",
|
|
2784
|
+
"ACC-SDK-Client-App": "Test client app",
|
|
2785
|
+
"X-Query-Source": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version},Test client app`,
|
|
2786
|
+
});
|
|
2787
|
+
});
|
|
2788
|
+
|
|
2789
|
+
it("Should set ACC-SDK headers on mcping JSP", async () => {
|
|
2790
|
+
const client = await Mock.makeClient({
|
|
2791
|
+
clientApp: 'Test client app'
|
|
2792
|
+
});
|
|
2793
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2794
|
+
await client.NLWS.xtkSession.logon();
|
|
2795
|
+
const headers = await collectHeaders(client, async() => {
|
|
2796
|
+
client._transport.mockReturnValueOnce(Mock.MC_PING);
|
|
2797
|
+
await client.mcPing();
|
|
2798
|
+
});
|
|
2799
|
+
expect(headers).toMatchObject({
|
|
2800
|
+
"ACC-SDK-Version": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version}`,
|
|
2801
|
+
"ACC-SDK-Auth": "UserPassword admin",
|
|
2802
|
+
"ACC-SDK-Client-App": "Test client app",
|
|
2803
|
+
"X-Query-Source": `${sdk.getSDKVersion().name} ${sdk.getSDKVersion().version},Test client app`,
|
|
2804
|
+
});
|
|
2805
|
+
});
|
|
2806
|
+
});
|
|
2807
|
+
|
|
2808
|
+
describe("Pushdown parameters", () => {
|
|
2809
|
+
it("Should push down custom parameters", async () => {
|
|
2810
|
+
const client = await Mock.makeClient();
|
|
2811
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2812
|
+
await client.NLWS.xtkSession.logon();
|
|
2813
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2814
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2815
|
+
const queryDef = {
|
|
2816
|
+
"schema": "nms:extAccount",
|
|
2817
|
+
"operation": "select",
|
|
2818
|
+
"select": {
|
|
2819
|
+
"node": [
|
|
2820
|
+
{ "expr": "@id" },
|
|
2821
|
+
{ "expr": "@name" }
|
|
2822
|
+
]
|
|
2823
|
+
}
|
|
2824
|
+
};
|
|
2825
|
+
// Pushing down the foo=bar attributes
|
|
2826
|
+
const query = client.NLWS.pushDown({'foo': 'bar'}).xtkQueryDef.create(queryDef);
|
|
2827
|
+
await query.executeQuery();
|
|
2828
|
+
const lastCall = client._transport.mock.calls[client._transport.mock.calls.length-1];
|
|
2829
|
+
expect(lastCall[0].url).toBe("http://acc-sdk:8080/nl/jsp/soaprouter.jsp?xtk:queryDef#ExecuteQuery");
|
|
2830
|
+
expect(lastCall[1].charset).toBe("UTF-8");
|
|
2831
|
+
expect(lastCall[1].foo).toBe("bar");
|
|
2832
|
+
});
|
|
2833
|
+
|
|
2834
|
+
it("Should push down custom parameters defined at the connection level", async () => {
|
|
2835
|
+
const client = await Mock.makeClient({ 'cnxDefault': 3, 'foo': 'foo' });
|
|
2836
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2837
|
+
await client.NLWS.xtkSession.logon();
|
|
2838
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2839
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2840
|
+
const queryDef = {
|
|
2841
|
+
"schema": "nms:extAccount",
|
|
2842
|
+
"operation": "select",
|
|
2843
|
+
"select": {
|
|
2844
|
+
"node": [
|
|
2845
|
+
{ "expr": "@id" },
|
|
2846
|
+
{ "expr": "@name" }
|
|
2847
|
+
]
|
|
2848
|
+
}
|
|
2849
|
+
};
|
|
2850
|
+
// Pushing down the foo=bar attributes (should overload the "foo" set in connecion parameters)
|
|
2851
|
+
const query = client.NLWS.pushDown({'foo': 'bar'}).xtkQueryDef.create(queryDef);
|
|
2852
|
+
await query.executeQuery();
|
|
2853
|
+
const lastCall = client._transport.mock.calls[client._transport.mock.calls.length-1];
|
|
2854
|
+
expect(lastCall[0].url).toBe("http://acc-sdk:8080/nl/jsp/soaprouter.jsp?xtk:queryDef#ExecuteQuery");
|
|
2855
|
+
expect(lastCall[1].charset).toBe("UTF-8");
|
|
2856
|
+
expect(lastCall[1].foo).toBe("bar");
|
|
2857
|
+
expect(lastCall[1].cnxDefault).toBe(3);
|
|
2858
|
+
});
|
|
2859
|
+
|
|
2860
|
+
it("Should chain push options", async () => {
|
|
2861
|
+
const client = await Mock.makeClient({ 'cnxDefault': 3, 'foo': 'foo' });
|
|
2862
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2863
|
+
await client.NLWS.xtkSession.logon();
|
|
2864
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2865
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2866
|
+
const queryDef = {
|
|
2867
|
+
"schema": "nms:extAccount",
|
|
2868
|
+
"operation": "select",
|
|
2869
|
+
"select": {
|
|
2870
|
+
"node": [
|
|
2871
|
+
{ "expr": "@id" },
|
|
2872
|
+
{ "expr": "@name" }
|
|
2873
|
+
]
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
// Supports multiple calls to pushDown. each one overrides the previous in case of duplicate key
|
|
2877
|
+
// Also supports undefined
|
|
2878
|
+
const query = client.NLWS.pushDown({'foo': 'bar'}).pushDown().pushDown({'foo': 'fu', x: 2 }).xtkQueryDef.create(queryDef);
|
|
2879
|
+
await query.executeQuery();
|
|
2880
|
+
const lastCall = client._transport.mock.calls[client._transport.mock.calls.length-1];
|
|
2881
|
+
expect(lastCall[0].url).toBe("http://acc-sdk:8080/nl/jsp/soaprouter.jsp?xtk:queryDef#ExecuteQuery");
|
|
2882
|
+
expect(lastCall[1].charset).toBe("UTF-8");
|
|
2883
|
+
expect(lastCall[1].foo).toBe("fu");
|
|
2884
|
+
expect(lastCall[1].cnxDefault).toBe(3);
|
|
2885
|
+
expect(lastCall[1].x).toBe(2);
|
|
2886
|
+
});
|
|
2887
|
+
});
|
|
2477
2888
|
});
|