mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
* APIv3: isolating documents from tests (not allowing clashes of calculated identifiers) * removing unused async keyword * fixing api v3 swagger and moving it to /api3-docs * APIv3: adding cachedCollection stub of cachedCollection storage implementation * APIv3: mongo cachedCollection storage implementation * APIv3: testing and debugging cache updates * APIv3: more testing on cache updates * APIv3: fixing bad async functions * APIv3: finishing cache invalidation tests Co-authored-by: Petr Ondrusek <petr.ondrusek@seznam.cz> Co-authored-by: Petr Ondrůšek <petr.ondrusek@okin.eu> Co-authored-by: Sulka Haro <sulka@sulka.net>
65 lines
1.4 KiB
JavaScript
65 lines
1.4 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);
|
|
|
|
self.subject = authResult.subject;
|
|
self.token = authResult.token;
|
|
self.urlToken = `${self.url}?token=${self.token.delete}`;
|
|
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?token=${self.url}`)
|
|
.send(self.validDoc)
|
|
.expect(404);
|
|
|
|
res.body.should.be.empty();
|
|
});
|
|
|
|
});
|
|
|