use of org.apache.jackrabbit.oak.spi.security.principal.TestPrincipalProvider in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetPrincipals.
@Test
public void testGetPrincipals() {
PrincipalProvider principalProvider = new TestPrincipalProvider();
AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(principalProvider));
Principal principal = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP).next();
String userId = TestPrincipalProvider.getIDFromPrincipal(principal);
Set<? extends Principal> principals = loginModule.getPrincipals(userId);
assertFalse(principals.isEmpty());
assertEquals(principalProvider.getPrincipals(userId), principals);
}
use of org.apache.jackrabbit.oak.spi.security.principal.TestPrincipalProvider in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetPrincipalProviderFromCallback.
@Test
public void testGetPrincipalProviderFromCallback() {
AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(new TestPrincipalProvider()));
assertNotNull(loginModule.getPrincipalProvider());
PrincipalProvider principalProvider = loginModule.getPrincipalProvider();
assertNotNull(principalProvider);
// principalProvider is stored as field -> second access returns the same object
assertSame(principalProvider, loginModule.getPrincipalProvider());
}
use of org.apache.jackrabbit.oak.spi.security.principal.TestPrincipalProvider in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetPrincipalsFromPrincipal.
@Test
public void testGetPrincipalsFromPrincipal() {
PrincipalProvider principalProvider = new TestPrincipalProvider();
AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(principalProvider));
Principal principal = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP).next();
Set<Principal> expected = new HashSet<>();
expected.add(principal);
expected.addAll(principalProvider.getGroupMembership(principal));
Set<? extends Principal> principals = loginModule.getPrincipals(principal);
assertFalse(principals.isEmpty());
assertEquals(expected, principals);
}
Aggregations