use of org.sonar.api.server.authentication.UserIdentity in project sonarqube by SonarSource.
the class RealmAuthenticatorTest method authenticate_with_group_sync.
@Test
public void authenticate_with_group_sync() throws Exception {
when(externalGroupsProvider.doGetGroups(any(ExternalGroupsProvider.Context.class))).thenReturn(asList("group1", "group2"));
when(userIdentityAuthenticator.authenticate(any(UserIdentity.class), any(IdentityProvider.class), any(Source.class))).thenReturn(USER);
executeStartWithGroupSync();
executeAuthenticate();
verify(userIdentityAuthenticator).authenticate(userIdentityArgumentCaptor.capture(), identityProviderArgumentCaptor.capture(), sourceCaptor.capture());
UserIdentity userIdentity = userIdentityArgumentCaptor.getValue();
assertThat(userIdentity.shouldSyncGroups()).isTrue();
assertThat(userIdentity.getGroups()).containsOnly("group1", "group2");
verify(authenticationEvent).loginSuccess(request, LOGIN, Source.realm(BASIC, REALM_NAME));
}
use of org.sonar.api.server.authentication.UserIdentity in project sonarqube by SonarSource.
the class RealmAuthenticatorTest method does_not_user_downcase_login.
@Test
public void does_not_user_downcase_login() throws Exception {
settings.setProperty("sonar.authenticator.downcase", false);
when(userIdentityAuthenticator.authenticate(any(UserIdentity.class), any(IdentityProvider.class), any(Source.class))).thenReturn(USER);
executeStartWithoutGroupSync();
executeAuthenticate("LoGiN");
verify(userIdentityAuthenticator).authenticate(userIdentityArgumentCaptor.capture(), identityProviderArgumentCaptor.capture(), sourceCaptor.capture());
UserIdentity userIdentity = userIdentityArgumentCaptor.getValue();
assertThat(userIdentity.getLogin()).isEqualTo("LoGiN");
assertThat(userIdentity.getProviderLogin()).isEqualTo("LoGiN");
verify(authenticationEvent).loginSuccess(request, "LoGiN", Source.realm(BASIC, REALM_NAME));
}
use of org.sonar.api.server.authentication.UserIdentity in project sonarqube by SonarSource.
the class UserIdentityFactoryImplTest method null_name_is_replaced_by_provider_login.
@Test
public void null_name_is_replaced_by_provider_login() {
GsonUser gson = new GsonUser("ABCD", "octocat", null, "octocat@github.com");
UserIdentity identity = underTest.create(gson, null, null);
assertThat(identity.getName()).isEqualTo("octocat");
}
use of org.sonar.api.server.authentication.UserIdentity in project sonarqube by SonarSource.
the class UserIdentityFactoryImplTest method no_email.
@Test
public void no_email() {
GsonUser gson = new GsonUser("ABCD", "octocat", "monalisa octocat", null);
UserIdentity identity = underTest.create(gson, null, null);
assertThat(identity.getProviderLogin()).isEqualTo("octocat");
assertThat(identity.getName()).isEqualTo("monalisa octocat");
assertThat(identity.getEmail()).isNull();
}
use of org.sonar.api.server.authentication.UserIdentity in project sonarqube by SonarSource.
the class UserIdentityFactoryImplTest method empty_name_is_replaced_by_provider_login.
@Test
public void empty_name_is_replaced_by_provider_login() {
GsonUser gson = new GsonUser("ABCD", "octocat", "", "octocat@github.com");
UserIdentity identity = underTest.create(gson, null, null);
assertThat(identity.getName()).isEqualTo("octocat");
}
Aggregations