@adobe/acc-js-sdk 1.1.48 → 1.1.50
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 +18 -0
- package/package-lock.json +9 -6
- package/package.json +1 -1
- package/src/client.js +7 -1
- package/src/xtkJob.js +5 -3
- package/test/client.test.js +93 -0
- package/test/xtkJob.test.js +65 -10
package/docs/changeLog.html
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
layout: page
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
|
+
<section class="changelog"><h1>Version 1.1.50</h1>
|
|
6
|
+
<h2>2024/07/18</h2>
|
|
7
|
+
<li>
|
|
8
|
+
<a href="https://github.com/adobe/acc-js-sdk/pull/110">Issue 110</a>. Update fileUploader iframe style so it remains hidden.
|
|
9
|
+
</li>
|
|
10
|
+
</section>
|
|
11
|
+
|
|
12
|
+
<section class="changelog"><h1>Version 1.1.49</h1>
|
|
13
|
+
<h2>2024/07/07</h2>
|
|
14
|
+
<li>
|
|
15
|
+
<a href="https://github.com/adobe/acc-js-sdk/pull/109">Issue 109</a>. Extra HTTP headers were not passed in all API calls.
|
|
16
|
+
</li>
|
|
17
|
+
<li>
|
|
18
|
+
Updated dependencies to fix vulnerabilities.
|
|
19
|
+
</li>
|
|
20
|
+
</section>
|
|
21
|
+
|
|
22
|
+
|
|
5
23
|
<section class="changelog"><h1>Version 1.1.48</h1>
|
|
6
24
|
<h2>2024/06/11</h2>
|
|
7
25
|
<li>
|
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.50",
|
|
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.50",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.2.1",
|
|
@@ -4587,14 +4587,15 @@
|
|
|
4587
4587
|
}
|
|
4588
4588
|
},
|
|
4589
4589
|
"node_modules/ws": {
|
|
4590
|
-
"version": "8.
|
|
4591
|
-
"
|
|
4590
|
+
"version": "8.18.0",
|
|
4591
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
|
|
4592
|
+
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
|
4592
4593
|
"engines": {
|
|
4593
4594
|
"node": ">=10.0.0"
|
|
4594
4595
|
},
|
|
4595
4596
|
"peerDependencies": {
|
|
4596
4597
|
"bufferutil": "^4.0.1",
|
|
4597
|
-
"utf-8-validate": "
|
|
4598
|
+
"utf-8-validate": ">=5.0.2"
|
|
4598
4599
|
},
|
|
4599
4600
|
"peerDependenciesMeta": {
|
|
4600
4601
|
"bufferutil": {
|
|
@@ -7716,7 +7717,9 @@
|
|
|
7716
7717
|
}
|
|
7717
7718
|
},
|
|
7718
7719
|
"ws": {
|
|
7719
|
-
"version": "8.
|
|
7720
|
+
"version": "8.18.0",
|
|
7721
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
|
|
7722
|
+
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
|
7720
7723
|
"requires": {}
|
|
7721
7724
|
},
|
|
7722
7725
|
"xml": {
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -595,6 +595,8 @@ const fileUploader = (client) => {
|
|
|
595
595
|
const data = new FormData();
|
|
596
596
|
data.append('file_noMd5', file);
|
|
597
597
|
const headers = client._getAuthHeaders(false);
|
|
598
|
+
for (let h in client._connectionParameters._options.extraHttpHeaders)
|
|
599
|
+
headers[h] = client._connectionParameters._options.extraHttpHeaders[h];
|
|
598
600
|
client._makeHttpCall({
|
|
599
601
|
url: `${client._connectionParameters._endpoint}/nl/jsp/uploadFile.jsp`,
|
|
600
602
|
processData: false,
|
|
@@ -607,6 +609,7 @@ const fileUploader = (client) => {
|
|
|
607
609
|
}
|
|
608
610
|
const iframe = document.createElement('iframe');
|
|
609
611
|
iframe.style.display = 'block';
|
|
612
|
+
iframe.style.border = 'none';
|
|
610
613
|
iframe.style.height = 0;
|
|
611
614
|
iframe.style.width = 0;
|
|
612
615
|
if(options && options.className) {
|
|
@@ -680,7 +683,8 @@ const fileUploader = (client) => {
|
|
|
680
683
|
const jsonData = JSON.stringify({
|
|
681
684
|
'assetDownloadUrl': assetDownloadUrl
|
|
682
685
|
});
|
|
683
|
-
|
|
686
|
+
for (let h in client._connectionParameters._options.extraHttpHeaders)
|
|
687
|
+
headers[h] = client._connectionParameters._options.extraHttpHeaders[h];
|
|
684
688
|
var response = await client._makeHttpCall({
|
|
685
689
|
url: url,
|
|
686
690
|
method: 'POST',
|
|
@@ -746,6 +750,8 @@ const fileUploader = (client) => {
|
|
|
746
750
|
}
|
|
747
751
|
|
|
748
752
|
const headers = client._getAuthHeaders(false);
|
|
753
|
+
for (let h in client._connectionParameters._options.extraHttpHeaders)
|
|
754
|
+
headers[h] = client._connectionParameters._options.extraHttpHeaders[h];
|
|
749
755
|
const rawFileResponse = await client._makeHttpCall({
|
|
750
756
|
url: `${client._connectionParameters._endpoint}/nl/jsp/downloadFile.jsp?${queryString}`,
|
|
751
757
|
headers: headers,
|
package/src/xtkJob.js
CHANGED
|
@@ -112,7 +112,8 @@ class XtkJobInterface {
|
|
|
112
112
|
client: this._client,
|
|
113
113
|
object: this._soapCall.object,
|
|
114
114
|
schemaId: 'xtk:jobInterface',
|
|
115
|
-
entitySchemaId: entitySchemaId
|
|
115
|
+
entitySchemaId: entitySchemaId,
|
|
116
|
+
headers: this._client._connectionParameters._options.extraHttpHeaders
|
|
116
117
|
};
|
|
117
118
|
var jobId = await callContext.client._callMethod("Execute", callContext, [ methodName ]);
|
|
118
119
|
this.jobId = jobId;
|
|
@@ -135,7 +136,8 @@ class XtkJobInterface {
|
|
|
135
136
|
client: this._client,
|
|
136
137
|
object: this._soapCall.object,
|
|
137
138
|
schemaId: 'xtk:jobInterface',
|
|
138
|
-
entitySchemaId: entitySchemaId
|
|
139
|
+
entitySchemaId: entitySchemaId,
|
|
140
|
+
headers: this._client._connectionParameters._options.extraHttpHeaders
|
|
139
141
|
};
|
|
140
142
|
var jobId = await callContext.client._callMethod("Submit", callContext, [ this._soapCall.method ]);
|
|
141
143
|
this.jobId = jobId;
|
|
@@ -156,8 +158,8 @@ class XtkJobInterface {
|
|
|
156
158
|
object: this._soapCall.object,
|
|
157
159
|
schemaId: 'xtk:jobInterface',
|
|
158
160
|
entitySchemaId: entitySchemaId,
|
|
161
|
+
headers: this._client._connectionParameters._options.extraHttpHeaders
|
|
159
162
|
};
|
|
160
|
-
|
|
161
163
|
const methodName = this._soapCall.method;
|
|
162
164
|
var schema = await this._client.getSchema(entitySchemaId, "xml", true);
|
|
163
165
|
if (!schema)
|
package/test/client.test.js
CHANGED
|
@@ -3717,7 +3717,60 @@ describe('ACC Client', function () {
|
|
|
3717
3717
|
url: "http://hello.com",
|
|
3718
3718
|
});
|
|
3719
3719
|
});
|
|
3720
|
+
it("Should add extraHttpHeaders in the headers", async () => {
|
|
3721
|
+
// Create a mock client and logon
|
|
3722
|
+
const extraHttpHeaders = {'x-api-key': 'check'};
|
|
3723
|
+
const client = await Mock.makeClient({extraHttpHeaders});
|
|
3724
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3725
|
+
await client.NLWS.xtkSession.logon();
|
|
3726
|
+
|
|
3727
|
+
// Mock the upload protocol
|
|
3728
|
+
// - the upload.jsp (which returns the content of an iframe and JS to eval)
|
|
3729
|
+
// - call to xtk:counter#IncreaseValue (first, retrieve the schema xtk:counter then call the function)
|
|
3730
|
+
// - call to xtk:session#Write
|
|
3731
|
+
// - call to xtk:fileRes#PublishIfNeeded
|
|
3732
|
+
// - call to xtk:fileRes#GetURL
|
|
3733
|
+
|
|
3734
|
+
client._transport.mockReturnValueOnce(
|
|
3735
|
+
Promise.resolve(`Ok
|
|
3736
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
3737
|
+
<head>
|
|
3738
|
+
<script type="text/javascript">if(window.parent&&window.parent.document.controller&&"function"==typeof window.parent.document.controller.uploadFileCallBack){var aFilesInfo=new Array;aFilesInfo.push({paramName:"file",fileName:"test.txt",newFileName:"d8e8fca2dc0f896fd7cb4cb0031ba249.txt",md5:"d8e8fca2dc0f896fd7cb4cb0031ba249"}),window.parent.document.controller.uploadFileCallBack(aFilesInfo)}</script>
|
|
3739
|
+
</head>
|
|
3740
|
+
<body></body>
|
|
3741
|
+
</html>`)
|
|
3742
|
+
); // upload.jsp
|
|
3743
|
+
|
|
3744
|
+
client._transport.mockReturnValueOnce(
|
|
3745
|
+
Promise.resolve(Mock.GET_XTK_COUNTER_RESPONSE)
|
|
3746
|
+
); // GetEntityIfMoreRecentResponse - counter
|
|
3747
|
+
client._transport.mockReturnValueOnce(Mock.INCREASE_VALUE_RESPONSE); // xtk:counter#IncreaseValue
|
|
3748
|
+
|
|
3749
|
+
client._transport.mockReturnValueOnce(
|
|
3750
|
+
Mock.GET_XTK_SESSION_SCHEMA_RESPONSE
|
|
3751
|
+
); // GetEntityIfMoreRecentResponse - session
|
|
3752
|
+
client._transport.mockReturnValueOnce(Mock.FILE_RES_WRITE_RESPONSE); // xtk:session#Write
|
|
3753
|
+
|
|
3754
|
+
client._transport.mockReturnValueOnce(
|
|
3755
|
+
Promise.resolve(Mock.GET_FILERES_QUERY_SCHEMA_RESPONSE)
|
|
3756
|
+
); // GetEntityIfMoreRecentResponse - fileRes
|
|
3757
|
+
client._transport.mockReturnValueOnce(
|
|
3758
|
+
Promise.resolve(Mock.PUBLISH_IF_NEEDED_RESPONSE)
|
|
3759
|
+
); // xtk:fileRes#PublishIfNeeded
|
|
3720
3760
|
|
|
3761
|
+
client._transport.mockReturnValueOnce(
|
|
3762
|
+
Promise.resolve(Mock.GET_URL_RESPONSE)
|
|
3763
|
+
); // xtk:fileRes#GetURL
|
|
3764
|
+
|
|
3765
|
+
// Call upload
|
|
3766
|
+
await client.fileUploader.upload({
|
|
3767
|
+
type: "text/html",
|
|
3768
|
+
size: 12345,
|
|
3769
|
+
});
|
|
3770
|
+
expect(client._transport.mock.calls[0][0]).toMatchObject(expect.objectContaining({
|
|
3771
|
+
headers: expect.objectContaining(extraHttpHeaders),
|
|
3772
|
+
}));
|
|
3773
|
+
});
|
|
3721
3774
|
it("throws error with dependant failures", async () => {
|
|
3722
3775
|
// Create a mock client and logon
|
|
3723
3776
|
const client = await Mock.makeClient();
|
|
@@ -4107,6 +4160,26 @@ describe('ACC Client', function () {
|
|
|
4107
4160
|
await client.NLWS.xtkSession.logoff();
|
|
4108
4161
|
});
|
|
4109
4162
|
|
|
4163
|
+
it("Should add extraHttpHeaders in the headers", async () => {
|
|
4164
|
+
const extraHttpHeaders = {'x-api-key': 'check'};
|
|
4165
|
+
const client = await Mock.makeClient({extraHttpHeaders});
|
|
4166
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
4167
|
+
await client.NLWS.xtkSession.logon();
|
|
4168
|
+
|
|
4169
|
+
const mockResponse = {
|
|
4170
|
+
publishedURL:
|
|
4171
|
+
"http://trk-inst-xyz.camp.adobe.com/res/trk-inst/409afb8798180a36591456e152b6c406.jpeg",
|
|
4172
|
+
};
|
|
4173
|
+
client._bearerToken = "Bearer 1234567890";
|
|
4174
|
+
client._transport.mockReturnValueOnce(mockResponse);
|
|
4175
|
+
await client.fileUploader.uploadAemAsset(
|
|
4176
|
+
"https://author-stg.aem.adobe.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download"
|
|
4177
|
+
);
|
|
4178
|
+
expect(client._transport.mock.calls[0][0]).toMatchObject(expect.objectContaining({
|
|
4179
|
+
headers: expect.objectContaining(extraHttpHeaders),
|
|
4180
|
+
}));
|
|
4181
|
+
});
|
|
4182
|
+
|
|
4110
4183
|
// Case 2: Bearertoken is not provided, but the client is already authenticated with session token
|
|
4111
4184
|
it("Should throw error for missing authentication token", async () => {
|
|
4112
4185
|
const client = await Mock.makeClient();
|
|
@@ -4244,6 +4317,26 @@ describe('ACC Client', function () {
|
|
|
4244
4317
|
expect(response).toStrictEqual(mockResponse);
|
|
4245
4318
|
});
|
|
4246
4319
|
|
|
4320
|
+
it("Should add extraHttpHeaders in the headers", async () => {
|
|
4321
|
+
const extraHttpHeaders = {'x-api-key': 'check'}
|
|
4322
|
+
const client = await Mock.makeClient({extraHttpHeaders});
|
|
4323
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
4324
|
+
await client.NLWS.xtkSession.logon();
|
|
4325
|
+
|
|
4326
|
+
const mockResponse = Mock.FILE_DOWNLOAD_RESPONSE;
|
|
4327
|
+
client._transport.mockReturnValueOnce(mockResponse);
|
|
4328
|
+
|
|
4329
|
+
await client.fileUploader.download(
|
|
4330
|
+
fileMd5,
|
|
4331
|
+
fileExt,
|
|
4332
|
+
fileOptions,
|
|
4333
|
+
);
|
|
4334
|
+
|
|
4335
|
+
expect(client._transport.mock.calls[0][0]).toMatchObject(expect.objectContaining({
|
|
4336
|
+
headers: expect.objectContaining(extraHttpHeaders),
|
|
4337
|
+
}));
|
|
4338
|
+
});
|
|
4339
|
+
|
|
4247
4340
|
it("Should return correct response without fileOptions", async () => {
|
|
4248
4341
|
const client = await Mock.makeClient();
|
|
4249
4342
|
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
package/test/xtkJob.test.js
CHANGED
|
@@ -176,7 +176,7 @@ describe('XRK Jobs', function () {
|
|
|
176
176
|
|
|
177
177
|
describe("Execute", () => {
|
|
178
178
|
it("Execute with success", async () => {
|
|
179
|
-
const client = { _callMethod: jest.fn() };
|
|
179
|
+
const client = { _callMethod: jest.fn(), _connectionParameters: { _options: {}} };
|
|
180
180
|
const job = new XtkJobInterface(client, { xtkschema: "nms:delivery", object: "Hello World", method: "Prepare" });
|
|
181
181
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
182
182
|
const jobId = await job.execute();
|
|
@@ -191,8 +191,26 @@ describe('XRK Jobs', function () {
|
|
|
191
191
|
expect(client._callMethod.mock.calls[0][2]).toEqual([ "Prepare" ]);
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
+
it("Execute should pass extraHttpHeaders in headers", async () => {
|
|
195
|
+
const extraHttpHeaders = {'x-api-key': 'check'};
|
|
196
|
+
const client = { _callMethod: jest.fn(), _connectionParameters: { _options: { extraHttpHeaders }} };
|
|
197
|
+
const job = new XtkJobInterface(client, { xtkschema: "nms:delivery", object: "Hello World", method: "Prepare" });
|
|
198
|
+
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
199
|
+
const jobId = await job.execute();
|
|
200
|
+
expect(jobId).toBe("9876");
|
|
201
|
+
expect(client._callMethod.mock.calls.length).toBe(1);
|
|
202
|
+
expect(client._callMethod.mock.calls[0][0]).toBe("Execute");
|
|
203
|
+
expect(client._callMethod.mock.calls[0][1]).toMatchObject({
|
|
204
|
+
entitySchemaId: "nms:delivery",
|
|
205
|
+
schemaId: "xtk:jobInterface",
|
|
206
|
+
object: "Hello World",
|
|
207
|
+
headers: extraHttpHeaders,
|
|
208
|
+
});
|
|
209
|
+
expect(client._callMethod.mock.calls[0][2]).toEqual([ "Prepare" ]);
|
|
210
|
+
});
|
|
211
|
+
|
|
194
212
|
it("Infer schema from objects", async () => {
|
|
195
|
-
const client = { _callMethod: jest.fn() };
|
|
213
|
+
const client = { _callMethod: jest.fn(), _connectionParameters: { _options: {}} };
|
|
196
214
|
const job = new XtkJobInterface(client, { object: { xtkschema: "nms:delivery", name: "Hello World" }, method: "Prepare" });
|
|
197
215
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
198
216
|
const jobId = await job.execute();
|
|
@@ -238,7 +256,7 @@ describe('XRK Jobs', function () {
|
|
|
238
256
|
|
|
239
257
|
describe("Submit", () => {
|
|
240
258
|
it("Submit with success", async () => {
|
|
241
|
-
const client = { _callMethod: jest.fn() };
|
|
259
|
+
const client = { _callMethod: jest.fn(), _connectionParameters: { _options: {}} };
|
|
242
260
|
const job = new XtkJobInterface(client, { xtkschema: "nms:delivery", object: "Hello World", method: "Prepare" });
|
|
243
261
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
244
262
|
const jobId = await job.submit();
|
|
@@ -253,8 +271,26 @@ describe('XRK Jobs', function () {
|
|
|
253
271
|
expect(client._callMethod.mock.calls[0][2]).toEqual([ "Prepare" ]);
|
|
254
272
|
});
|
|
255
273
|
|
|
274
|
+
it("Submit should pass extraHttpHeaders in headers", async () => {
|
|
275
|
+
const extraHttpHeaders = {'x-api-key': 'check'};
|
|
276
|
+
const client = { _callMethod: jest.fn(), _connectionParameters: { _options: { extraHttpHeaders }} };
|
|
277
|
+
const job = new XtkJobInterface(client, { xtkschema: "nms:delivery", object: "Hello World", method: "Prepare" });
|
|
278
|
+
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
279
|
+
const jobId = await job.submit();
|
|
280
|
+
expect(jobId).toBe("9876");
|
|
281
|
+
expect(client._callMethod.mock.calls.length).toBe(1);
|
|
282
|
+
expect(client._callMethod.mock.calls[0][0]).toBe("Submit");
|
|
283
|
+
expect(client._callMethod.mock.calls[0][1]).toMatchObject({
|
|
284
|
+
entitySchemaId: "nms:delivery",
|
|
285
|
+
schemaId: "xtk:jobInterface",
|
|
286
|
+
object: "Hello World",
|
|
287
|
+
headers: extraHttpHeaders,
|
|
288
|
+
});
|
|
289
|
+
expect(client._callMethod.mock.calls[0][2]).toEqual([ "Prepare" ]);
|
|
290
|
+
});
|
|
291
|
+
|
|
256
292
|
it("Infer schema from objects", async () => {
|
|
257
|
-
const client = { _callMethod: jest.fn() };
|
|
293
|
+
const client = { _callMethod: jest.fn(), _connectionParameters: { _options: {}} };
|
|
258
294
|
const job = new XtkJobInterface(client, { object: { xtkschema: "nms:delivery", name: "Hello World" }, method: "Prepare" });
|
|
259
295
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
260
296
|
const jobId = await job.submit();
|
|
@@ -301,7 +337,7 @@ describe('XRK Jobs', function () {
|
|
|
301
337
|
|
|
302
338
|
describe("SubmitSoapCall", () => {
|
|
303
339
|
it("SubmitSoapCall with success", async () => {
|
|
304
|
-
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
|
|
340
|
+
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()}, _connectionParameters: { _options: {}} };
|
|
305
341
|
const job = new XtkJobInterface(client, { xtkschema: "nms:delivery", object: "Hello World", method: "Prepare" });
|
|
306
342
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
307
343
|
client.getSchema.mockReturnValueOnce(Promise.resolve(true));
|
|
@@ -325,8 +361,27 @@ describe('XRK Jobs', function () {
|
|
|
325
361
|
} ]);
|
|
326
362
|
});
|
|
327
363
|
|
|
364
|
+
it("SubmitSoapCall should pass extraHttpHeaders in headers", async () => {
|
|
365
|
+
const extraHttpHeaders = {'x-api-key': 'check'};
|
|
366
|
+
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()}, _connectionParameters: { _options: { extraHttpHeaders }} };
|
|
367
|
+
const job = new XtkJobInterface(client, { xtkschema: "nms:delivery", object: "Hello World", method: "Prepare" });
|
|
368
|
+
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
369
|
+
client.getSchema.mockReturnValueOnce(Promise.resolve(true));
|
|
370
|
+
client._methodCache.get.mockReturnValueOnce(DomUtil.parse("<method></method>").documentElement);
|
|
371
|
+
const jobId = await job.submitSoapCall();
|
|
372
|
+
expect(jobId).toBe("9876");
|
|
373
|
+
expect(client._callMethod.mock.calls.length).toBe(1);
|
|
374
|
+
expect(client._callMethod.mock.calls[0][0]).toBe("SubmitSoapCall");
|
|
375
|
+
expect(client._callMethod.mock.calls[0][1]).toMatchObject({
|
|
376
|
+
entitySchemaId: "nms:delivery",
|
|
377
|
+
schemaId: "xtk:jobInterface",
|
|
378
|
+
object: "Hello World",
|
|
379
|
+
headers: extraHttpHeaders,
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
|
|
328
383
|
it("SubmitSoapCall a non-persistant and static job with success", async () => {
|
|
329
|
-
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
|
|
384
|
+
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()}, _connectionParameters: { _options: {}} };
|
|
330
385
|
const jobDescription = {
|
|
331
386
|
doNotPersist: "true",
|
|
332
387
|
xtkschema: 'nms:webApp',
|
|
@@ -368,7 +423,7 @@ describe('XRK Jobs', function () {
|
|
|
368
423
|
});
|
|
369
424
|
|
|
370
425
|
it("Infer schema from objects", async () => {
|
|
371
|
-
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
|
|
426
|
+
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()}, _connectionParameters: { _options: {}} };
|
|
372
427
|
const job = new XtkJobInterface(client, { object: { xtkschema: "nms:delivery", name: "Hello World" }, method: "Prepare" });
|
|
373
428
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
374
429
|
client.getSchema.mockReturnValueOnce(Promise.resolve(true));
|
|
@@ -383,7 +438,7 @@ describe('XRK Jobs', function () {
|
|
|
383
438
|
});
|
|
384
439
|
|
|
385
440
|
it("Should fail on missing schema", async () => {
|
|
386
|
-
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
|
|
441
|
+
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()}, _connectionParameters: { _options: {}} };
|
|
387
442
|
const job = new XtkJobInterface(client, { method: "Prepare" });
|
|
388
443
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
389
444
|
client.getSchema.mockReturnValueOnce(Promise.resolve(false));
|
|
@@ -400,7 +455,7 @@ describe('XRK Jobs', function () {
|
|
|
400
455
|
});
|
|
401
456
|
|
|
402
457
|
it("Should fail on invalid schema", async () => {
|
|
403
|
-
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
|
|
458
|
+
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()}, _connectionParameters: { _options: {}} };
|
|
404
459
|
const job = new XtkJobInterface(client, { object: { xtkschema: "nms:notFound", name: "Hello World" }, method: "Prepare" });
|
|
405
460
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
406
461
|
client.getSchema.mockReturnValueOnce(Promise.resolve(false));
|
|
@@ -417,7 +472,7 @@ describe('XRK Jobs', function () {
|
|
|
417
472
|
});
|
|
418
473
|
|
|
419
474
|
it("Should fail on method not found", async () => {
|
|
420
|
-
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
|
|
475
|
+
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()}, _connectionParameters: { _options: {}} };
|
|
421
476
|
const job = new XtkJobInterface(client, { object: { xtkschema: "nms:delivery", name: "Hello World" }, method: "NotFound" });
|
|
422
477
|
client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
|
|
423
478
|
client.getSchema.mockReturnValueOnce(Promise.resolve(true));
|