mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-22 23:12:23 +00:00
532e75a77e
This excludes route tests or refactoring. Also, created tests for API middleware. Change-type: patch Signed-off-by: Christina Ying Wang <christina@balena.io>
30 lines
707 B
TypeScript
30 lines
707 B
TypeScript
import * as express from 'express';
|
|
import * as request from 'supertest';
|
|
|
|
import * as deviceApi from '~/src/device-api';
|
|
|
|
describe('device-api/index', () => {
|
|
let api: express.Application;
|
|
|
|
before(async () => {
|
|
api = new deviceApi.SupervisorAPI({
|
|
routers: [],
|
|
healthchecks: [],
|
|
// @ts-expect-error
|
|
}).api;
|
|
// Express app set in SupervisorAPI is private here
|
|
// but we need to access it for supertest
|
|
});
|
|
|
|
describe('/ping', () => {
|
|
it('responds with 200 regardless of auth', async () => {
|
|
await request(api).get('/ping').expect(200);
|
|
|
|
await request(api)
|
|
.get('/ping')
|
|
.set('Authorization', `Bearer ${await deviceApi.getGlobalApiKey()}`)
|
|
.expect(200);
|
|
});
|
|
});
|
|
});
|