Skip to content

Commit

Permalink
fix: solve sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed Nov 29, 2024
1 parent eff8b87 commit ef3cdce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ public boolean isStructureContributor(String structureId){
public boolean isStructureAndComponentContributor(String body) {
logger.trace("Check if {} can create the structure or component", methodSecurityExpressionRoot.getPrincipal());
Optional<Stamp> stamp = getStamp();
return hasRole(Roles.STRUCTURES_CONTRIBUTOR) && extractContributorStampsFromBody(body).toList().stream().anyMatch(s -> ((String) s).equalsIgnoreCase(stamp.get().stamp()));
JSONArray contributors = extractContributorStampsFromBody(body);

if(contributors == null){
return false;
}
return hasRole(Roles.STRUCTURES_CONTRIBUTOR) && contributors.toList().stream().anyMatch(s -> ((String) s).equalsIgnoreCase(stamp.get().stamp()));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import fr.insee.rmes.config.auth.security.DefaultSecurityContext;
import fr.insee.rmes.config.auth.security.OpenIDConnectSecurityContext;
import fr.insee.rmes.config.auth.user.Stamp;
import fr.insee.rmes.model.ValidationStatus;
import fr.insee.rmes.webservice.StructureResources;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
Expand All @@ -28,7 +27,6 @@

import static fr.insee.rmes.integration.authorizations.TokenForTestsConfiguration.*;
import static fr.insee.rmes.integration.authorizations.TokenForTestsConfiguration.KEY_FOR_ROLES_IN_ROLE_CLAIM;
import static fr.insee.rmes.model.ValidationStatus.UNPUBLISHED;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand Down

0 comments on commit ef3cdce

Please sign in to comment.