-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmachine.test.js
More file actions
30 lines (27 loc) · 999 Bytes
/
machine.test.js
File metadata and controls
30 lines (27 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const os = require('os');
const ip = require('../../sdk/utils/ip');
const request = require('supertest');
const app = require('../../app');
const { expectError } = require('../../utils/testWrapper/index');
describe('machine', () => {
// Testing authorization
test('should be 401 if auth is not passed', async () => {
const response = await request(app)
.get('/admin/machine');
expectError(response, 401, 'Unauthorized');
});
test('should be 401 if auth does not match', async () => {
const response = await request(app)
.get('/admin/machine')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
});
test('should be 200', async () => {
const response = await request(app)
.get('/admin/machine')
.set('Authorization', 'test');
expect(response.statusCode).toEqual(200);
expect(response.body).toHaveProperty('ip', ip.address());
expect(response.body).toHaveProperty('name', os.hostname());
});
});