@@ -33,6 +33,8 @@ describe("OIDC authentication", () => {
3333 } ) ;
3434
3535 beforeEach ( ( ) => {
36+ cy . clearLocalStorage ( ) ;
37+
3638 // load login page
3739 interceptSettings ( {
3840 "release.type" : "EE" ,
@@ -76,7 +78,7 @@ describe("OIDC authentication", () => {
7678 cy . logout ( ) ;
7779 } ) ;
7880
79- it ( "should force authentication if token expired, and there is no refresh token" , ( ) => {
81+ it ( "should force SSO authentication if token expired, and there is no refresh token" , ( ) => {
8082 interceptAuthorizationCodeRequest ( `${ baseUrl } ?code=abcdefgh` ) ;
8183 cy . getByDataHook ( "button-sso-login" ) . click ( ) ;
8284 cy . wait ( "@authorizationCode" ) ;
@@ -91,9 +93,65 @@ describe("OIDC authentication", () => {
9193 cy . getEditor ( ) . should ( "be.visible" ) ;
9294
9395 cy . reload ( ) ;
94- cy . getByDataHook ( "button-log-in" ) . should ( "be.visible" ) ;
96+ cy . getByDataHook ( "button-sso-login" ) . should ( "be.visible" ) ;
97+
98+ cy . getByDataHook ( "button-sso-login" ) . click ( ) ;
99+ cy . getEditor ( ) . should ( "be.visible" ) ;
100+ } ) ;
101+
102+ it ( "should not force SSO re-authentication with continue button" , ( ) => {
103+ interceptAuthorizationCodeRequest ( `${ baseUrl } ?code=abcdefgh` ) ;
104+ cy . getByDataHook ( "button-sso-login" ) . click ( ) ;
105+ cy . wait ( "@authorizationCode" ) ;
106+
107+ interceptTokenRequest ( {
108+ "access_token" : "gslpJtzmmi6RwaPSx0dYGD4tEkom" ,
109+ "refresh_token" : "FUuAAqMp6LSTKmkUd5uZuodhiE4Kr6M7Eyv" ,
110+ "id_token" : "eyJhbGciOiJSUzI1NiIsImtpZCI6I" ,
111+ "token_type" : "Bearer" ,
112+ "expires_in" : 300
113+ } ) ;
114+ cy . wait ( "@tokens" ) ;
115+ cy . getEditor ( ) . should ( "be.visible" ) ;
116+
117+ cy . executeSQL ( "select current_user();" ) ;
118+ cy . getGridRow ( 0 ) . should ( "contain" , "user1" ) ;
119+
120+ cy . logout ( ) ;
121+
122+ cy . getByDataHook ( "button-sso-continue" ) . click ( ) ;
123+ cy . wait ( "@authorizationCode" ) . then ( ( interception ) => {
124+ expect ( interception . request . url ) . to . include ( "/authorization" ) ;
125+ const url = new URL ( interception . request . url ) ;
126+ expect ( url . searchParams . get ( "prompt" ) ) . to . equal ( null ) ;
127+ } ) ;
128+ } ) ;
129+
130+ it ( "should force SSO re-authentication with choose a different account button" , ( ) => {
131+ interceptAuthorizationCodeRequest ( `${ baseUrl } ?code=abcdefgh` ) ;
132+ cy . getByDataHook ( "button-sso-login" ) . click ( ) ;
133+ cy . wait ( "@authorizationCode" ) ;
95134
96- cy . getByDataHook ( "button-log-in" ) . click ( )
135+ interceptTokenRequest ( {
136+ "access_token" : "gslpJtzmmi6RwaPSx0dYGD4tEkom" ,
137+ "refresh_token" : "FUuAAqMp6LSTKmkUd5uZuodhiE4Kr6M7Eyv" ,
138+ "id_token" : "eyJhbGciOiJSUzI1NiIsImtpZCI6I" ,
139+ "token_type" : "Bearer" ,
140+ "expires_in" : 300
141+ } ) ;
142+ cy . wait ( "@tokens" ) ;
97143 cy . getEditor ( ) . should ( "be.visible" ) ;
144+
145+ cy . executeSQL ( "select current_user();" ) ;
146+ cy . getGridRow ( 0 ) . should ( "contain" , "user1" ) ;
147+
148+ cy . logout ( ) ;
149+
150+ cy . getByDataHook ( "button-sso-login" ) . click ( ) ;
151+ cy . wait ( "@authorizationCode" ) . then ( ( interception ) => {
152+ expect ( interception . request . url ) . to . include ( "/authorization" ) ;
153+ const url = new URL ( interception . request . url ) ;
154+ expect ( url . searchParams . get ( "prompt" ) ) . to . equal ( "login" ) ;
155+ } ) ;
98156 } ) ;
99- } ) ;
157+ } ) ;
0 commit comments