Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update matchingPolicy #856

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import it.infn.mw.iam.persistence.model.IamGroup;
import it.infn.mw.iam.persistence.model.IamScopePolicy;
import it.infn.mw.iam.persistence.model.PolicyRule;
import it.infn.mw.iam.persistence.model.IamScopePolicy.MatchingPolicy;
import it.infn.mw.iam.persistence.repository.IamAccountRepository;
import it.infn.mw.iam.persistence.repository.IamGroupRepository;
import it.infn.mw.iam.persistence.repository.IamScopePolicyRepository;
Expand Down Expand Up @@ -547,6 +548,31 @@ public void testDefaultPolicyUpdate() throws Exception {
.andExpect(jsonPath("$.scopes").doesNotExist());

}

@Test
@WithMockOAuthUser(user = "admin", authorities = {"ROLE_USER", "ROLE_ADMIN"}, scopes = {"iam:admin.read", "iam:admin.write"})
public void testDefaultPolicyUpdateUpdatingMatchingPolicy() throws Exception {
final String description = "DENY ALL!";

ScopePolicyDTO sp = new ScopePolicyDTO();
sp.setDescription(description);
sp.setRule(PolicyRule.DENY.name());
sp.setMatchingPolicy(MatchingPolicy.PATH.name());
sp.setScopes(Sets.newHashSet(SCIM_READ, SCIM_WRITE));
sp.setId(1L);

String serializedSp = mapper.writeValueAsString(sp);
mvc.perform(put("/iam/scope_policies/1").content(serializedSp).contentType(APPLICATION_JSON))
.andExpect(status().isNoContent());

mvc.perform(get("/iam/scope_policies/1"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id", equalTo(1)))
.andExpect(jsonPath("$.rule", equalTo("DENY")))
.andExpect(jsonPath("$.description", equalTo(description)))
.andExpect(jsonPath("$.matchingPolicy", equalTo(MatchingPolicy.PATH.name())));

}

@Test
@WithMockOAuthUser(user = "admin", authorities = {"ROLE_USER", "ROLE_ADMIN"}, scopes = "iam:admin.write")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public void from(IamScopePolicy other) {
setDescription(other.getDescription());
setRule(other.getRule());
setScopes(other.getScopes());
setMatchingPolicy(other.getMatchingPolicy());
linkAccount();
linkGroup();
}
Expand Down
Loading