1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

tests custom cors settings

This commit is contained in:
aaronmyatt 2020-12-06 15:29:54 +08:00
parent 0b569a4120
commit c9bc530df0

View File

@ -112,15 +112,6 @@ describe("api/index", function() {
}); });
}); });
//adminAuth: {
// type: "credentials",
// users: [{
// username: "admin",
// password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
// permissions: "*"
// }]
//},
describe('initialises api with authentication enabled', function(done) { describe('initialises api with authentication enabled', function(done) {
it('enables an oauth/openID based authentication mechanism',function(done) { it('enables an oauth/openID based authentication mechanism',function(done) {
@ -144,4 +135,25 @@ describe("api/index", function() {
}); });
describe('initialises api with custom cors config', function (done) {
const httpAdminCors = {
origin: "*",
methods: "GET,PUT,POST,DELETE"
};
it('uses default cors middleware when user settings absent', function(done){
api.init({ httpAdminRoot: true }, {}, {}, {});
const middlewareFound = api.httpAdmin._router.stack.filter((layer) => layer.name === 'corsMiddleware')
should(middlewareFound).be.length(1);
done();
})
it('enables custom cors middleware when settings present', function(done){
api.init({ httpAdminRoot: true, httpAdminCors }, {}, {}, {});
const middlewareFound = api.httpAdmin._router.stack.filter((layer) => layer.name === 'corsMiddleware')
should(middlewareFound).be.length(2);
done();
})
});
}); });