@Test public void realm_not_found() { settings.setProperty("sonar.security.realm", "Fake"); try { new SecurityRealmFactory(settings.asConfig()); fail(); } catch (SonarException e) { assertThat(e.getMessage()).contains("Realm 'Fake' not found."); } }
@Test public void authenticator_not_found() { settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_CLASS, "Fake"); try { new SecurityRealmFactory(settings.asConfig()); fail(); } catch (SonarException e) { assertThat(e.getMessage()).contains("Authenticator 'Fake' not found."); } }
@Test public void should_fail() { SecurityRealm realm = spy(new AlwaysFailsRealm()); settings.setProperty("sonar.security.realm", realm.getName()); try { new SecurityRealmFactory(settings.asConfig(), new SecurityRealm[] {realm}).start(); fail(); } catch (SonarException e) { assertThat(e.getCause()).isInstanceOf(IllegalStateException.class); assertThat(e.getMessage()).contains("Security realm fails to start"); } }