• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

suculent / thinx-device-api / #252646960

14 Mar 2026 04:35PM UTC coverage: 52.052% (-10.0%) from 62.077%
#252646960

push

suculent
Revert test bootstrap experiments to baseline

1399 of 3653 branches covered (38.3%)

Branch coverage included in aggregate %.

27 of 40 new or added lines in 3 files covered. (67.5%)

1153 existing lines in 32 files now uncovered.

5996 of 10554 relevant lines covered (56.81%)

10.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.06
/spec/jasmine/ZZ-RouterDeviceSpec.js
1
/* Router integration test only; does not have to cover full unit functionality. */
2

3
const THiNX = require("../../thinx-core.js");
1✔
4

5
let chai = require('chai');
1✔
6
var expect = require('chai').expect;
1✔
7
let chaiHttp = require('chai-http');
1✔
8
var envi = require("../_envi.json");
1✔
9
chai.use(chaiHttp);
1✔
10

11
let thx;
12

13
describe("Router Devices", function () {
1✔
14

15
  beforeAll((done) => {
1✔
16
    console.log(`🚸 [chai] >>> running Devices spec`);
1✔
17
    thx = new THiNX();
1✔
18
    thx.init(() => {
1✔
19
      done();
×
20
    });
21
  });
22

23
  afterAll(() => {
1✔
24
    console.log(`🚸 [chai] <<< completed Devices spec`);
1✔
25
  });
26

27
  it("GET /api/user/devices (noauth)", function (done) {
1✔
28
    console.log("🚸 [chai] GET /api/user/devices (noauth)");
×
29
    chai.request(thx.app)
×
30
      .get('/api/user/devices')
31
      .end((err, res) => {
32
        expect(res.status).to.equal(401);
×
33
        done();
×
34
      });
35
  }, 30000);
36

37
  it("GET /api/user/devices (cookie)", function (done) {
1✔
38
    console.log("🚸 [chai] GET /api/user/devices (cookie)");
×
39
    chai.request(thx.app)
×
40
      .get('/api/user/devices')
41
      .set('Cookie', 'thx-session-cookie=something;owner=' + envi.oid)
42
      .end((err, res) => {
43
        expect(res.status).to.equal(401);
×
44
        done();
×
45
      });
46
  }, 30000);
47

48
  it("GET /api/user/device/data/:udid" + envi.oid, function (done) {
1✔
49
    console.log("🚸 [chai] GET /api/user/device/data/:udid");
×
50
    chai.request(thx.app)
×
51
      .get('/api/user/device/data/' + envi.oid)
52
      .end((err, res) => {
53
        expect(res.status).to.equal(404);
×
54
        done();
×
55
      });
56
  }, 30000);
57

58
  it("Router POST /api/device/edit (alias)", function (done) {
1✔
59
    console.log("🚸 [chai] POST /api/device/edit");
×
60
    chai.request(thx.app)
×
61
      .post('/api/device/edit')
62
      .send({ changes: { alias: "edited-alias" } })
63
      .end((err, res) => {
64
        expect(res.status).to.equal(401);
×
65
        done();
×
66
      });
67
  }, 30000);
68

69
  it("POST /api/device/attach (noauth, invalid)", function (done) {
1✔
70
    console.log("🚸 [chai] POST /api/device/attach (invalid)");
×
71
    chai.request(thx.app)
×
72
      .post('/api/device/attach')
73
      .send({ udid: envi.oid })
74
      .end((err, res) => {
75
        expect(res.status).to.equal(401);
×
76
        done();
×
77
      });
78
  }, 30000);
79

80
  it("POST /api/device/detach", function (done) {
1✔
81
    console.log("🚸 [chai] POST /api/device/detach (invalid)");
×
82
    chai.request(thx.app)
×
83
      .post('/api/device/detach')
84
      .send({ udid: envi.oid })
85
      .end((err, res) => {
86
        expect(res.status).to.equal(401);
×
87
        done();
×
88
      });
89
  }, 30000);
90

91
  it("POST /api/device/mesh/attach", function (done) {
1✔
92
    console.log("🚸 [chai] POST /api/device/mesh/attach");
×
93
    chai.request(thx.app)
×
94
      .post('/api/device/mesh/attach')
95
      .send({ udid: envi.udid })
96
      .end((err, res) => {
97
        if (err) console.log("🚸 [chai] ERR", err);
×
98
        expect(res.status).to.equal(401);
×
99
        done();
×
100
      });
101
  }, 30000);
102

103
  // POST /api/device/mesh/detach
104
  it("POST /api/device/mesh/detach", function (done) {
1✔
105
    console.log("🚸 [chai] POST /api/device/mesh/detach");
×
106
    chai.request(thx.app)
×
107
      .post('/api/device/mesh/detach')
108
      .send({ udid: envi.udid })
109
      .end((err, res) => {
110
        if (err) console.log("🚸 [chai] ERR", err);
×
111
        expect(res.status).to.equal(401);
×
112
        done();
×
113
      });
114
  }, 30000);
115

116
  it("POST /api/device/data", function (done) {
1✔
117
    console.log("🚸 [chai] POST /api/device/data");
×
118
    chai.request(thx.app)
×
119
      .post('/api/device/data')
120
      .send({ udid: envi.oid })
121
      .end((err, res) => {
122
        console.log("🚸 [chai] response /api/device/data:", res.text, " status:", res.status);
×
123
        expect(res.status).to.equal(401);
×
124
        done();
×
125
      });
126
  }, 30000);
127

128
  it("POST /api/device/revoke", function (done) {
1✔
129
    console.log("🚸 [chai] POST /api/device/revoke");
×
130
    chai.request(thx.app)
×
131
      .post('/api/device/revoke')
132
      .send({ udid: envi.oid })
133
      .end((err, res) => {
134
        expect(res.status).to.equal(401);
×
135
        done();
×
136
      });
137
  }, 30000);
138

139
  //
140
  // Device Configuration
141
  //
142

143
  // push device configuration over MQTT
144
  it("POST /api/device/push", function (done) {
1✔
145
    console.log("🚸 [chai] POST /api/device/push");
×
146
    chai.request(thx.app)
×
147
      .post('/api/device/push')
148
      .send({ key: "value" })
149
      .end((err, res) => {
150
        expect(res.status).to.equal(401);
×
151
        done();
×
152
      });
153
  }, 30000);
154
});
155

156
describe("Devices (JWT)", function () {
1✔
157

158
  let agent;
159
  let jwt;
160

161
  var JRS5 = {
1✔
162
    mac: "55:55:55:55:55:55",
163
    firmware: "ZZ-RouterDeviceSpec.js",
164
    version: "1.0.0",
165
    alias: "test-device-5-dynamic",
166
    owner: envi.dynamic.owner,
167
    platform: "arduino"
168
  };
169

170
  let created_api_key = null;
1✔
171

172
  beforeAll((done) => {
1✔
173
    console.log(`🚸 [chai] >>> running Devices (JWT) spec`);
1✔
174
    agent = chai.request.agent(thx.app);
1✔
175
    agent
1✔
176
      .post('/api/login')
177
      .send({ username: 'dynamic', password: 'dynamic', remember: false })
178
      .then(function (res) {
179
        console.log(`🚸 [chai] DeviceSpec (JWT) beforeAll POST /api/login (valid) response: ${JSON.stringify(res)}`);
1✔
180
        expect(res).to.have.cookie('x-thx-core');
1✔
UNCOV
181
        let body = JSON.parse(res.text);
×
UNCOV
182
        jwt = 'Bearer ' + body.access_token;
×
UNCOV
183
        done();
×
184
      })
185
      .catch((e) => { console.log(e); });
1✔
186
  });
187

188
  afterAll(() => {
1✔
189
    console.log(`🚸 [chai] <<< completed Devices (JWT) spec`);
1✔
190
    agent.close();
1✔
191
    if (thx && thx.server) thx.server.close();
1!
192
  });
193

194
  it("POST /api/user/apikey (D)", function (done) {
1✔
UNCOV
195
    chai.request(thx.app)
×
196
      .post('/api/user/apikey')
197
      .set('Authorization', jwt)
198
      .send({
199
        'alias': 'device-apikey-alias'
200
      })
201
      .end((err, res) => {
202
        //  {"success":true,"api_key":"9b7bd4f4eacf63d8453b32dbe982eea1fb8bbc4fc8e3bcccf2fc998f96138629","hash":"0a920b2e99a917a04d7961a28b49d05524d10cd8bdc2356c026cfc1c280ca22c"}
UNCOV
203
        expect(res.status).to.equal(200);
×
UNCOV
204
        let j = JSON.parse(res.text);
×
UNCOV
205
        expect(j.success).to.equal(true);
×
UNCOV
206
        expect(j.response.api_key).to.be.a('string');
×
UNCOV
207
        expect(j.response.hash).to.be.a('string');
×
UNCOV
208
        created_api_key = j.response.hash;
×
UNCOV
209
        console.log("[spec] saving apikey (D)", j.response.api_key);
×
UNCOV
210
        done();
×
211
      });
212
  }, 30000);
213

214
  it("POST /device/register (jwt, valid) D", function (done) {
1✔
215

UNCOV
216
    chai.request(thx.app)
×
217
      .post('/device/register')
218
      .set('Authentication', created_api_key)
219
      .send({ registration: JRS5 })
220
      .end((err, res) => {
UNCOV
221
        console.log("🚸 [chai] POST /device/register (jwt, valid) D response:", res.text);
×
UNCOV
222
        expect(res.status).to.equal(200);
×
UNCOV
223
        let r = JSON.parse(res.text);
×
UNCOV
224
        console.log("🚸 [chai] POST /device/register (jwt, valid) D response:", JSON.stringify(r));
×
UNCOV
225
        JRS5.udid = r.registration.udid;
×
UNCOV
226
        expect(res.text).to.be.a('string');
×
UNCOV
227
        done();
×
228
      });
229
  }, 30000);
230

231
  let dynamic_devices = [];
1✔
232

233
  it("GET /api/user/devices (JWT)", function (done) {
1✔
UNCOV
234
    console.log("🚸 [chai] GET /api/user/devices (JWT)");
×
UNCOV
235
    agent
×
236
      .get('/api/user/devices')
237
      .set('Authorization', jwt)
238
      .end((err, res) => {
UNCOV
239
        console.log("🚸 [chai] GET /api/user/devices (JWT) response:", res.text, " status:", res.status);
×
UNCOV
240
        let j = JSON.parse(res.text);
×
UNCOV
241
        dynamic_devices = j.response;
×
UNCOV
242
        expect(res.status).to.equal(200);
×
UNCOV
243
        expect(res.text).to.be.a('string');
×
UNCOV
244
        done();
×
245
      });
246
  }, 30000);
247

248
  it("GET /api/user/device/data/:udid" + envi.oid, function (done) {
1✔
UNCOV
249
    console.log("🚸 [chai] GET /api/user/device/data/:udid");
×
UNCOV
250
    agent
×
251
      .get('/api/user/device/data/' + envi.oid)
252
      .set('Authorization', jwt)
253
      .end((err, res) => {
UNCOV
254
        expect(res.status).to.equal(404);
×
255
        //expect(res.text).to.be.a('string');
UNCOV
256
        done();
×
257
      });
258
  }, 30000);
259

260
  it("Router POST /api/device/edit (JWT)", function (done) {
1✔
UNCOV
261
    console.log("🚸 [chai] POST /api/device/edit (JWT)");
×
UNCOV
262
    agent
×
263
      .post('/api/device/edit')
264
      .set('Authorization', jwt)
265
      .send({ changes: { alias: "edited-alias", udid: dynamic_devices[1].udid } })
266
      .end((err, res) => {
UNCOV
267
        console.log("🚸 [chai] POST /api/device/edit (JWT)response:", res.text, " status:", res.status);
×
268
        //expect(res.status).to.equal(200);
269
        //expect(res.text).to.be.a('string');
UNCOV
270
        done();
×
271
      });
272
  }, 30000);
273

274
  it("POST /api/device/attach (jwt, dynamic udid)", function (done) {
1✔
UNCOV
275
    console.log("🚸 [chai] POST /api/device/attach (JWT)");
×
UNCOV
276
    agent
×
277
      .post('/api/device/attach')
278
      .set('Authorization', jwt)
279
      .send({ udid: dynamic_devices[1].udid })
280
      .end((err, res) => {
UNCOV
281
        console.log("🚸 [chai] POST /api/device/attach (JWT) response:", res.text, " status:", res.status);
×
282
        //expect(res.status).to.equal(200);
283
        //expect(res.text).to.be.a('string');
UNCOV
284
        done();
×
285
      });
286
  }, 30000);
287

288
  it("POST /api/device/attach (jwt, registered udid)", function (done) {
1✔
UNCOV
289
    console.log("🚸 [chai] POST /api/device/attach (JWT) 2");
×
UNCOV
290
    agent
×
291
      .post('/api/device/attach')
292
      .set('Authorization', jwt)
293
      .send({ udid: JRS5.udid })
294
      .end((err, res) => {
UNCOV
295
        console.log("🚸 [chai] POST /api/device/attach (JWT) 2 response:", res.text, " status:", res.status);
×
296
        //expect(res.status).to.equal(200);
297
        //expect(res.text).to.be.a('string');
UNCOV
298
        done();
×
299
      });
300
  }, 30000);
301

302
  it("POST /api/device/detach (jwt, dynamic udid)", function (done) {
1✔
UNCOV
303
    console.log("🚸 [chai] POST /api/device/detach  (JWT)");
×
UNCOV
304
    agent
×
305
      .post('/api/device/detach')
306
      .set('Authorization', jwt)
307
      .send({ udid: dynamic_devices[1].udid })
308
      .end((err, res) => {
UNCOV
309
        console.log("🚸 [chai] POST /api/device/detach  (JWT) response:", res.text, " status:", res.status);
×
310
        //expect(res.status).to.equal(200);
311
        //expect(res.text).to.be.a('string');
UNCOV
312
        done();
×
313
      });
314
  }, 30000);
315

316
  it("POST /api/device/detach (jwt, registered udid)", function (done) {
1✔
UNCOV
317
    console.log("🚸 [chai] POST /api/device/detach  (JWT) 2");
×
UNCOV
318
    agent
×
319
      .post('/api/device/detach')
320
      .set('Authorization', jwt)
321
      .send({ udid: JRS5.udid })
322
      .end((_err, res) => {
UNCOV
323
        expect(res.status).to.equal(200);
×
UNCOV
324
        expect(res.text).to.be.a('string');
×
UNCOV
325
        expect(res.text).to.equal('{"success":true,"response":"detached"}');
×
UNCOV
326
        done();
×
327
      });
328
  }, 30000);
329

330
  let mesh_id;
331

332
  it("POST /api/mesh/create (jwt, valid)", (done) => {
1✔
UNCOV
333
    agent
×
334
      .post('/api/mesh/create')
335
      .set('Authorization', jwt)
336
      .send({ alias: "device-mesh-alias", owner_id: envi.dynamic.owner, mesh_id: 'device-mesh-id' })
337
      .end((_err, res) => {
UNCOV
338
        let r = JSON.parse(res.text);
×
UNCOV
339
        mesh_id = r.mesh_id;
×
UNCOV
340
        expect(res.status).to.equal(200);
×
UNCOV
341
        expect(res.text).to.be.a('string');
×
UNCOV
342
        expect(res.text).to.equal('{"success":true,"response":{"mesh_id":"device-mesh-id","alias":"device-mesh-alias"}}');
×
UNCOV
343
        done();
×
344
      });
345
  }, 30000);
346

347
  it("POST /api/device/mesh/attach (jwt, fixed mesh id)", function (done) {
1✔
UNCOV
348
    console.log("🚸 [chai] POST /api/device/mesh/attach (JWT)");
×
UNCOV
349
    agent
×
350
      .post('/api/device/mesh/attach')
351
      .set('Authorization', jwt)
352
      .send({ udid: envi.dynamic.udid, mesh_id: "device-mesh-id" })
353
      .end((err, res) => {
UNCOV
354
        console.log("🚸 [chai] POST /api/device/mesh/attach (JWT) response:", res.text, " status:", res.status);
×
355
        //expect(res.status).to.equal(200);
356
        //expect(res.text).to.be.a('string');
UNCOV
357
        done();
×
358
      });
359
  }, 30000);
360

361
  it("POST /api/device/mesh/attach (jwt, JRS5 udid)", function (done) {
1✔
UNCOV
362
    console.log("🚸 [chai] POST /api/device/mesh/attach (JWT) 2");
×
UNCOV
363
    agent
×
364
      .post('/api/device/mesh/attach')
365
      .set('Authorization', jwt)
366
      .send({ udid: JRS5.udid, mesh_id: mesh_id })
367
      .end((err, res) => {
UNCOV
368
        console.log("🚸 [chai] POST /api/device/mesh/attach (JWT) 2 response:", res.text, " status:", res.status);
×
369
        //expect(res.status).to.equal(200);
370
        //expect(res.text).to.be.a('string');
UNCOV
371
        done();
×
372
      });
373
  }, 30000);
374

375
  it("POST /api/device/mesh/attach (jwt, missing udid)", function (done) {
1✔
UNCOV
376
    console.log("🚸 [chai] POST /api/device/mesh/attach (JWT) 3");
×
UNCOV
377
    agent
×
378
      .post('/api/device/mesh/attach')
379
      .set('Authorization', jwt)
380
      .send({ mesh_id: mesh_id })
381
      .end((err, res) => {
UNCOV
382
        console.log("🚸 [chai] POST /api/device/mesh/attach (JWT) 3 response:", res.text, " status:", res.status);
×
383
        //expect(res.status).to.equal(200);
384
        //expect(res.text).to.be.a('string');
UNCOV
385
        done();
×
386
      });
387
  }, 30000);
388

389
  it("POST /api/device/mesh/attach (jwt, dynamic udid)", function (done) {
1✔
UNCOV
390
    console.log("🚸 [chai] POST /api/device/mesh/attach (JWT) 4");
×
UNCOV
391
    agent
×
392
      .post('/api/device/mesh/attach')
393
      .set('Authorization', jwt)
394
      .send({ udid: envi.dynamic.udid, mesh_id: mesh_id })
395
      .end((err, res) => {
UNCOV
396
        console.log("🚸 [chai] POST /api/device/mesh/attach (JWT) 4 response:", res.text, " status:", res.status);
×
397
        //expect(res.status).to.equal(200);
398
        //expect(res.text).to.be.a('string');
UNCOV
399
        done();
×
400
      });
401
  }, 30000);
402

403
  it("POST /api/device/mesh/detach (missing udid)", function (done) {
1✔
UNCOV
404
    console.log("🚸 [chai] POST /api/device/mesh/detach (noudid)");
×
UNCOV
405
    chai.request(thx.app)
×
406
      .post('/api/device/mesh/detach')
407
      .send({ mesh_id: mesh_id })
408
      .end((err, res) => {
UNCOV
409
        console.log("🚸 [chai] POST /api/device/mesh/detach (noudid) response:", res.text, " status:", res.status);
×
410
        //expect(res.status).to.equal(200);
411
        //expect(res.text).to.be.a('string');
UNCOV
412
        done();
×
413
      });
414
  }, 30000);
415

416
  // POST /api/device/mesh/detach
417
  it("POST /api/device/mesh/detach (jwt, dynamic udid)", function (done) {
1✔
UNCOV
418
    console.log("🚸 [chai] POST /api/device/mesh/detach (JWT)");
×
UNCOV
419
    agent
×
420
      .post('/api/device/mesh/detach')
421
      .set('Authorization', jwt)
422
      .send({ udid: envi.dynamic.udid, mesh_id: "device-mesh-id" })
423
      .end((err, res) => {
UNCOV
424
        console.log("🚸 [chai] POST /api/device/mesh/detach (JWT) response:", res.text, " status:", res.status);
×
425
        //expect(res.status).to.equal(200);
426
        //expect(res.text).to.be.a('string');
UNCOV
427
        done();
×
428
      });
429
  }, 30000);
430

431
  it("POST /api/device/mesh/detach (jwt, JRS5 udid)", function (done) {
1✔
UNCOV
432
    console.log("🚸 [chai] POST /api/device/mesh/detach (JWT) 2");
×
UNCOV
433
    agent
×
434
      .post('/api/device/mesh/detach')
435
      .set('Authorization', jwt)
436
      .send({ udid: JRS5.udid, mesh_id: "device-mesh-id" })
437
      .end((err, res) => {
UNCOV
438
        console.log("🚸 [chai] POST /api/device/mesh/detach (JWT) 2 response:", res.text, " status:", res.status);
×
439
        //expect(res.status).to.equal(200);
440
        //expect(res.text).to.be.a('string');
UNCOV
441
        done();
×
442
      });
443
  }, 30000);
444

445
  it("POST /api/device/data (jwt, owner lookup)", function (done) {
1✔
UNCOV
446
    console.log("🚸 [chai] POST /api/device/data (JWT)");
×
UNCOV
447
    agent
×
448
      .post('/api/device/data')
449
      .set('Authorization', jwt)
450
      .send({ udid: envi.oid })
451
      .end((err, res) => {
UNCOV
452
        console.log("🚸 [chai] response /api/device/data (JWT):", res.text, " status:", res.status);
×
453
        //expect(res.status).to.equal(200);
454
        //expect(res.text).to.be.a('string');
UNCOV
455
        done();
×
456
      });
457
  }, 30000);
458

459
  it("POST /api/device/data (jwt, JRS5 udid)", function (done) {
1✔
UNCOV
460
    console.log("🚸 [chai] POST /api/device/data (JWT) 2");
×
UNCOV
461
    agent
×
462
      .post('/api/device/data')
463
      .set('Authorization', jwt)
464
      .send({ udid: JRS5.udid })
465
      .end((err, res) => {
UNCOV
466
        console.log("🚸 [chai] response /api/device/data (JWT) 2:", res.text, " status:", res.status);
×
467
        //expect(res.status).to.equal(200);
468
        //expect(res.text).to.be.a('string');
UNCOV
469
        done();
×
470
      });
471
  }, 30000);
472

473
  it("POST /api/device/revoke (jwt, owner lookup)", function (done) {
1✔
UNCOV
474
    console.log("🚸 [chai] POST /api/device/revoke (JWT)");
×
UNCOV
475
    agent
×
476
      .post('/api/device/revoke')
477
      .set('Authorization', jwt)
478
      .send({ udid: envi.oid })
479
      .end((err, res) => {
UNCOV
480
        console.log("🚸 [chai] POST /api/device/revoke (JWT) response:", res.text, " status:", res.status);
×
481
        //expect(res.status).to.equal(200);
482
        //expect(res.text).to.be.a('string');
UNCOV
483
        done();
×
484
      });
485
  }, 30000);
486

487
  //
488
  // Device Configuration
489
  //
490

491
  // push device configuration over MQTT
492
  it("POST /api/device/push (jwt, missing target)", function (done) {
1✔
UNCOV
493
    console.log("🚸 [chai] POST /api/device/push (JWT+udid)");
×
UNCOV
494
    agent
×
495
      .post('/api/device/push')
496
      .set('Authorization', jwt)
497
      .send({ key: "value" })
498
      .end((err, res) => {
UNCOV
499
        console.log("🚸 [chai] POST /api/device/push (JWT+udid) response:", res.text, " status:", res.status);
×
500
        // no messenger, will fail here...
501
        //expect(res.status).to.equal(200);
502
        //expect(res.text).to.be.a('string');
UNCOV
503
        done();
×
504
      });
505
  }, 30000);
506

507
  it("POST /api/device/push (jwt, single udid)", function (done) {
1✔
UNCOV
508
    console.log("🚸 [chai] POST /api/device/push (JWT+udid)");
×
UNCOV
509
    agent
×
510
      .post('/api/device/push')
511
      .set('Authorization', jwt)
512
      .send({ udid: JRS5.udid, key: "value" })
513
      .end((err, res) => {
UNCOV
514
        console.log("🚸 [chai] POST /api/device/push (JWT) response:", res.text, " status:", res.status);
×
515
        // no messenger, will fail here...
516
        //expect(res.status).to.equal(200);
517
        //expect(res.text).to.be.a('string');
UNCOV
518
        done();
×
519
      });
520
  }, 30000);
521

522
  it("POST /api/device/push (jwt, udids array)", function (done) {
1✔
UNCOV
523
    console.log("🚸 [chai] POST /api/device/push (JWT+udid)");
×
UNCOV
524
    agent
×
525
      .post('/api/device/push')
526
      .set('Authorization', jwt)
527
      .send({ udids: [JRS5.udid], key: "value" })
528
      .end((err, res) => {
UNCOV
529
        console.log("🚸 [chai] POST /api/device/push (JWT) response:", res.text, " status:", res.status);
×
530
        // no messenger, will fail here...
531
        //expect(res.status).to.equal(200);
532
        //expect(res.text).to.be.a('string');
UNCOV
533
        done();
×
534
      });
535
  }, 30000);
536

537
  it("POST /api/device/revoke (jwt, JRS5 udid)", function (done) {
1✔
UNCOV
538
    console.log("🚸 [chai] POST /api/device/revoke (JWT) 2");
×
UNCOV
539
    agent
×
540
      .post('/api/device/revoke')
541
      .set('Authorization', jwt)
542
      .send({ udid: JRS5.udid })
543
      .end((err, res) => {
UNCOV
544
        console.log("🚸 [chai] POST /api/device/revoke (JWT) 2 response:", res.text, " status:", res.status);
×
545
        //expect(res.status).to.equal(200);
546
        //expect(res.text).to.be.a('string');
UNCOV
547
        done();
×
548
      });
549
  }, 30000);
550

551
  //
552
  // API v2 specs for device.router.js
553
  //
554

555
  // GET /api/v2/device
556
  it("GET /api/v2/device (JWT)", function (done) {
1✔
UNCOV
557
    console.log("🚸 [chai] GET /api/v2/device (JWT)");
×
UNCOV
558
    agent
×
559
      .get('/api/v2/device')
560
      .set('Authorization', jwt)
561
      .end((err, res) => {
UNCOV
562
        console.log("🚸 [chai] GET /api/v2/device (JWT) response 1:", res.text, " status:", res.status);
×
UNCOV
563
        expect(res.status).to.equal(200);
×
UNCOV
564
        expect(res.text).to.be.a('string');
×
UNCOV
565
        done();
×
566
      });
567
  }, 30000);
568

569
  // PUT /api/v2/device
570
  it("PUT /api/v2/device (JWT)", function (done) {
1✔
UNCOV
571
    console.log("🚸 [chai] PUT /api/v2/device (JWT)");
×
UNCOV
572
    agent
×
573
      .put('/api/v2/device')
574
      .set('Authorization', jwt)
575
      .send({ changes: { alias: "changed" }})
576
      .end((err, res) => {
UNCOV
577
        console.log("🚸 [chai] PUT /api/v2/device (JWT) response 2:", res.text, " status:", res.status);
×
UNCOV
578
        expect(res.status).to.equal(200);
×
UNCOV
579
        expect(res.text).to.be.a('string');
×
UNCOV
580
        done();
×
581
      });
582
  }, 30000);
583

584
  // PUT /api/v2/source/attach
585
  it("PUT /api/v2/source/attach", function (done) {
1✔
UNCOV
586
    console.log("🚸 [chai] PUT /api/v2/source/attach (JWT)");
×
UNCOV
587
    agent
×
588
      .put('/api/v2/source/attach')
589
      .set('Authorization', jwt)
590
      .send({ udid: JRS5.udid })
591
      .end((err, res) => {
UNCOV
592
        console.log("🚸 [chai] PUT /api/v2/source/attach response:", res.text, " status:", res.status);
×
593
        //expect(res.status).to.equal(200);
594
        //expect(res.text).to.be.a('string');
UNCOV
595
        done();
×
596
      });
597
  }, 30000);
598
  
599
  // PUT /api/v2/source/detach
600
  it("PUT /api/v2/source/detach", function (done) {
1✔
UNCOV
601
    console.log("🚸 [chai] PUT /api/v2/source/detach (JWT)");
×
UNCOV
602
    agent
×
603
      .put('/api/v2/source/detach')
604
      .set('Authorization', jwt)
605
      .send({ udid: envi.oid })
606
      .end((err, res) => {
UNCOV
607
        console.log("🚸 [chai] PUT /api/v2/source/detach (JWT) response:", res.text, " status:", res.status);
×
608
        //expect(res.status).to.equal(200);
609
        //expect(res.text).to.be.a('string');
UNCOV
610
        done();
×
611
      });
612
  }, 30000);
613

614
  // PUT /api/v2/mesh/attach
615
  it("PUT /api/v2/mesh/attach", function (done) {
1✔
UNCOV
616
    console.log("🚸 [chai] PUT /api/v2/mesh/attach");
×
UNCOV
617
    agent
×
618
      .put('/api/v2/mesh/attach')
619
      .set('Authorization', jwt)
620
      .send({ udid: envi.dynamic.udid, mesh_id: mesh_id })
621
      .end((err, res) => {
UNCOV
622
        console.log("🚸 [chai] PUT /api/v2/mesh/attach response:", res.text, " status:", res.status);
×
623
        //expect(res.status).to.equal(200);
624
        //expect(res.text).to.be.a('string');
UNCOV
625
        done();
×
626
      });
627
  }, 30000);
628

629
  // PUT /api/v2/mesh/detach
630
  it("PUT /api/v2/mesh/detach", function (done) {
1✔
UNCOV
631
    console.log("🚸 [chai] PUT /api/v2/mesh/detach");
×
UNCOV
632
    agent
×
633
      .put('/api/v2/mesh/detach')
634
      .set('Authorization', jwt)
635
      .send({ udid: envi.dynamic.udid, mesh_id: "device-mesh-id" })
636
      .end((err, res) => {
UNCOV
637
        console.log("🚸 [chai] PUT /api/v2/mesh/detach response:", res.text, " status:", res.status);
×
638
        //expect(res.status).to.equal(200);
639
        //expect(res.text).to.be.a('string');
UNCOV
640
        done();
×
641
      });
642
  }, 30000);
643

644
  // DELETE /api/v2/device
645
  it("DELETE /api/v2/device (jwt, invalid)", function (done) {
1✔
UNCOV
646
    console.log("🚸 [chai] DELETE /api/v2/device (JWT, invalid)");
×
UNCOV
647
    agent
×
648
      .delete('/api/v2/device')
649
      .send({})
650
      .set('Authorization', jwt)
651
      .end((err, res) => {
UNCOV
652
        console.log("🚸 [chai] DELETE /api/v2/device (JWT, invalid) response:", res.text, " status:", res.status);
×
UNCOV
653
        expect(res.status).to.equal(200);
×
UNCOV
654
        expect(res.text).to.be.a('string');
×
UNCOV
655
        done();
×
656
      });
657
  }, 30000);
658

659
  it("DELETE /api/v2/device (jwt, multi)", function (done) {
1✔
UNCOV
660
    console.log("🚸 [chai] DELETE /api/v2/device (JWT, multi)");
×
UNCOV
661
    agent
×
662
      .delete('/api/v2/device')
663
      .send({ udids: dynamic_devices })
664
      .set('Authorization', jwt)
665
      .end((err, res) => {
UNCOV
666
        console.log("🚸 [chai] GET /api/v2/device (JWT, multi) response:", res.text, " status:", res.status);
×
UNCOV
667
        expect(res.status).to.equal(200);
×
UNCOV
668
        expect(res.text).to.be.a('string');
×
UNCOV
669
        done();
×
670
      });
671
  }, 30000);
672

673
  
674
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc