Search in sources :

Example 1 with Source

use of org.sonar.server.authentication.event.AuthenticationEvent.Source in project sonarqube by SonarSource.

the class UserIdentityAuthenticatorTest method fail_to_authenticate_new_user_when_allow_users_to_signup_is_false.

@Test
public void fail_to_authenticate_new_user_when_allow_users_to_signup_is_false() throws Exception {
    TestIdentityProvider identityProvider = new TestIdentityProvider().setKey("github").setName("Github").setEnabled(true).setAllowsUsersToSignUp(false);
    Source source = Source.realm(Method.FORM, identityProvider.getName());
    thrown.expect(authenticationException().from(source).withLogin(USER_IDENTITY.getLogin()).andPublicMessage("'github' users are not allowed to sign up"));
    thrown.expectMessage("User signup disabled for provider 'github'");
    underTest.authenticate(USER_IDENTITY, identityProvider, source);
}
Also used : Source(org.sonar.server.authentication.event.AuthenticationEvent.Source) Test(org.junit.Test)

Example 2 with Source

use of org.sonar.server.authentication.event.AuthenticationEvent.Source in project sonarqube by SonarSource.

the class AuthenticationEventSourceTest method realm_creates_source_instance_with_specified_method_and_provider_name_and_hardcoded_provider.

@Test
public void realm_creates_source_instance_with_specified_method_and_provider_name_and_hardcoded_provider() {
    Source underTest = Source.realm(Method.BASIC, "some name");
    assertThat(underTest.getMethod()).isEqualTo(Method.BASIC);
    assertThat(underTest.getProvider()).isEqualTo(Provider.REALM);
    assertThat(underTest.getProviderName()).isEqualTo("some name");
}
Also used : Source(org.sonar.server.authentication.event.AuthenticationEvent.Source) Test(org.junit.Test)

Example 3 with Source

use of org.sonar.server.authentication.event.AuthenticationEvent.Source in project sonarqube by SonarSource.

the class AuthenticationEventSourceTest method sso_returns_source_instance_with_hardcoded_method_provider_and_providerName.

@Test
public void sso_returns_source_instance_with_hardcoded_method_provider_and_providerName() {
    Source underTest = Source.sso();
    assertThat(underTest.getMethod()).isEqualTo(Method.SSO);
    assertThat(underTest.getProvider()).isEqualTo(Provider.SSO);
    assertThat(underTest.getProviderName()).isEqualTo("sso");
    assertThat(underTest).isSameAs(Source.sso());
}
Also used : Source(org.sonar.server.authentication.event.AuthenticationEvent.Source) Test(org.junit.Test)

Example 4 with Source

use of org.sonar.server.authentication.event.AuthenticationEvent.Source in project sonarqube by SonarSource.

the class AuthenticationEventSourceTest method external_creates_source_instance_with_specified_provider_name_and_hardcoded_provider_and_method.

@Test
public void external_creates_source_instance_with_specified_provider_name_and_hardcoded_provider_and_method() {
    Source underTest = Source.external(newBasicIdentityProvider("some name"));
    assertThat(underTest.getMethod()).isEqualTo(Method.EXTERNAL);
    assertThat(underTest.getProvider()).isEqualTo(Provider.EXTERNAL);
    assertThat(underTest.getProviderName()).isEqualTo("some name");
}
Also used : Source(org.sonar.server.authentication.event.AuthenticationEvent.Source) Test(org.junit.Test)

Example 5 with Source

use of org.sonar.server.authentication.event.AuthenticationEvent.Source in project sonarqube by SonarSource.

the class AuthenticationEventSourceTest method local_creates_source_instance_with_specified_method_and_hardcoded_provider_and_provider_name.

@Test
public void local_creates_source_instance_with_specified_method_and_hardcoded_provider_and_provider_name() {
    Source underTest = Source.local(Method.BASIC_TOKEN);
    assertThat(underTest.getMethod()).isEqualTo(Method.BASIC_TOKEN);
    assertThat(underTest.getProvider()).isEqualTo(Provider.LOCAL);
    assertThat(underTest.getProviderName()).isEqualTo("local");
}
Also used : Source(org.sonar.server.authentication.event.AuthenticationEvent.Source) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 Source (org.sonar.server.authentication.event.AuthenticationEvent.Source)8