SEC-1898: Added test to demonstrate JdbcAclService#readAclById throws NotFoundException when the Acl is missing
This commit is contained in:
parent
520b65e2e3
commit
6584b65489
|
@ -0,0 +1,50 @@
|
||||||
|
package org.springframework.security.acls.jdbc;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.anyListOf;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
import org.springframework.security.acls.domain.ObjectIdentityImpl;
|
||||||
|
import org.springframework.security.acls.domain.PrincipalSid;
|
||||||
|
import org.springframework.security.acls.model.Acl;
|
||||||
|
import org.springframework.security.acls.model.NotFoundException;
|
||||||
|
import org.springframework.security.acls.model.ObjectIdentity;
|
||||||
|
import org.springframework.security.acls.model.Sid;
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class JdbcAclServiceTests {
|
||||||
|
@Mock
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private LookupStrategy lookupStrategy;
|
||||||
|
|
||||||
|
private JdbcAclService aclService;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
aclService = new JdbcAclService(dataSource, lookupStrategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SEC-1898
|
||||||
|
@Test(expected = NotFoundException.class)
|
||||||
|
public void readAclByIdMissingAcl() {
|
||||||
|
Map<ObjectIdentity, Acl> result = new HashMap<ObjectIdentity, Acl>();
|
||||||
|
when(lookupStrategy.readAclsById(anyListOf(ObjectIdentity.class), anyListOf(Sid.class))).thenReturn(result);
|
||||||
|
ObjectIdentity objectIdentity = new ObjectIdentityImpl(Object.class, 1);
|
||||||
|
List<Sid> sids = Arrays.<Sid> asList(new PrincipalSid("user"));
|
||||||
|
|
||||||
|
aclService.readAclById(objectIdentity, sids);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue