Add support for oauth adminAuth configs

This commit is contained in:
Nick O'Leary
2017-04-12 10:09:03 +01:00
parent bfb548636e
commit c54cf26848
8 changed files with 180 additions and 44 deletions

View File

@@ -85,7 +85,7 @@ describe("api auth middleware",function() {
Users.init.restore();
});
it("returns login details - credentials", function(done) {
auth.init({settings:{adminAuth:{}},log:{audit:function(){}}})
auth.init({settings:{adminAuth:{type:"credentials"}},log:{audit:function(){}}})
auth.login(null,{json: function(resp) {
resp.should.have.a.property("type","credentials");
resp.should.have.a.property("prompts");
@@ -100,6 +100,19 @@ describe("api auth middleware",function() {
done();
}});
});
it("returns login details - oauth", function(done) {
auth.init({settings:{adminAuth:{type:"oauth",strategy:{label:"test-oauth",icon:"test-icon"}}},log:{audit:function(){}}})
auth.login(null,{json: function(resp) {
resp.should.have.a.property("type","oauth");
resp.should.have.a.property("prompts");
resp.prompts.should.have.a.lengthOf(1);
resp.prompts[0].should.have.a.property("type","button");
resp.prompts[0].should.have.a.property("label","test-oauth");
resp.prompts[0].should.have.a.property("icon","test-icon");
done();
}});
});
});