WIP: separate runtime and api components

This commit is contained in:
Nick O'Leary
2015-11-11 22:11:02 +00:00
parent 923a46d304
commit f43738446e
49 changed files with 695 additions and 612 deletions

View File

@@ -24,12 +24,14 @@ var auth = require("../../../../red/api/auth");
var Users = require("../../../../red/api/auth/users");
var Tokens = require("../../../../red/api/auth/tokens");
var settings = require("../../../../red/settings");
describe("api auth middleware",function() {
describe("ensureClientSecret", function() {
before(function() {
auth.init({settings:{},log:{audit:function(){}}})
});
it("leaves client_secret alone if not present",function(done) {
var req = {
body: {
@@ -83,7 +85,7 @@ describe("api auth middleware",function() {
Users.init.restore();
});
it("returns login details - credentials", function(done) {
auth.init({adminAuth:{}},null);
auth.init({settings:{adminAuth:{}},log:{audit:function(){}}})
auth.login(null,{json: function(resp) {
resp.should.have.a.property("type","credentials");
resp.should.have.a.property("prompts");
@@ -92,7 +94,7 @@ describe("api auth middleware",function() {
}});
});
it("returns login details - none", function(done) {
auth.init({},null);
auth.init({settings:{},log:{audit:function(){}}})
auth.login(null,{json: function(resp) {
resp.should.eql({});
done();

View File

@@ -24,8 +24,10 @@ var Tokens = require("../../../../red/api/auth/tokens");
var Clients = require("../../../../red/api/auth/clients");
describe("Auth strategies", function() {
before(function() {
strategies.init({log:{audit:function(){}}})
});
describe("Password Token Exchange", function() {
var userAuthentication;
afterEach(function() {
if (userAuthentication) {
@@ -49,7 +51,7 @@ describe("Auth strategies", function() {
}
});
});
it('Handles scope overreach',function(done) {
userAuthentication = sinon.stub(Users,"authenticate",function(username,password) {
return when.resolve({username:"user",permissions:"read"});