@@ -33,6 +33,8 @@ describe("OIDC authentication", () => {
33
33
} ) ;
34
34
35
35
beforeEach ( ( ) => {
36
+ cy . clearLocalStorage ( ) ;
37
+
36
38
// load login page
37
39
interceptSettings ( {
38
40
"release.type" : "EE" ,
@@ -76,7 +78,7 @@ describe("OIDC authentication", () => {
76
78
cy . logout ( ) ;
77
79
} ) ;
78
80
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" , ( ) => {
80
82
interceptAuthorizationCodeRequest ( `${ baseUrl } ?code=abcdefgh` ) ;
81
83
cy . getByDataHook ( "button-sso-login" ) . click ( ) ;
82
84
cy . wait ( "@authorizationCode" ) ;
@@ -91,9 +93,65 @@ describe("OIDC authentication", () => {
91
93
cy . getEditor ( ) . should ( "be.visible" ) ;
92
94
93
95
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" ) ;
95
134
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" ) ;
97
143
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
+ } ) ;
98
156
} ) ;
99
- } ) ;
157
+ } ) ;
0 commit comments