Ejemplo n.º 1
0
 @Test
 public void checkCreatingSimplePrincipalWithAttributes() {
   final PrincipalFactory f = new DefaultPrincipalFactory();
   final Principal p =
       f.createPrincipal("uid", Collections.singletonMap("mail", "*****@*****.**"));
   assertEquals(p.getId(), "uid");
   assertEquals(p.getAttributes().size(), 1);
   assertTrue(p.getAttributes().containsKey("mail"));
 }
Ejemplo n.º 2
0
 @Test
 public void checkCreatingSimplePrincipalWithDefaultRepository() {
   final PrincipalFactory f = new DefaultPrincipalFactory();
   final Principal p = f.createPrincipal("uid");
   assertEquals(p.getId(), "uid");
   assertEquals(p.getAttributes().size(), 0);
 }
 @Test
 public void verifyAttributesWithPrincipal() {
   final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver();
   resolver.setAttributeRepository(TestUtils.getAttributeRepository());
   resolver.setPrincipalAttributeName("cn");
   final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
   final Principal p = resolver.resolve(c);
   assertNotNull(p);
   assertNotEquals(p.getId(), TestUtils.CONST_USERNAME);
   assertTrue(p.getAttributes().containsKey("memberOf"));
 }