-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix for backward compatible new mobile API
- Loading branch information
Showing
9 changed files
with
44 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,21 +256,20 @@ public void relayState() throws IOException { | |
|
||
@Test | ||
public void updateUser() { | ||
User user = userRepository.findOneUserByEmail("[email protected]"); | ||
user.setGivenName("Mary"); | ||
user.setFamilyName("Poppins"); | ||
UpdateUserNameRequest updateUserNameRequest = new UpdateUserNameRequest("chosenName", "Mary", "Poppins"); | ||
given() | ||
.when() | ||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) | ||
.body(user) | ||
.body(updateUserNameRequest) | ||
.put("/myconext/api/sp/update") | ||
.then() | ||
.statusCode(HttpStatus.CREATED.value()); | ||
|
||
User userFromDB = userRepository.findOneUserByEmail("[email protected]"); | ||
|
||
assertEquals(user.getGivenName(), userFromDB.getGivenName()); | ||
assertEquals(user.getFamilyName(), userFromDB.getFamilyName()); | ||
//Has linked accounts, so no update | ||
assertEquals(userFromDB.getGivenName(), "John"); | ||
assertEquals(userFromDB.getFamilyName(), "Doe"); | ||
assertEquals(userFromDB.getChosenName(), updateUserNameRequest.getChosenName()); | ||
} | ||
|
||
@Test | ||
|
@@ -362,17 +361,6 @@ public void removeUserService() { | |
assertFalse(userFromDB.getEduIDS().stream().anyMatch(val -> val.getServiceProviderEntityId().equals(("http://mock-sp")))); | ||
} | ||
|
||
@Test | ||
public void updateUser403() { | ||
given() | ||
.when() | ||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) | ||
.body(new User()) | ||
.put("/myconext/api/sp/update") | ||
.then() | ||
.statusCode(400); | ||
} | ||
|
||
@Test | ||
public void updateUserWeakPassword() { | ||
User user = userRepository.findOneUserByEmail("[email protected]"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,23 +35,40 @@ public void me() throws IOException { | |
|
||
@Test | ||
public void updateUserProfile() throws IOException { | ||
UpdateUserNameRequest userNameRequest = new UpdateUserNameRequest("CallName", "Mary", "Winters"); | ||
UpdateUserNameRequest userNameRequest = new UpdateUserNameRequest("Annie", "Anna", "Winters"); | ||
given() | ||
.when() | ||
.accept(ContentType.JSON) | ||
.contentType(ContentType.JSON) | ||
.auth().oauth2(opaqueAccessToken(true, "eduid.nl/mobile")) | ||
.auth().oauth2(doOpaqueAccessToken(true, new String[] {"eduid.nl/mobile"}, "introspect_no_linked_accounts")) | ||
.body(userNameRequest) | ||
.put("/mobile/api/sp/update") | ||
.then() | ||
.statusCode(201); | ||
User user = userRepository.findUserByEmail("jdoe@example.com").get(); | ||
User user = userRepository.findUserByEmail("mdoe@example.com").get(); | ||
|
||
assertEquals(userNameRequest.getChosenName(), user.getChosenName()); | ||
assertEquals(userNameRequest.getGivenName(), user.getGivenName()); | ||
assertEquals(userNameRequest.getFamilyName(), user.getFamilyName()); | ||
} | ||
|
||
@Test | ||
public void updateUserProfileOldAPI() throws IOException { | ||
UpdateUserNameRequest userNameRequest = new UpdateUserNameRequest(null, "Anna", null); | ||
given() | ||
.when() | ||
.accept(ContentType.JSON) | ||
.contentType(ContentType.JSON) | ||
.auth().oauth2(doOpaqueAccessToken(true, new String[] {"eduid.nl/mobile"}, "introspect_no_linked_accounts")) | ||
.body(userNameRequest) | ||
.put("/mobile/api/sp/update") | ||
.then() | ||
.statusCode(201); | ||
User user = userRepository.findUserByEmail("[email protected]").get(); | ||
|
||
assertEquals(userNameRequest.getGivenName(), user.getChosenName()); | ||
} | ||
|
||
@Test | ||
public void institutionNames() throws IOException { | ||
Map names = given() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters