@@ -7,13 +7,11 @@ const SolidAuthOIDC = require('solid-auth-oidc')
77
88const fetch = require ( 'node-fetch' )
99const localStorage = require ( 'localstorage-memory' )
10- const url = require ( 'url' )
1110const URL = require ( 'whatwg-url' ) . URL
1211global . URL = URL
1312global . URLSearchParams = require ( 'whatwg-url' ) . URLSearchParams
1413
1514const supertest = require ( 'supertest' )
16- const nock = require ( 'nock' )
1715const chai = require ( 'chai' )
1816const expect = chai . expect
1917chai . use ( require ( 'dirty-chai' ) )
@@ -89,48 +87,6 @@ describe('Authentication API (OIDC)', () => {
8987 fs . removeSync ( path . join ( bobRootPath , 'index.html.acl' ) )
9088 } )
9189
92- describe ( 'Provider Discovery (POST /api/auth/select-provider)' , ( ) => {
93- it ( 'form should load on a get' , done => {
94- alice . get ( '/api/auth/select-provider' )
95- . expect ( 200 )
96- . expect ( ( res ) => { res . text . match ( / P r o v i d e r D i s c o v e r y / ) } )
97- . end ( done )
98- } )
99-
100- it ( 'should complain if WebID URI is missing' , ( done ) => {
101- alice . post ( '/api/auth/select-provider' )
102- . expect ( 400 , done )
103- } )
104-
105- it ( 'should prepend https:// to webid, if necessary' , ( done ) => {
106- alice . post ( '/api/auth/select-provider' )
107- . type ( 'form' )
108- . send ( { webid : 'localhost:7000' } )
109- . expect ( 302 , done )
110- } )
111-
112- it ( "should return a 400 if endpoint doesn't have Link Headers" , ( done ) => {
113- // Fake provider, replies with 200 and no Link headers
114- nock ( 'https://amazingwebsite.tld' ) . intercept ( '/' , 'OPTIONS' ) . reply ( 204 )
115-
116- alice . post ( '/api/auth/select-provider' )
117- . send ( 'webid=https://amazingwebsite.tld/' )
118- . expect ( 400 )
119- . end ( done )
120- } )
121-
122- it ( 'should redirect user to discovered provider if valid uri' , ( done ) => {
123- bob . post ( '/api/auth/select-provider' )
124- . send ( 'webid=' + aliceServerUri )
125- . expect ( 302 )
126- . end ( ( err , res ) => {
127- let loginUri = res . header . location
128- expect ( loginUri . startsWith ( aliceServerUri + '/authorize' ) )
129- done ( err )
130- } )
131- } )
132- } )
133-
13490 describe ( 'Login page (GET /login)' , ( ) => {
13591 it ( 'should load the user login form' , ( ) => {
13692 return alice . get ( '/login' )
@@ -279,39 +235,13 @@ describe('Authentication API (OIDC)', () => {
279235 } )
280236 } )
281237
282- describe ( 'Two Pods + Browser Login workflow' , ( ) => {
283- // Step 1: Alice tries to access bob.com/shared-with-alice.txt, and
284- // gets redirected to bob.com's Provider Discovery endpoint
285- it ( '401 Unauthorized -> redirect to provider discovery' , ( done ) => {
238+ describe ( 'Browser login workflow' , ( ) => {
239+ it ( '401 Unauthorized asking the user to log in' , ( done ) => {
286240 bob . get ( '/shared-with-alice.txt' )
287241 . expect ( 401 )
288242 . end ( ( err , res ) => {
289- if ( err ) return done ( err )
290- let redirectString = 'http-equiv="refresh" ' +
291- `content="0; url=${ bobServerUri } /api/auth/select-provider`
292- expect ( res . text ) . to . match ( new RegExp ( redirectString ) )
293- done ( )
294- } )
295- } )
296-
297- // Step 2: Alice enters her pod's URI to Bob's Provider Discovery endpoint
298- it ( 'Enter webId -> redirect to provider login' , ( ) => {
299- return bob . post ( '/api/auth/select-provider' )
300- . send ( 'webid=' + aliceServerUri )
301- . expect ( 302 )
302- . then ( res => {
303- // Submitting select-provider form redirects to Alice's pod's /authorize
304- let authorizeUri = res . header . location
305- expect ( authorizeUri . startsWith ( aliceServerUri + '/authorize' ) )
306-
307- // Follow the redirect to /authorize
308- let authorizePath = url . parse ( authorizeUri ) . path
309- return alice . get ( authorizePath )
310- } )
311- . then ( res => {
312- // Since alice not logged in to her pod, /authorize redirects to /login
313- let loginUri = res . header . location
314- expect ( loginUri . startsWith ( '/login' ) )
243+ expect ( res . text ) . to . contain ( 'Log in' )
244+ done ( err )
315245 } )
316246 } )
317247 } )
0 commit comments