Skip to content

Commit 3879587

Browse files
committed
RDM-4369: Support reserved characters in userId email address
Ensure `GET` request to `/user-profile/users` endpoint uses a fully encoded URL, to allow reserved characters in the `uid` query parameter.
1 parent bcd4a51 commit 3879587

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/java/uk/gov/hmcts/ccd/data/user/DefaultUserRepositoryTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.net.URI;
44
import java.util.Arrays;
55
import java.util.Collection;
6+
import java.util.Collections;
67
import java.util.Set;
78
import java.util.stream.Collectors;
89

@@ -30,6 +31,7 @@
3031
import org.junit.jupiter.api.DisplayName;
3132
import org.junit.jupiter.api.Nested;
3233
import org.junit.jupiter.api.Test;
34+
import org.mockito.ArgumentCaptor;
3335
import org.mockito.InjectMocks;
3436
import org.mockito.Mock;
3537
import org.mockito.MockitoAnnotations;
@@ -240,6 +242,12 @@ void shouldThrowExceptionIfErrorOnRetrievingUserProfile() {
240242
() -> userRepository.getUserDefaultSettings(userId),
241243
"Expected getUserDefaultSettings() to throw, but it didn't");
242244
assertThat(serviceException.getMessage(), is("Problem getting user default settings for " + userId));
245+
246+
// Check that the URL used in the request is encoded correctly, specifically the query string
247+
ArgumentCaptor<String> requestUrl = ArgumentCaptor.forClass(String.class);
248+
verify(restTemplate).exchange(
249+
requestUrl.capture(), same(HttpMethod.GET), any(HttpEntity.class), (Class<?>)any(Class.class));
250+
assertThat(requestUrl.getValue(), is("http://test.hmcts.net/users?uid=ccd%2Btest%40hmcts.net"));
243251
}
244252
}
245253

0 commit comments

Comments
 (0)