mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
* * Simplified bundling to just one bundle * Removed cache invalidation token from bundling * Generate strong persistent random string on deploy to use for JWT signing * WIP: moving api-secret and JWT signing to a separate centralized security component * Moved some server components away from project root * Fix issues reported by linter * Ignore detect-object-injection everywhere but the client * Make admin message button red * Remove alarms for some security alerts on code * api_secret is now fully contained in the enclave
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
var request = require('supertest');
|
|
var language = require('../lib/language')();
|
|
|
|
require('should');
|
|
|
|
describe('Verifyauth REST api', function ( ) {
|
|
var self = this;
|
|
|
|
this.timeout(10000);
|
|
var known = 'b723e97aa97846eb92d5264f084b2823f57c4aa1';
|
|
|
|
var api = require('../lib/api/');
|
|
before(function (done) {
|
|
delete process.env.API_SECRET;
|
|
process.env.API_SECRET = 'this is my long pass phrase';
|
|
self.env = require('../lib/server/env')( );
|
|
self.env.settings.authDefaultRoles = 'denied';
|
|
this.wares = require('../lib/middleware/')(self.env);
|
|
self.app = require('express')( );
|
|
self.app.enable('api');
|
|
require('../lib/server/bootevent')(self.env, language).boot(function booted (ctx) {
|
|
self.app.use('/api', api(self.env, ctx));
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('/verifyauth should return UNAUTHORIZED', function (done) {
|
|
request(self.app)
|
|
.get('/api/verifyauth')
|
|
.expect(200)
|
|
.end(function(err, res) {
|
|
res.body.message.message.should.equal('UNAUTHORIZED');
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('/verifyauth should return OK', function (done) {
|
|
request(self.app)
|
|
.get('/api/verifyauth')
|
|
.set('api-secret', known || '')
|
|
.expect(200)
|
|
.end(function(err, res) {
|
|
res.body.message.message.should.equal('OK');
|
|
done();
|
|
});
|
|
});
|
|
|
|
|
|
});
|
|
|