@@ -526,6 +526,9 @@ describe('Authentication API (OIDC)', () => {
526526 let authorizationUri , loginUri , authParams , callbackUri
527527 let loginFormFields = ''
528528 let bearerToken
529+ let postLoginUri
530+ let cookie
531+ let postConsentUri
529532
530533 before ( ( ) => {
531534 auth = new SolidAuthOIDC ( { store : localStorage , window : { location : { } } } )
@@ -627,25 +630,50 @@ describe('Authentication API (OIDC)', () => {
627630 } )
628631 . then ( res => {
629632 expect ( res . status ) . to . equal ( 302 )
630- let postLoginUri = res . headers . get ( 'location' )
631- let cookie = res . headers . get ( 'set-cookie' )
633+ postLoginUri = res . headers . get ( 'location' )
634+ cookie = res . headers . get ( 'set-cookie' )
632635
633636 // Successful login gets redirected back to /authorize and then
634637 // back to app
635- expect ( postLoginUri . startsWith ( aliceServerUri + '/authorize ' ) )
638+ expect ( postLoginUri . startsWith ( aliceServerUri + '/consent ' ) )
636639 . to . be . true ( )
637-
638- return fetch ( postLoginUri , { redirect : 'manual' , headers : { cookie } } )
639- } )
640- . then ( res => {
641- // User gets redirected back to original app
642- expect ( res . status ) . to . equal ( 302 )
643- callbackUri = res . headers . get ( 'location' )
644- expect ( callbackUri . startsWith ( 'https://app.example.com#' ) )
645640 } )
646641 } )
647642
648- // Step 6: Web App extracts tokens from the uri hash fragment, uses
643+ // Step 6: User consents to the app accessing certain things
644+ it ( 'should consent via the /consent form' , ( ) => {
645+ loginFormFields += `&access_mode=Read&access_mode=Write&consent=true`
646+
647+ return fetch ( aliceServerUri + '/consent' , {
648+ method : 'POST' ,
649+ body : loginFormFields ,
650+ redirect : 'manual' ,
651+ headers : {
652+ 'content-type' : 'application/x-www-form-urlencoded' ,
653+ cookie
654+ } ,
655+ credentials : 'include'
656+ } )
657+ . then ( res => {
658+ expect ( res . status ) . to . equal ( 302 )
659+ postConsentUri = res . headers . get ( 'location' )
660+ // cookie = res.headers.get('set-cookie')
661+
662+ // Successful login gets redirected back to /authorize and then
663+ // back to app
664+ expect ( postConsentUri . startsWith ( aliceServerUri + '/authorize' ) )
665+ . to . be . true ( )
666+ return fetch ( postConsentUri , { redirect : 'manual' , headers : { cookie } } )
667+ } )
668+ . then ( res => {
669+ // User gets redirected back to original app
670+ expect ( res . status ) . to . equal ( 302 )
671+ callbackUri = res . headers . get ( 'location' )
672+ expect ( callbackUri . startsWith ( 'https://app.example.com#' ) )
673+ } )
674+ } )
675+
676+ // Step 7: Web App extracts tokens from the uri hash fragment, uses
649677 // them to access protected resource
650678 it ( 'should use id token from the callback uri to access shared resource (no origin)' , ( ) => {
651679 auth . window . location . href = callbackUri
0 commit comments