1
+ package org .springframework .security .acls .jdbc ;
2
+
3
+ import static org .mockito .Matchers .anyListOf ;
4
+ import static org .mockito .Mockito .when ;
5
+
6
+ import java .util .Arrays ;
7
+ import java .util .HashMap ;
8
+ import java .util .List ;
9
+ import java .util .Map ;
10
+
11
+ import javax .sql .DataSource ;
12
+
13
+ import org .junit .Before ;
14
+ import org .junit .Test ;
15
+ import org .junit .runner .RunWith ;
16
+ import org .mockito .Mock ;
17
+ import org .mockito .runners .MockitoJUnitRunner ;
18
+ import org .springframework .security .acls .domain .ObjectIdentityImpl ;
19
+ import org .springframework .security .acls .domain .PrincipalSid ;
20
+ import org .springframework .security .acls .model .Acl ;
21
+ import org .springframework .security .acls .model .NotFoundException ;
22
+ import org .springframework .security .acls .model .ObjectIdentity ;
23
+ import org .springframework .security .acls .model .Sid ;
24
+
25
+ @ RunWith (MockitoJUnitRunner .class )
26
+ public class JdbcAclServiceTests {
27
+ @ Mock
28
+ private DataSource dataSource ;
29
+
30
+ @ Mock
31
+ private LookupStrategy lookupStrategy ;
32
+
33
+ private JdbcAclService aclService ;
34
+
35
+ @ Before
36
+ public void setUp () {
37
+ aclService = new JdbcAclService (dataSource , lookupStrategy );
38
+ }
39
+
40
+ // SEC-1898
41
+ @ Test (expected = NotFoundException .class )
42
+ public void readAclByIdMissingAcl () {
43
+ Map <ObjectIdentity , Acl > result = new HashMap <ObjectIdentity , Acl >();
44
+ when (lookupStrategy .readAclsById (anyListOf (ObjectIdentity .class ), anyListOf (Sid .class ))).thenReturn (result );
45
+ ObjectIdentity objectIdentity = new ObjectIdentityImpl (Object .class , 1 );
46
+ List <Sid > sids = Arrays .<Sid > asList (new PrincipalSid ("user" ));
47
+
48
+ aclService .readAclById (objectIdentity , sids );
49
+ }
50
+ }
0 commit comments