1
1
const chai = require ( 'chai' ) ;
2
- const service = require ( '../src/service' ) ;
3
2
const config = require ( '../src/config' ) ;
4
3
const sinon = require ( 'sinon' ) ;
5
4
const proxyquire = require ( 'proxyquire' ) ;
@@ -8,12 +7,6 @@ chai.should();
8
7
const expect = chai . expect ;
9
8
10
9
describe ( 'auth methods' , async ( ) => {
11
- let app ;
12
-
13
- before ( async function ( ) {
14
- app = await service . start ( ) ;
15
- } ) ;
16
-
17
10
it ( 'should return a local auth method by default' , async function ( ) {
18
11
const authMethods = config . getAuthMethods ( ) ;
19
12
expect ( authMethods ) . to . have . lengthOf ( 1 ) ;
@@ -41,7 +34,28 @@ describe('auth methods', async () => {
41
34
expect ( ( ) => config . getAuthMethods ( ) ) . to . throw ( Error , 'No authentication method enabled' ) ;
42
35
} ) ;
43
36
44
- after ( async function ( ) {
45
- await service . httpServer . close ( ) ;
46
- } ) ;
37
+ it ( 'should return an array of enabled auth methods when overridden' , async function ( ) {
38
+ const newConfig = JSON . stringify ( {
39
+ authentication : [
40
+ { type : 'local' , enabled : true } ,
41
+ { type : 'ActiveDirectory' , enabled : true } ,
42
+ { type : 'openidconnect' , enabled : true } ,
43
+ ] ,
44
+ } ) ;
45
+
46
+ const fsStub = {
47
+ existsSync : sinon . stub ( ) . returns ( true ) ,
48
+ readFileSync : sinon . stub ( ) . returns ( newConfig ) ,
49
+ } ;
50
+
51
+ const config = proxyquire ( '../src/config' , {
52
+ fs : fsStub ,
53
+ } ) ;
54
+
55
+ const authMethods = config . getAuthMethods ( ) ;
56
+ expect ( authMethods ) . to . have . lengthOf ( 3 ) ;
57
+ expect ( authMethods [ 0 ] . type ) . to . equal ( 'local' ) ;
58
+ expect ( authMethods [ 1 ] . type ) . to . equal ( 'ActiveDirectory' ) ;
59
+ expect ( authMethods [ 2 ] . type ) . to . equal ( 'openidconnect' ) ;
60
+ } )
47
61
} ) ;
0 commit comments