Search in sources :

Example 1 with SidRetrievalStrategyImpl

use of org.springframework.security.acls.domain.SidRetrievalStrategyImpl in project spring-security by spring-projects.

the class SidRetrievalStrategyTests method roleHierarchyIsUsedWhenSet.

@Test
public void roleHierarchyIsUsedWhenSet() {
    RoleHierarchy rh = mock(RoleHierarchy.class);
    List rhAuthorities = AuthorityUtils.createAuthorityList("D");
    given(rh.getReachableGrantedAuthorities(anyCollection())).willReturn(rhAuthorities);
    SidRetrievalStrategy strat = new SidRetrievalStrategyImpl(rh);
    List<Sid> sids = strat.getSids(this.authentication);
    assertThat(sids).hasSize(2);
    assertThat(sids.get(0)).isNotNull();
    assertThat(sids.get(0) instanceof PrincipalSid).isTrue();
    assertThat(((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority()).isEqualTo("D");
}
Also used : SidRetrievalStrategyImpl(org.springframework.security.acls.domain.SidRetrievalStrategyImpl) GrantedAuthoritySid(org.springframework.security.acls.domain.GrantedAuthoritySid) RoleHierarchy(org.springframework.security.access.hierarchicalroles.RoleHierarchy) List(java.util.List) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) SidRetrievalStrategy(org.springframework.security.acls.model.SidRetrievalStrategy) Sid(org.springframework.security.acls.model.Sid) GrantedAuthoritySid(org.springframework.security.acls.domain.GrantedAuthoritySid) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) Test(org.junit.jupiter.api.Test)

Example 2 with SidRetrievalStrategyImpl

use of org.springframework.security.acls.domain.SidRetrievalStrategyImpl in project spring-security by spring-projects.

the class SidRetrievalStrategyTests method correctSidsAreRetrieved.

@Test
public void correctSidsAreRetrieved() {
    SidRetrievalStrategy retrStrategy = new SidRetrievalStrategyImpl();
    List<Sid> sids = retrStrategy.getSids(this.authentication);
    assertThat(sids).isNotNull();
    assertThat(sids).hasSize(4);
    assertThat(sids.get(0)).isNotNull();
    assertThat(sids.get(0) instanceof PrincipalSid).isTrue();
    for (int i = 1; i < sids.size(); i++) {
        assertThat(sids.get(i) instanceof GrantedAuthoritySid).isTrue();
    }
    assertThat(((PrincipalSid) sids.get(0)).getPrincipal()).isEqualTo("scott");
    assertThat(((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority()).isEqualTo("A");
    assertThat(((GrantedAuthoritySid) sids.get(2)).getGrantedAuthority()).isEqualTo("B");
    assertThat(((GrantedAuthoritySid) sids.get(3)).getGrantedAuthority()).isEqualTo("C");
}
Also used : SidRetrievalStrategyImpl(org.springframework.security.acls.domain.SidRetrievalStrategyImpl) GrantedAuthoritySid(org.springframework.security.acls.domain.GrantedAuthoritySid) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) SidRetrievalStrategy(org.springframework.security.acls.model.SidRetrievalStrategy) Sid(org.springframework.security.acls.model.Sid) GrantedAuthoritySid(org.springframework.security.acls.domain.GrantedAuthoritySid) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 GrantedAuthoritySid (org.springframework.security.acls.domain.GrantedAuthoritySid)2 PrincipalSid (org.springframework.security.acls.domain.PrincipalSid)2 SidRetrievalStrategyImpl (org.springframework.security.acls.domain.SidRetrievalStrategyImpl)2 Sid (org.springframework.security.acls.model.Sid)2 SidRetrievalStrategy (org.springframework.security.acls.model.SidRetrievalStrategy)2 List (java.util.List)1 RoleHierarchy (org.springframework.security.access.hierarchicalroles.RoleHierarchy)1