Skip to content

Commit 7da3953

Browse files
committed
Path parameter is missing in the get account endpoint
Closes keycloak#10055
1 parent 674fc3d commit 7da3953

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

services/src/main/java/org/keycloak/services/resources/account/AccountRestService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void init() {
138138
@GET
139139
@Produces(MediaType.APPLICATION_JSON)
140140
@NoCache
141-
public UserRepresentation account(final @PathParam("userProfileMetadata") Boolean userProfileMetadata) {
141+
public UserRepresentation account(final @QueryParam("userProfileMetadata") Boolean userProfileMetadata) {
142142
auth.requireOneOf(AccountRoles.MANAGE_ACCOUNT, AccountRoles.VIEW_PROFILE);
143143

144144
UserModel user = auth.getUser();

testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/AccountRestServiceTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ public void testGetUserProfileMetadata_EditUsernameAllowed() throws IOException
106106
assertUserProfileAttributeMetadata(user, "firstName", "${firstName}", true, false);
107107
assertUserProfileAttributeMetadata(user, "lastName", "${lastName}", true, false);
108108
}
109-
109+
110+
@Test
111+
public void testGetUserProfileWithoutMetadata() throws IOException {
112+
UserRepresentation user = getUser(false);
113+
assertNull(user.getUserProfileMetadata());
114+
}
115+
110116
@Test
111117
public void testGetUserProfileMetadata_EditUsernameDisallowed() throws IOException {
112118

@@ -462,7 +468,13 @@ public void testUpdateProfileWithRegistrationEmailAsUsername() throws IOExceptio
462468
}
463469

464470
protected UserRepresentation getUser() throws IOException {
465-
SimpleHttp a = SimpleHttp.doGet(getAccountUrl(null), httpClient).auth(tokenUtil.getToken());
471+
return getUser(true);
472+
}
473+
474+
protected UserRepresentation getUser(boolean fetchMetadata) throws IOException {
475+
String accountUrl = getAccountUrl(null) + "?userProfileMetadata=" + fetchMetadata;
476+
SimpleHttp a = SimpleHttp.doGet(accountUrl, httpClient).auth(tokenUtil.getToken());
477+
466478
try {
467479
return a.asJson(UserRepresentation.class);
468480
} catch (IOException e) {

0 commit comments

Comments
 (0)