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

suculent / thinx-device-api / #252646769

01 Nov 2025 03:54PM UTC coverage: 71.357% (+25.1%) from 46.298%
#252646769

push

suculent
testing fixed broker URL configuration after MQTT upgrade

1841 of 3538 branches covered (52.04%)

Branch coverage included in aggregate %.

27 of 38 new or added lines in 1 file covered. (71.05%)

25 existing lines in 13 files now uncovered.

8169 of 10490 relevant lines covered (77.87%)

7.39 hits per line

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

98.78
/spec/jasmine/ZZ-RouterENVVarSpec.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
let chaiHttp = require('chai-http');
1✔
7
var expect = require('chai').expect;
1✔
8
var envi = require("../_envi.json");
1✔
9
chai.use(chaiHttp);
1✔
10

11
let thx;
12

13
describe("ENV Vars (noauth)", function () {
1✔
14

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

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

27
  it("POST /api/user/env/revoke (noauth, invalid)", function (done) {
1✔
28
    chai.request(thx.app)
1✔
29
      .post('/api/user/env/revoke')
30
      .send()
31
      .end((_err, res) => {
32
        expect(res.status).to.equal(401);
1✔
33
        done();
1✔
34
      });
35
  }, 30000);
36

37
  it("POST /api/user/env/add (noauth, invalid)", function (done) {
1✔
38
    chai.request(thx.app)
1✔
39
      .post('/api/user/env/add')
40
      .send()
41
      .end((_err, res) => {
42
        expect(res.status).to.equal(401);
1✔
43
        done();
1✔
44
      });
45
  }, 30000);
46

47
  it("POST /api/user/env/add (noauth, semi-valid)", function (done) {
1✔
48
    chai.request(thx.app)
1✔
49
      .post('/api/user/env/add')
50
      .send({ udid: envi.oid })
51
      .end((_err, res) => {
52
        expect(res.status).to.equal(401);
1✔
53
        done();
1✔
54
      });
55
  }, 30000);
56

57
  it("POST /api/user/env/revoke (noauth, semi-valid)", function (done) {
1✔
58
    chai.request(thx.app)
1✔
59
      .post('/api/user/env/revoke')
60
      .send({ udid: envi.oid })
61
      .end((_err, res) => {
62
        expect(res.status).to.equal(401);
1✔
63
        done();
1✔
64
      });
65
  }, 30000);
66

67
  it("GET /api/user/env/list (noauth)", function (done) {
1✔
68
    chai.request(thx.app)
1✔
69
      .get('/api/user/env/list')
70
      .end((_err, res) => {
71
        expect(res.status).to.equal(401);
1✔
72
        done();
1✔
73
      });
74
  }, 30000);
75
});
76

77
describe("ENV Vars (JWT)", function () {
1✔
78

79
  let agent;
80
  let jwt;
81

82
  beforeAll((done) => {
1✔
83
    console.log(`🚸 [chai] >>> running ENV Vars (JWT) spec`);
1✔
84
    agent = chai.request.agent(thx.app);
1✔
85
    agent
1✔
86
      .post('/api/login')
87
      .send({ 
88
        username: envi.dynamic.username,
89
        password: envi.dynamic.username, 
90
        remember: false }
91
      )
92
      .then(function (res) {
93
        let body = JSON.parse(res.text);
1✔
94
        jwt = 'Bearer ' + body.access_token;
1✔
95
        done();
1✔
96
      })
UNCOV
97
      .catch((e) => { console.log(e); });
×
98
  });
99

100
  afterAll((done) => {
1✔
101
    agent.close();
1✔
102
    console.log(`🚸 [chai] <<< completed ENV Vars (JWT) spec`);
1✔
103
    done();
1✔
104
  });
105

106
  it("POST /api/user/env/add (JWT, valid)", function (done) {
1✔
107
    chai.request(thx.app)
1✔
108
      .post('/api/user/env/add')
109
      .set('Authorization', jwt)
110
      .send({ key: "env-name", value: "env-value"})
111
      .end((err, res) => {
112
        expect(res.status).to.equal(200);
1✔
113
        expect(res.text).to.be.a('string');
1✔
114
        expect(res.text).to.equal('{"success":true,"response":"env-name"}');
1✔
115
        done();
1✔
116
      });
117
  }, 30000);
118

119
  it("POST /api/user/env/revoke (JWT, invalid)", function (done) {
1✔
120
    chai.request(thx.app)
1✔
121
      .post('/api/user/env/revoke')
122
      .set('Authorization', jwt)
123
      .send()
124
      .end((err, res) => {
125
        expect(res.status).to.equal(400);
1✔
126
        expect(res.text).to.be.a('string');
1✔
127
        expect(res.text).to.equal('{"success":false,"response":"missing_body"}');
1✔
128
        done();
1✔
129
      });
130
  }, 30000);
131

132
  it("POST /api/user/env/add (JWT, invalid)", function (done) {
1✔
133
    chai.request(thx.app)
1✔
134
      .post('/api/user/env/add')
135
      .set('Authorization', jwt)
136
      .send()
137
      .end((err, res) => {
138
        expect(res.status).to.equal(400);
1✔
139
        expect(res.text).to.be.a('string');
1✔
140
        expect(res.text).to.equal('{"success":false,"response":"missing_body"}');
1✔
141
        done();
1✔
142
      });
143
  }, 30000);
144

145
  it("POST /api/user/env/add (JWT, semi-valid)", function (done) {
1✔
146
    chai.request(thx.app)
1✔
147
      .post('/api/user/env/add')
148
      .set('Authorization', jwt)
149
      .send({ udid: envi.oid })
150
      .end((err, res) => {
151
        expect(res.status).to.equal(200);
1✔
152
        expect(res.text).to.be.a('string');
1✔
153
        expect(res.text).to.equal('{"success":false,"response":"missing_key"}');
1✔
154
        done();
1✔
155
      });
156
  }, 30000);
157

158
  it("POST /api/user/env/revoke (JWT, semi-valid)", function (done) {
1✔
159
    chai.request(thx.app)
1✔
160
      .post('/api/user/env/revoke')
161
      .set('Authorization', jwt)
162
      .send({ udid: envi.oid })
163
      .end((err, res) => {
164
        expect(res.status).to.equal(200);
1✔
165
        expect(res.text).to.be.a('string');
1✔
166
        expect(res.text).to.equal('{"success":false,"response":"no_names_given"}');
1✔
167
        done();
1✔
168
      });
169
  }, 30000);
170

171
  it("GET /api/user/env/list (JWT)", function (done) {
1✔
172
    chai.request(thx.app)
1✔
173
      .get('/api/user/env/list')
174
      .set('Authorization', jwt)
175
      .end((err, res) => {
176
        expect(res.status).to.equal(200);
1✔
177
        expect(res.text).to.be.a('string');
1✔
178
        //expect(res.text).to.equal('{"env_vars":["env-name"]}'); // does not return values, this is a one-way
179
        done();
1✔
180
      });
181
  }, 30000);
182
});
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