20
20
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .redirectedUrl ;
21
21
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
22
22
23
+ import java .net .URLEncoder ;
24
+ import java .nio .charset .StandardCharsets ;
23
25
import java .sql .SQLException ;
24
26
import java .util .ArrayList ;
25
27
import java .util .List ;
@@ -144,7 +146,8 @@ public void shouldReturnUserWithoutEmailException() throws Exception {
144
146
.header ("Shib-Identity-Provider" , IDP_TEST_EPERSON ))
145
147
.andExpect (status ().isFound ())
146
148
.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 )));
148
151
}
149
152
150
153
/**
@@ -170,7 +173,8 @@ public void userFillInEmailAndShouldBeRegisteredByVerificationToken() throws Exc
170
173
.header ("SHIB-NETID" , netId ))
171
174
.andExpect (status ().isFound ())
172
175
.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 )));
174
178
175
179
// Send the email with the verification token.
176
180
String tokenAdmin = getAuthToken (admin .getEmail (), password );
@@ -618,7 +622,8 @@ public void shouldAskForEmailWhenHasPersistentId() throws Exception {
618
622
.header (NET_ID_PERSISTENT_ID , persistentId ))
619
623
.andExpect (status ().isFound ())
620
624
.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 )));
622
627
}
623
628
624
629
// 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
636
641
.header ("SHIB-NETID" , netId ))
637
642
.andExpect (status ().isFound ())
638
643
.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 )));
640
646
641
647
// Send the email with the verification token.
642
648
String tokenAdmin = getAuthToken (admin .getEmail (), password );
@@ -655,7 +661,8 @@ public void shouldNotAuthenticateOnSecondAttemptWithoutVerificationTokenInReques
655
661
.header ("SHIB-NETID" , netId ))
656
662
.andExpect (status ().isFound ())
657
663
.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 )));
659
666
}
660
667
661
668
@ Test
0 commit comments