-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent using studielink in remote-creation API
- Loading branch information
Showing
5 changed files
with
53 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,7 @@ void eduIDForInstitutionBrinCodeNotExists() { | |
|
||
@Test | ||
void createEduIDHappyFlow() { | ||
StudieLinkEduID studieLinkEduID = new StudieLinkEduID( | ||
ExternalEduID externalEduID = new ExternalEduID( | ||
"[email protected]", | ||
null, | ||
"Mary", | ||
|
@@ -145,15 +145,15 @@ void createEduIDHappyFlow() { | |
Verification.Decentraal, | ||
null | ||
); | ||
StudieLinkEduID studieLinkEduIdResult = given() | ||
ExternalEduID externalEduIDResult = given() | ||
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduID) | ||
.body(externalEduID) | ||
.post("/api/remote-creation/eduid-create") | ||
.as(new TypeRef<>() { | ||
}); | ||
String eduIDValue = studieLinkEduIdResult.getEduIDValue(); | ||
String eduIDValue = externalEduIDResult.getEduIDValue(); | ||
User user = userRepository.findByEduIDS_value(eduIDValue).get(); | ||
EduID newEduID = user.getEduIDS().stream() | ||
.filter(anEduID -> anEduID.getValue().equals(eduIDValue)) | ||
|
@@ -169,7 +169,7 @@ void createEduIDHappyFlow() { | |
|
||
@Test | ||
void createEduIDConflict() { | ||
StudieLinkEduID studieLinkEduID = new StudieLinkEduID( | ||
ExternalEduID externalEduID = new ExternalEduID( | ||
email, | ||
null, | ||
"Mary", | ||
|
@@ -185,15 +185,15 @@ void createEduIDConflict() { | |
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduID) | ||
.body(externalEduID) | ||
.post("/api/remote-creation/eduid-create") | ||
.then() | ||
.statusCode(HttpStatus.CONFLICT.value()); | ||
} | ||
|
||
@Test | ||
void createEduIDBadRequest() { | ||
StudieLinkEduID studieLinkEduID = new StudieLinkEduID( | ||
ExternalEduID externalEduID = new ExternalEduID( | ||
null, | ||
null, | ||
"Mary", | ||
|
@@ -209,15 +209,15 @@ void createEduIDBadRequest() { | |
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduID) | ||
.body(externalEduID) | ||
.post("/api/remote-creation/eduid-create") | ||
.then() | ||
.statusCode(HttpStatus.BAD_REQUEST.value()); | ||
} | ||
|
||
@Test | ||
void updateEduIDHappyFlow() { | ||
StudieLinkEduID studieLinkEduID = new StudieLinkEduID( | ||
ExternalEduID externalEduID = new ExternalEduID( | ||
"[email protected]", | ||
null, | ||
"Mary", | ||
|
@@ -229,33 +229,33 @@ void updateEduIDHappyFlow() { | |
Verification.Decentraal, | ||
null | ||
); | ||
StudieLinkEduID studieLinkEduIdResult = given() | ||
ExternalEduID externaalEduIDResult = given() | ||
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduID) | ||
.body(externalEduID) | ||
.post("/api/remote-creation/eduid-create") | ||
.as(new TypeRef<>() { | ||
}); | ||
studieLinkEduIdResult.setBrinCode("QWER"); | ||
externaalEduIDResult.setBrinCode("QWER"); | ||
given() | ||
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduIdResult) | ||
.body(externaalEduIDResult) | ||
.put("/api/remote-creation/eduid-update") | ||
.as(new TypeRef<>() { | ||
}); | ||
String eduIDValue = studieLinkEduIdResult.getEduIDValue(); | ||
String eduIDValue = externaalEduIDResult.getEduIDValue(); | ||
User user = userRepository.findByEduIDS_value(eduIDValue).get(); | ||
|
||
assertEquals(1, user.getExternalLinkedAccounts().size()); | ||
assertEquals(studieLinkEduIdResult.getBrinCode(), user.getExternalLinkedAccounts().get(0).getBrinCode()); | ||
assertEquals(externaalEduIDResult.getBrinCode(), user.getExternalLinkedAccounts().get(0).getBrinCode()); | ||
} | ||
|
||
@Test | ||
void updateEduIDNotFound() { | ||
StudieLinkEduID studieLinkEduID = new StudieLinkEduID( | ||
ExternalEduID externalEduID = new ExternalEduID( | ||
"[email protected]", | ||
null, | ||
"Mary", | ||
|
@@ -267,28 +267,28 @@ void updateEduIDNotFound() { | |
Verification.Decentraal, | ||
null | ||
); | ||
StudieLinkEduID studieLinkEduIdResult = given() | ||
ExternalEduID externalEduIDResult = given() | ||
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduID) | ||
.body(externalEduID) | ||
.post("/api/remote-creation/eduid-create") | ||
.as(new TypeRef<>() { | ||
}); | ||
studieLinkEduIdResult.setEduIDValue(UUID.randomUUID().toString()); | ||
externalEduIDResult.setEduIDValue(UUID.randomUUID().toString()); | ||
given() | ||
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduIdResult) | ||
.body(externalEduIDResult) | ||
.put("/api/remote-creation/eduid-update") | ||
.then() | ||
.statusCode(HttpStatus.NOT_FOUND.value()); | ||
} | ||
|
||
@Test | ||
void updateEduIDExternalAccountGone() { | ||
StudieLinkEduID studieLinkEduID = new StudieLinkEduID( | ||
ExternalEduID externalEduID = new ExternalEduID( | ||
"[email protected]", | ||
null, | ||
"Mary", | ||
|
@@ -300,16 +300,16 @@ void updateEduIDExternalAccountGone() { | |
Verification.Decentraal, | ||
null | ||
); | ||
StudieLinkEduID studieLinkEduIdResult = given() | ||
ExternalEduID externalEduIDResult = given() | ||
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduID) | ||
.body(externalEduID) | ||
.post("/api/remote-creation/eduid-create") | ||
.as(new TypeRef<>() { | ||
}); | ||
//Now delete the externalAccount | ||
String eduIDValue = studieLinkEduIdResult.getEduIDValue(); | ||
String eduIDValue = externalEduIDResult.getEduIDValue(); | ||
User user = userRepository.findByEduIDS_value(eduIDValue).get(); | ||
user.getExternalLinkedAccounts().clear(); | ||
userRepository.save(user); | ||
|
@@ -318,7 +318,7 @@ void updateEduIDExternalAccountGone() { | |
.when() | ||
.auth().preemptive().basic(userName, password) | ||
.contentType(ContentType.JSON) | ||
.body(studieLinkEduIdResult) | ||
.body(externalEduIDResult) | ||
.put("/api/remote-creation/eduid-update") | ||
.then() | ||
.statusCode(HttpStatus.GONE.value()); | ||
|