Skip to content

Commit

Permalink
[BUG] searching-groups-on-a-non-existing-application-result-in-500-er…
Browse files Browse the repository at this point in the history
…ror (776)

Signed-off-by: Sommer Le <[email protected]>
  • Loading branch information
fjr3o6 committed May 30, 2023
1 parent cf866d4 commit d51edec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import fr.insee.sugoi.core.model.ProviderResponse;
import fr.insee.sugoi.core.model.ProviderResponse.ProviderResponseStatus;
import fr.insee.sugoi.core.model.SugoiUser;
import fr.insee.sugoi.core.service.ApplicationService;
import fr.insee.sugoi.core.service.GroupService;
import fr.insee.sugoi.model.Group;
import fr.insee.sugoi.model.exceptions.ApplicationNotFoundException;
import fr.insee.sugoi.model.exceptions.IdNotMatchingException;
import fr.insee.sugoi.model.paging.PageResult;
import fr.insee.sugoi.model.paging.PageableResult;
Expand Down Expand Up @@ -67,6 +69,8 @@ public class GroupController {

@Autowired private GroupService groupService;

@Autowired private ApplicationService applicationService;

@GetMapping(
path = {"/realms/{realm}/applications/{application}/groups"},
produces = {MediaType.APPLICATION_JSON_VALUE})
Expand Down Expand Up @@ -111,8 +115,14 @@ public ResponseEntity<PageResult<Group>> getGroups(
filterGroup.setName(name);
filterGroup.setDescription(description);
PageableResult pageableResult = new PageableResult(size, offset, searchCookie);
PageResult<Group> foundGroups = null;
try {
applicationService.findById(realm, applicationName);

PageResult<Group> foundGroups =
} catch (ApplicationNotFoundException e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
foundGroups =
groupService.findByProperties(realm, applicationName, filterGroup, pageableResult);

if (foundGroups.isHasMoreResult()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import fr.insee.sugoi.commons.services.controller.technics.SugoiAdviceController;
import fr.insee.sugoi.core.model.ProviderResponse;
import fr.insee.sugoi.core.model.ProviderResponse.ProviderResponseStatus;
import fr.insee.sugoi.core.service.ApplicationService;
import fr.insee.sugoi.core.service.GroupService;
import fr.insee.sugoi.model.Group;
import fr.insee.sugoi.model.exceptions.GroupAlreadyExistException;
Expand Down Expand Up @@ -58,6 +59,8 @@ public class GroupControllerTest {

@MockBean private GroupService groupService;

@MockBean private ApplicationService applicationService;

ObjectMapper objectMapper = new ObjectMapper();
Group group1, group2, group2Updated;
PageResult<Group> pageResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Feature: Groups scenario admin
Then the client receives status code 200
Then the client expect to receive a list of groups

Scenario: Get groups application not exist
When the client perform GET request on url /realms/domaine1/applications/non/groups
Then the client receives status code 404

Scenario: Get group
When the client perform GET request on url /realms/domaine1/applications/applitest/groups/Administrateurs_AppliTest
And show body received
Expand All @@ -22,6 +26,10 @@ Feature: Groups scenario admin
And show body received
Then the client receives status code 200

Scenario: Get group application not exist
When the client perform GET request on url /realms/domaine1/applications/non/groups/Administrateurs_AppliTest
Then the client receives status code 404

Scenario: Post group
When the client perform POST request with body on url /realms/domaine1/applications/applitest/groups body:
"""
Expand Down

0 comments on commit d51edec

Please sign in to comment.