1919import org .htmlunit .FailingHttpStatusCodeException ;
2020import org .htmlunit .WebClient ;
2121import org .htmlunit .WebResponse ;
22- import org .htmlunit .html .HtmlForm ;
23- import org .htmlunit .html .HtmlInput ;
24- import org .htmlunit .html .HtmlPage ;
25- import org .htmlunit .html .HtmlSubmitInput ;
22+ import org .htmlunit .html .*;
2623import org .junit .jupiter .api .Tag ;
2724import org .junit .jupiter .api .Test ;
2825import org .junit .jupiter .api .extension .ExtendWith ;
@@ -69,7 +66,7 @@ class OIDCAuthenticationProviderFactoryIT {
6966
7067 // The realm JSON resides in conf/keycloak/test-realm.json and gets avail here using <testResources> in pom.xml
7168 @ Container
72- static KeycloakContainer keycloakContainer = new KeycloakContainer ("quay.io/keycloak/keycloak:22.0 " )
69+ static KeycloakContainer keycloakContainer = new KeycloakContainer ("quay.io/keycloak/keycloak:26.1.4 " )
7370 .withRealmImportFile ("keycloak/test-realm.json" )
7471 .withAdminUsername (adminUser )
7572 .withAdminPassword (adminPassword );
@@ -186,8 +183,7 @@ void testAuthorizationCodeFlowWithPKCE() throws Exception {
186183
187184 OIDCAuthProvider oidcAuthProvider = getProvider ();
188185 String authzUrl = oidcAuthProvider .buildAuthzUrl (state , callbackUrl );
189- //System.out.println(authzUrl);
190-
186+
191187 try (WebClient webClient = new WebClient ()) {
192188 webClient .getOptions ().setCssEnabled (false );
193189 webClient .getOptions ().setJavaScriptEnabled (false );
@@ -200,27 +196,26 @@ void testAuthorizationCodeFlowWithPKCE() throws Exception {
200196 HtmlForm form = loginPage .getForms ().get (0 );
201197 HtmlInput username = form .getInputByName ("username" );
202198 HtmlInput password = form .getInputByName ("password" );
203- HtmlSubmitInput submit = form . getInputByName ( " login" );
204-
199+ HtmlButton submitButton = ( HtmlButton ) loginPage . getElementById ( "kc- login" );
200+
205201 username .type (realmAdminUser );
206202 password .type (realmAdminPassword );
207-
208- FailingHttpStatusCodeException exception = assertThrows (FailingHttpStatusCodeException .class , submit ::click );
203+
204+ FailingHttpStatusCodeException exception = assertThrows (FailingHttpStatusCodeException .class , submitButton ::click );
209205 assertEquals (302 , exception .getStatusCode ());
210206
211207 WebResponse response = exception .getResponse ();
212208 assertNotNull (response );
213209
214210 String callbackLocation = response .getResponseHeaderValue ("Location" );
215211 assertTrue (callbackLocation .startsWith (callbackUrl ));
216- //System.out.println(callbackLocation);
217-
212+
218213 String queryPart = callbackLocation .trim ().split ("\\ ?" )[1 ];
219214 Map <String ,String > parameters = Pattern .compile ("\\ s*&\\ s*" )
220215 .splitAsStream (queryPart )
221216 .map (s -> s .split ("=" , 2 ))
222217 .collect (Collectors .toMap (a -> a [0 ], a -> a .length > 1 ? a [1 ]: "" ));
223- //System.out.println(map);
218+
224219 assertTrue (parameters .containsKey ("code" ));
225220 assertTrue (parameters .containsKey ("state" ));
226221
@@ -237,4 +232,4 @@ void testAuthorizationCodeFlowWithPKCE() throws Exception {
237232 throw e ;
238233 }
239234 }
240- }
235+ }
0 commit comments