Search in sources :

Example 1 with LoginPasswordAuthenticator

use of org.sonar.api.security.LoginPasswordAuthenticator in project sonarqube by SonarSource.

the class SecurityRealmFactoryTest method should_provide_compatibility_for_authenticator.

@Test
public void should_provide_compatibility_for_authenticator() {
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_CLASS, FakeAuthenticator.class.getName());
    LoginPasswordAuthenticator authenticator = new FakeAuthenticator();
    SecurityRealmFactory factory = new SecurityRealmFactory(settings, new LoginPasswordAuthenticator[] { authenticator });
    SecurityRealm realm = factory.getRealm();
    assertThat(realm).isInstanceOf(CompatibilityRealm.class);
}
Also used : SecurityRealm(org.sonar.api.security.SecurityRealm) LoginPasswordAuthenticator(org.sonar.api.security.LoginPasswordAuthenticator) Test(org.junit.Test)

Example 2 with LoginPasswordAuthenticator

use of org.sonar.api.security.LoginPasswordAuthenticator in project sonarqube by SonarSource.

the class SecurityRealmFactoryTest method should_take_precedence_over_authenticator.

@Test
public void should_take_precedence_over_authenticator() {
    SecurityRealm realm = new FakeRealm();
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_REALM, realm.getName());
    LoginPasswordAuthenticator authenticator = new FakeAuthenticator();
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_CLASS, FakeAuthenticator.class.getName());
    SecurityRealmFactory factory = new SecurityRealmFactory(settings, new SecurityRealm[] { realm }, new LoginPasswordAuthenticator[] { authenticator });
    assertThat(factory.getRealm()).isSameAs(realm);
}
Also used : SecurityRealm(org.sonar.api.security.SecurityRealm) LoginPasswordAuthenticator(org.sonar.api.security.LoginPasswordAuthenticator) Test(org.junit.Test)

Example 3 with LoginPasswordAuthenticator

use of org.sonar.api.security.LoginPasswordAuthenticator in project sonarqube by SonarSource.

the class CompatibilityRealmTest method shouldDelegate.

@Test
public void shouldDelegate() {
    LoginPasswordAuthenticator authenticator = mock(LoginPasswordAuthenticator.class);
    CompatibilityRealm realm = new CompatibilityRealm(authenticator);
    realm.init();
    verify(authenticator).init();
    assertThat(realm.getLoginPasswordAuthenticator()).isSameAs(authenticator);
    assertThat(realm.getName()).isEqualTo("CompatibilityRealm[" + authenticator.getClass().getName() + "]");
}
Also used : LoginPasswordAuthenticator(org.sonar.api.security.LoginPasswordAuthenticator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 LoginPasswordAuthenticator (org.sonar.api.security.LoginPasswordAuthenticator)3 SecurityRealm (org.sonar.api.security.SecurityRealm)2