@@ -15,13 +15,16 @@ describe('Authentication API (OIDC)', () => {
1515
1616 let aliceServerUri = 'https://localhost:7000'
1717 let aliceWebId = 'https://localhost:7000/profile/card#me'
18- let aliceDbPath = path . join ( __dirname , '../resources/db/alice' )
18+ let configPath = path . join ( __dirname , '../../config' )
19+ let aliceDbPath = path . join ( __dirname ,
20+ '../resources/accounts-scenario/alice/db/oidc' )
1921 let userStorePath = path . join ( aliceDbPath , 'users' )
2022 let aliceUserStore = UserStore . from ( { path : userStorePath , saltRounds : 1 } )
2123 aliceUserStore . initCollections ( )
2224
2325 let bobServerUri = 'https://localhost:7001'
24- let bobDbPath = path . join ( __dirname , '../resources/db/bob' )
26+ let bobDbPath = path . join ( __dirname ,
27+ '../resources/accounts-scenario/bob/db/oidc' )
2528
2629 const serverConfig = {
2730 sslKey : path . join ( __dirname , '../keys/key.pem' ) ,
@@ -30,7 +33,8 @@ describe('Authentication API (OIDC)', () => {
3033 dataBrowser : false ,
3134 fileBrowser : false ,
3235 webid : true ,
33- idp : false
36+ idp : false ,
37+ configPath
3438 }
3539
3640 const alicePod = Solid . createServer (
@@ -67,25 +71,23 @@ describe('Authentication API (OIDC)', () => {
6771 after ( ( ) => {
6872 if ( aliceServer ) aliceServer . close ( )
6973 if ( bobServer ) bobServer . close ( )
70- // fs.removeSync(aliceDbPath)
71- // fs.removeSync(bobDbPath)
7274 } )
7375
74- describe ( 'Provider Discovery (POST /api/auth/discover )' , ( ) => {
76+ describe ( 'Provider Discovery (POST /api/auth/select-provider )' , ( ) => {
7577 it ( 'form should load on a get' , done => {
76- alice . get ( '/api/auth/discover ' )
78+ alice . get ( '/api/auth/select-provider ' )
7779 . expect ( 200 )
7880 . expect ( ( res ) => { res . text . match ( / P r o v i d e r D i s c o v e r y / ) } )
7981 . end ( done )
8082 } )
8183
8284 it ( 'should complain if WebID URI is missing' , ( done ) => {
83- alice . post ( '/api/auth/discover ' )
85+ alice . post ( '/api/auth/select-provider ' )
8486 . expect ( 400 , done )
8587 } )
8688
8789 it ( 'should prepend https:// to webid, if necessary' , ( done ) => {
88- alice . post ( '/api/auth/discover ' )
90+ alice . post ( '/api/auth/select-provider ' )
8991 . type ( 'form' )
9092 . send ( { webid : 'localhost:7000' } )
9193 . expect ( 302 , done )
@@ -95,14 +97,14 @@ describe('Authentication API (OIDC)', () => {
9597 // Fake provider, replies with 200 and no Link headers
9698 nock ( 'https://amazingwebsite.tld' ) . intercept ( '/' , 'OPTIONS' ) . reply ( 204 )
9799
98- alice . post ( '/api/auth/discover ' )
100+ alice . post ( '/api/auth/select-provider ' )
99101 . send ( 'webid=https://amazingwebsite.tld/' )
100102 . expect ( 400 )
101103 . end ( done )
102104 } )
103105
104106 it ( 'should redirect user to discovered provider if valid uri' , ( done ) => {
105- bob . post ( '/api/auth/discover ' )
107+ bob . post ( '/api/auth/select-provider ' )
106108 . send ( 'webid=' + aliceServerUri )
107109 . expect ( 302 )
108110 . end ( ( err , res ) => {
@@ -126,7 +128,7 @@ describe('Authentication API (OIDC)', () => {
126128 } )
127129
128130 afterEach ( ( ) => {
129- fs . removeSync ( aliceDbPath )
131+ fs . removeSync ( path . join ( aliceDbPath , 'users/*' ) )
130132 } )
131133
132134 it ( 'should login and be redirected to /authorize' , ( done ) => {
@@ -175,15 +177,15 @@ describe('Authentication API (OIDC)', () => {
175177 . end ( ( err , res ) => {
176178 if ( err ) return done ( err )
177179 let redirectString = 'http-equiv="refresh" ' +
178- `content="0; url=${ bobServerUri } /api/auth/discover `
180+ `content="0; url=${ bobServerUri } /api/auth/select-provider `
179181 expect ( res . text ) . to . match ( new RegExp ( redirectString ) )
180182 done ( )
181183 } )
182184 } )
183185
184186 // Step 2: Alice enters her WebID URI to the Provider Discovery endpoint
185187 it ( 'Enter webId -> redirect to provider login' , ( done ) => {
186- bob . post ( '/api/auth/discover ' )
188+ bob . post ( '/api/auth/select-provider ' )
187189 . send ( 'webid=' + aliceServerUri )
188190 . expect ( 302 )
189191 . end ( ( err , res ) => {
0 commit comments