Search in sources :

Example 6 with Source

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

the class AuthenticationEventSourceTest method jwt_returns_source_instance_with_hardcoded_method_provider_and_providerName.

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

Example 7 with Source

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

the class AuthenticationEventSourceTest method oauth2_creates_source_instance_with_specified_provider_name_and_hardcoded_provider_and_method.

@Test
public void oauth2_creates_source_instance_with_specified_provider_name_and_hardcoded_provider_and_method() {
    Source underTest = Source.oauth2(newOauth2IdentityProvider("some name"));
    assertThat(underTest.getMethod()).isEqualTo(Method.OAUTH2);
    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 8 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_email_already_exists.

@Test
public void fail_to_authenticate_new_user_when_email_already_exists() throws Exception {
    db.users().insertUser(newUserDto().setLogin("Existing user with same email").setActive(true).setEmail("john@email.com"));
    Source source = Source.realm(Method.FORM, IDENTITY_PROVIDER.getName());
    thrown.expect(authenticationException().from(source).withLogin(USER_IDENTITY.getLogin()).andPublicMessage("You can't sign up because email 'john@email.com' is already used by an existing user. " + "This means that you probably already registered with another account."));
    thrown.expectMessage("Email 'john@email.com' is already used");
    underTest.authenticate(USER_IDENTITY, IDENTITY_PROVIDER, source);
}
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