2020import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .redirectedUrl ;
2121import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
2222
23+ import java .net .URLEncoder ;
24+ import java .nio .charset .StandardCharsets ;
2325import java .sql .SQLException ;
2426import java .util .ArrayList ;
2527import java .util .List ;
@@ -144,7 +146,8 @@ public void shouldReturnUserWithoutEmailException() throws Exception {
144146 .header ("Shib-Identity-Provider" , IDP_TEST_EPERSON ))
145147 .andExpect (status ().isFound ())
146148 .andExpect (redirectedUrl ("http://localhost:4000/login/auth-failed?netid=" +
147- Util .formatNetId (netId , IDP_TEST_EPERSON )));
149+ URLEncoder .encode (Objects .requireNonNull (Util .formatNetId (netId , IDP_TEST_EPERSON )),
150+ StandardCharsets .UTF_8 )));
148151 }
149152
150153 /**
@@ -170,7 +173,8 @@ public void userFillInEmailAndShouldBeRegisteredByVerificationToken() throws Exc
170173 .header ("SHIB-NETID" , netId ))
171174 .andExpect (status ().isFound ())
172175 .andExpect (redirectedUrl ("http://localhost:4000/login/auth-failed?netid=" +
173- Util .formatNetId (netId , idp )));
176+ URLEncoder .encode (Objects .requireNonNull (Util .formatNetId (netId , idp )),
177+ StandardCharsets .UTF_8 )));
174178
175179 // Send the email with the verification token.
176180 String tokenAdmin = getAuthToken (admin .getEmail (), password );
@@ -618,7 +622,8 @@ public void shouldAskForEmailWhenHasPersistentId() throws Exception {
618622 .header (NET_ID_PERSISTENT_ID , persistentId ))
619623 .andExpect (status ().isFound ())
620624 .andExpect (redirectedUrl ("http://localhost:4000/login/auth-failed?netid=" +
621- Util .formatNetId (persistentId , IDP_TEST_EPERSON )));
625+ URLEncoder .encode (Objects .requireNonNull (Util .formatNetId (persistentId , IDP_TEST_EPERSON )),
626+ StandardCharsets .UTF_8 )));
622627 }
623628
624629 // The user was registered and signed in with the verification token on the second attempt, after the email
@@ -636,7 +641,8 @@ public void shouldNotAuthenticateOnSecondAttemptWithoutVerificationTokenInReques
636641 .header ("SHIB-NETID" , netId ))
637642 .andExpect (status ().isFound ())
638643 .andExpect (redirectedUrl ("http://localhost:4000/login/auth-failed?netid=" +
639- Util .formatNetId (netId , idp )));
644+ URLEncoder .encode (Objects .requireNonNull (Util .formatNetId (netId , idp )),
645+ StandardCharsets .UTF_8 )));
640646
641647 // Send the email with the verification token.
642648 String tokenAdmin = getAuthToken (admin .getEmail (), password );
@@ -655,7 +661,8 @@ public void shouldNotAuthenticateOnSecondAttemptWithoutVerificationTokenInReques
655661 .header ("SHIB-NETID" , netId ))
656662 .andExpect (status ().isFound ())
657663 .andExpect (redirectedUrl ("http://localhost:4000/login/auth-failed?netid=" +
658- Util .formatNetId (netId , idp )));
664+ URLEncoder .encode (Objects .requireNonNull (Util .formatNetId (netId , idp )),
665+ StandardCharsets .UTF_8 )));
659666 }
660667
661668 @ Test
0 commit comments