mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
* APIv3: removing authorization by accessToken from codebase and adjusting tests * APIv3: updating docs --------- Co-authored-by: Petr Ondrůšek <petr.ondrusek@okin.eu> Co-authored-by: Sulka Haro <sulka@sulka.net>
66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
/* eslint require-atomic-updates: 0 */
|
|
'use strict';
|
|
|
|
require('should');
|
|
|
|
describe('API3 UPDATE', function() {
|
|
const self = this
|
|
, instance = require('./fixtures/api3/instance')
|
|
, authSubject = require('./fixtures/api3/authSubject')
|
|
;
|
|
|
|
self.timeout(15000);
|
|
|
|
|
|
before(async () => {
|
|
self.instance = await instance.create({});
|
|
|
|
self.app = self.instance.app;
|
|
self.env = self.instance.env;
|
|
self.url = '/api/v3/treatments';
|
|
|
|
let authResult = await authSubject(self.instance.ctx.authorization.storage, [
|
|
'delete'
|
|
], self.instance.app);
|
|
|
|
self.subject = authResult.subject;
|
|
self.jwt = authResult.jwt;
|
|
self.cache = self.instance.cacheMonitor;
|
|
});
|
|
|
|
|
|
after(() => {
|
|
self.instance.ctx.bus.teardown();
|
|
});
|
|
|
|
|
|
beforeEach(() => {
|
|
self.cache.clear();
|
|
});
|
|
|
|
|
|
afterEach(() => {
|
|
self.cache.shouldBeEmpty();
|
|
});
|
|
|
|
|
|
it('should require authentication', async () => {
|
|
let res = await self.instance.delete(`${self.url}/FAKE_IDENTIFIER`)
|
|
.expect(401);
|
|
|
|
res.body.status.should.equal(401);
|
|
res.body.message.should.equal('Missing or bad access token or JWT');
|
|
});
|
|
|
|
|
|
it('should not found not existing collection', async () => {
|
|
let res = await self.instance.delete(`/api/v3/NOT_EXIST`, self.jwt.delete)
|
|
.send(self.validDoc)
|
|
.expect(404);
|
|
|
|
res.body.status.should.equal(404);
|
|
});
|
|
|
|
});
|
|
|