@xiboplayer/xmds 0.3.1 → 0.3.3
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/package.json +2 -2
- package/src/rest-client.js +1 -1
- package/src/xmds-client.js +1 -1
- package/src/xmds.rest.test.js +34 -0
- package/src/xmds.test.js +63 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiboplayer/xmds",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "XMDS SOAP client for Xibo CMS communication",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"./xmds": "./src/xmds.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@xiboplayer/utils": "0.3.
|
|
12
|
+
"@xiboplayer/utils": "0.3.3"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"vitest": "^2.0.0"
|
package/src/rest-client.js
CHANGED
|
@@ -148,7 +148,7 @@ export class RestClient {
|
|
|
148
148
|
operatingSystem: os,
|
|
149
149
|
macAddress: this.config.macAddress || 'n/a',
|
|
150
150
|
xmrChannel: this.config.xmrChannel,
|
|
151
|
-
xmrPubKey: '',
|
|
151
|
+
xmrPubKey: this.config.xmrPubKey || '',
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
return this._parseRegisterDisplayJson(json);
|
package/src/xmds-client.js
CHANGED
|
@@ -155,7 +155,7 @@ export class XmdsClient {
|
|
|
155
155
|
operatingSystem: os,
|
|
156
156
|
macAddress: this.config.macAddress || 'n/a',
|
|
157
157
|
xmrChannel: this.config.xmrChannel,
|
|
158
|
-
xmrPubKey: ''
|
|
158
|
+
xmrPubKey: this.config.xmrPubKey || ''
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
return this.parseRegisterDisplayResponse(xml);
|
package/src/xmds.rest.test.js
CHANGED
|
@@ -237,6 +237,40 @@ describe('RestClient - RegisterDisplay', () => {
|
|
|
237
237
|
global.fetch = mockFetch;
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
+
it('should include xmrPubKey from config in POST body', async () => {
|
|
241
|
+
const clientWithKey = createRestClient({
|
|
242
|
+
xmrPubKey: '-----BEGIN PUBLIC KEY-----\nTEST\n-----END PUBLIC KEY-----',
|
|
243
|
+
});
|
|
244
|
+
const mockFetchLocal = vi.fn();
|
|
245
|
+
global.fetch = mockFetchLocal;
|
|
246
|
+
|
|
247
|
+
mockFetchLocal.mockResolvedValue(jsonResponse({
|
|
248
|
+
display: {
|
|
249
|
+
'@attributes': { code: 'READY', message: 'OK' },
|
|
250
|
+
collectInterval: '60',
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
|
|
254
|
+
await clientWithKey.registerDisplay();
|
|
255
|
+
|
|
256
|
+
const body = JSON.parse(mockFetchLocal.mock.calls[0][1].body);
|
|
257
|
+
expect(body.xmrPubKey).toBe('-----BEGIN PUBLIC KEY-----\nTEST\n-----END PUBLIC KEY-----');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('should send empty xmrPubKey when config has no key', async () => {
|
|
261
|
+
mockFetch.mockResolvedValue(jsonResponse({
|
|
262
|
+
display: {
|
|
263
|
+
'@attributes': { code: 'READY', message: 'OK' },
|
|
264
|
+
collectInterval: '60',
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
await client.registerDisplay();
|
|
269
|
+
|
|
270
|
+
const body = JSON.parse(mockFetch.mock.calls[0][1].body);
|
|
271
|
+
expect(body.xmrPubKey).toBe('');
|
|
272
|
+
});
|
|
273
|
+
|
|
240
274
|
it('should POST to /register and parse READY response', async () => {
|
|
241
275
|
mockFetch.mockResolvedValue(jsonResponse({
|
|
242
276
|
display: {
|
package/src/xmds.test.js
CHANGED
|
@@ -7,6 +7,69 @@
|
|
|
7
7
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
8
8
|
import { XmdsClient } from './xmds-client.js';
|
|
9
9
|
|
|
10
|
+
describe('XmdsClient - RegisterDisplay', () => {
|
|
11
|
+
let client;
|
|
12
|
+
let mockFetch;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
client = new XmdsClient({
|
|
16
|
+
cmsAddress: 'https://cms.example.com',
|
|
17
|
+
cmsKey: 'test-server-key',
|
|
18
|
+
hardwareKey: 'test-hardware-key',
|
|
19
|
+
displayName: 'Test Display',
|
|
20
|
+
xmrChannel: 'test-xmr-channel',
|
|
21
|
+
xmrPubKey: '-----BEGIN PUBLIC KEY-----\nTEST\n-----END PUBLIC KEY-----',
|
|
22
|
+
retryOptions: { maxRetries: 0 }
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
mockFetch = vi.fn();
|
|
26
|
+
global.fetch = mockFetch;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should include xmrPubKey from config in SOAP envelope', () => {
|
|
30
|
+
const envelope = client.buildEnvelope('RegisterDisplay', {
|
|
31
|
+
serverKey: 'test-server-key',
|
|
32
|
+
hardwareKey: 'test-hardware-key',
|
|
33
|
+
displayName: 'Test Display',
|
|
34
|
+
clientType: 'chromeOS',
|
|
35
|
+
clientVersion: '0.1.0',
|
|
36
|
+
clientCode: '1',
|
|
37
|
+
operatingSystem: 'test',
|
|
38
|
+
macAddress: 'n/a',
|
|
39
|
+
xmrChannel: 'test-xmr-channel',
|
|
40
|
+
xmrPubKey: client.config.xmrPubKey || ''
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(envelope).toContain('<xmrPubKey xsi:type="xsd:string">-----BEGIN PUBLIC KEY-----');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should send empty xmrPubKey when config has no key', () => {
|
|
47
|
+
const clientNoKey = new XmdsClient({
|
|
48
|
+
cmsAddress: 'https://cms.example.com',
|
|
49
|
+
cmsKey: 'test-server-key',
|
|
50
|
+
hardwareKey: 'test-hardware-key',
|
|
51
|
+
displayName: 'Test Display',
|
|
52
|
+
xmrChannel: 'test-xmr-channel',
|
|
53
|
+
retryOptions: { maxRetries: 0 }
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const envelope = clientNoKey.buildEnvelope('RegisterDisplay', {
|
|
57
|
+
serverKey: 'test-server-key',
|
|
58
|
+
hardwareKey: 'test-hardware-key',
|
|
59
|
+
displayName: 'Test Display',
|
|
60
|
+
clientType: 'chromeOS',
|
|
61
|
+
clientVersion: '0.1.0',
|
|
62
|
+
clientCode: '1',
|
|
63
|
+
operatingSystem: 'test',
|
|
64
|
+
macAddress: 'n/a',
|
|
65
|
+
xmrChannel: 'test-xmr-channel',
|
|
66
|
+
xmrPubKey: clientNoKey.config.xmrPubKey || ''
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(envelope).toContain('<xmrPubKey xsi:type="xsd:string"></xmrPubKey>');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
10
73
|
describe('XmdsClient - SubmitLog', () => {
|
|
11
74
|
let client;
|
|
12
75
|
let mockFetch;
|