Search in sources :

Example 1 with AuthenticationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration in project jackrabbit-oak by apache.

the class InternalSecurityProviderTest method testSetAuthenticationConfiguration.

@Test
public void testSetAuthenticationConfiguration() {
    AuthenticationConfiguration ac = Mockito.mock(AuthenticationConfiguration.class);
    when(ac.getParameters()).thenReturn(PARAMS);
    securityProvider.setAuthenticationConfiguration(ac);
    assertSame(ac, securityProvider.getConfiguration(AuthenticationConfiguration.class));
    for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
        if (sc instanceof AuthenticationConfiguration) {
            assertSame(ac, sc);
        }
    }
    assertEquals(PARAMS, securityProvider.getParameters(AuthenticationConfiguration.NAME));
}
Also used : AuthenticationConfiguration(org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration) SecurityConfiguration(org.apache.jackrabbit.oak.spi.security.SecurityConfiguration) Test(org.junit.Test)

Example 2 with AuthenticationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration in project jackrabbit-oak by apache.

the class SecurityProviderImplTest method testUnBindAuthenticationConfiguration.

@Test
public void testUnBindAuthenticationConfiguration() {
    AuthenticationConfiguration ac = Mockito.mock(AuthenticationConfiguration.class);
    securityProvider.bindAuthenticationConfiguration(ac);
    securityProvider.unbindAuthenticationConfiguration(ac);
    assertNull(securityProvider.getConfiguration(AuthenticationConfiguration.class));
    for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
        if (sc instanceof AuthenticationConfiguration) {
            fail();
        }
    }
}
Also used : AuthenticationConfiguration(org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration) SecurityConfiguration(org.apache.jackrabbit.oak.spi.security.SecurityConfiguration) Test(org.junit.Test)

Example 3 with AuthenticationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration in project jackrabbit-oak by apache.

the class SecurityProviderImplTest method testBindAuthenticationConfiguration.

@Test
public void testBindAuthenticationConfiguration() {
    AuthenticationConfiguration ac = Mockito.mock(AuthenticationConfiguration.class);
    securityProvider.bindAuthenticationConfiguration(ac);
    assertSame(ac, securityProvider.getConfiguration(AuthenticationConfiguration.class));
    for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
        if (sc instanceof AuthenticationConfiguration) {
            assertSame(ac, sc);
        }
    }
}
Also used : AuthenticationConfiguration(org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration) SecurityConfiguration(org.apache.jackrabbit.oak.spi.security.SecurityConfiguration) Test(org.junit.Test)

Example 4 with AuthenticationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration in project jackrabbit-oak by apache.

the class SecurityProviderRegistrationTest method testBindAnotherAuthenticationConfiguration.

@Test
public void testBindAnotherAuthenticationConfiguration() throws Exception {
    Field f = registration.getClass().getDeclaredField("authenticationConfiguration");
    f.setAccessible(true);
    AuthenticationConfiguration ac = mockConfiguration(AuthenticationConfiguration.class);
    registration.bindAuthenticationConfiguration(ac);
    assertSame(ac, f.get(registration));
    AuthenticationConfiguration ac2 = mockConfiguration(AuthenticationConfiguration.class);
    registration.bindAuthenticationConfiguration(ac2);
    assertSame(ac2, f.get(registration));
}
Also used : AuthenticationConfiguration(org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration) Field(java.lang.reflect.Field) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 5 with AuthenticationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration in project jackrabbit-oak by apache.

the class SecurityProviderRegistrationTest method testBindUnbindAuthenticationConfiguration.

@Test
public void testBindUnbindAuthenticationConfiguration() throws Exception {
    Field f = registration.getClass().getDeclaredField("authenticationConfiguration");
    f.setAccessible(true);
    assertNull(f.get(registration));
    AuthenticationConfiguration ac = mockConfiguration(AuthenticationConfiguration.class);
    registration.bindAuthenticationConfiguration(ac);
    assertSame(ac, f.get(registration));
    registration.unbindAuthenticationConfiguration(ac);
    assertNull(f.get(registration));
}
Also used : AuthenticationConfiguration(org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration) Field(java.lang.reflect.Field) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

AuthenticationConfiguration (org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration)5 Test (org.junit.Test)5 SecurityConfiguration (org.apache.jackrabbit.oak.spi.security.SecurityConfiguration)3 Field (java.lang.reflect.Field)2 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)2