Skip to content

Commit

Permalink
Email is optional and return status 201 for POST and PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jun 17, 2024
1 parent c1de661 commit 8a9a34d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
@Setter
public class ExternalEduID implements Serializable {

@NotBlank
private String email;

@Schema(description = "Will be generated by the eduID API")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public ResponseEntity<ExternalEduID> createEduID(@Parameter(hidden = true) @Auth
userRepository.save(user);
mailBox.sendAccountConfirmation(user);

return ResponseEntity.ok(externalEduID);
return ResponseEntity.status(HttpStatus.CREATED).body(externalEduID);
}

@PutMapping(value = {"/eduid-update"})
Expand Down Expand Up @@ -269,7 +269,7 @@ public ResponseEntity<ExternalEduID> updateEduID(@Parameter(hidden = true) @Auth

userRepository.save(user);

return ResponseEntity.ok(externalEduID);
return ResponseEntity.status(HttpStatus.CREATED).body(externalEduID);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void createEduIDBadRequest() {
.extract()
.as(new TypeRef<>() {
});
assertEquals(Stream.of("chosenName", "email", "identifier", "lastName", "verification").sorted().collect(Collectors.toList()),
assertEquals(Stream.of("chosenName", "identifier", "lastName", "verification").sorted().collect(Collectors.toList()),
((List<Map<String, Object>>) errorResult.get("errors")).stream().map(m -> m.get("field")).sorted().collect(Collectors.toList()));
}

Expand Down Expand Up @@ -273,6 +273,9 @@ void updateEduIDHappyFlowWithNewUser() {
.contentType(ContentType.JSON)
.body(externalEduID)
.post("/api/remote-creation/eduid-create")
.then()
.statusCode(201)
.extract()
.as(new TypeRef<>() {
});
externalEduIDResult.setBrinCode("QWER");
Expand All @@ -283,6 +286,9 @@ void updateEduIDHappyFlowWithNewUser() {
.contentType(ContentType.JSON)
.body(externalEduIDResult)
.put("/api/remote-creation/eduid-update")
.then()
.statusCode(HttpStatus.CREATED.value())
.extract()
.as(new TypeRef<>() {
});
String eduIDValue = externalEduIDResult.getEduIDValue();
Expand Down Expand Up @@ -314,6 +320,9 @@ void updateEduIDHappyFlowWithExistingUser() {
.contentType(ContentType.JSON)
.body(externalEduID)
.put("/api/remote-creation/eduid-update")
.then()
.statusCode(HttpStatus.CREATED.value())
.extract()
.as(new TypeRef<>() {
});
String eduIDValue = updatedExternalEduID.getEduIDValue();
Expand Down Expand Up @@ -358,6 +367,9 @@ void updateEduIDNotFound() {
.contentType(ContentType.JSON)
.body(externalEduID)
.post("/api/remote-creation/eduid-create")
.then()
.statusCode(HttpStatus.CREATED.value())
.extract()
.as(new TypeRef<>() {
});
externalEduIDResult.setEduIDValue(UUID.randomUUID().toString());
Expand Down Expand Up @@ -392,6 +404,9 @@ void updateEduIDExternalAccountGone() {
.contentType(ContentType.JSON)
.body(externalEduID)
.post("/api/remote-creation/eduid-create")
.then()
.statusCode(HttpStatus.CREATED.value())
.extract()
.as(new TypeRef<>() {
});
//Now delete the externalAccount
Expand Down Expand Up @@ -430,6 +445,9 @@ void updateEduIDExternalAccountUpdateIdemPotent() {
.contentType(ContentType.JSON)
.body(externalEduID)
.post("/api/remote-creation/eduid-create")
.then()
.statusCode(HttpStatus.CREATED.value())
.extract()
.as(new TypeRef<>() {
});
String eduIDValue = externalEduIDResult.getEduIDValue();
Expand Down

0 comments on commit 8a9a34d

Please sign in to comment.