Skip to content

Commit

Permalink
Path parameter is missing in the get account endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroigor committed Feb 15, 2022
1 parent 674fc3d commit 7da3953
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void init() {
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public UserRepresentation account(final @PathParam("userProfileMetadata") Boolean userProfileMetadata) {
public UserRepresentation account(final @QueryParam("userProfileMetadata") Boolean userProfileMetadata) {
auth.requireOneOf(AccountRoles.MANAGE_ACCOUNT, AccountRoles.VIEW_PROFILE);

UserModel user = auth.getUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ public void testGetUserProfileMetadata_EditUsernameAllowed() throws IOException
assertUserProfileAttributeMetadata(user, "firstName", "${firstName}", true, false);
assertUserProfileAttributeMetadata(user, "lastName", "${lastName}", true, false);
}


@Test
public void testGetUserProfileWithoutMetadata() throws IOException {
UserRepresentation user = getUser(false);
assertNull(user.getUserProfileMetadata());
}

@Test
public void testGetUserProfileMetadata_EditUsernameDisallowed() throws IOException {

Expand Down Expand Up @@ -462,7 +468,13 @@ public void testUpdateProfileWithRegistrationEmailAsUsername() throws IOExceptio
}

protected UserRepresentation getUser() throws IOException {
SimpleHttp a = SimpleHttp.doGet(getAccountUrl(null), httpClient).auth(tokenUtil.getToken());
return getUser(true);
}

protected UserRepresentation getUser(boolean fetchMetadata) throws IOException {
String accountUrl = getAccountUrl(null) + "?userProfileMetadata=" + fetchMetadata;
SimpleHttp a = SimpleHttp.doGet(accountUrl, httpClient).auth(tokenUtil.getToken());

try {
return a.asJson(UserRepresentation.class);
} catch (IOException e) {
Expand Down

0 comments on commit 7da3953

Please sign in to comment.