Search in sources :

Example 6 with ExternalUser

use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.

the class ExternalUserPermissionIT method externalUser_isContainedInternalGroupThatContainsExternalGroup.

@Test
public void externalUser_isContainedInternalGroupThatContainsExternalGroup() {
    AccountGroup.UUID internalGroup = groupOperations.newGroup().addSubgroup(EXTERNAL_GROUP).create();
    ExternalUser user = createUserInGroup("1", "it-department");
    assertThat(user.getEffectiveGroups().contains(internalGroup)).isTrue();
    assertThat(user.getEffectiveGroups().contains(EXTERNAL_GROUP)).isTrue();
    assertThat(user.getEffectiveGroups().contains(REGISTERED_USERS)).isTrue();
    assertThat(user.getEffectiveGroups().contains(ANONYMOUS_USERS)).isTrue();
}
Also used : AccountGroup(com.google.gerrit.entities.AccountGroup) ExternalUser(com.google.gerrit.server.ExternalUser) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with ExternalUser

use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.

the class ExternalUserPermissionIT method externalUser_isContainedInRegisteredUsersIfConfigured.

@GerritConfig(name = "groups.includeExternalUsersInRegisteredUsersGroup", value = "true")
@Test
public void externalUser_isContainedInRegisteredUsersIfConfigured() {
    ExternalUser user = createUserInGroup("1", "it-department");
    assertThat(user.getEffectiveGroups().contains(REGISTERED_USERS)).isTrue();
}
Also used : ExternalUser(com.google.gerrit.server.ExternalUser) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 8 with ExternalUser

use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.

the class ExternalUserPermissionIT method changeVisibility_changeOnBranchVisibleToRegisteredUsersIsVisible.

@Test
public void changeVisibility_changeOnBranchVisibleToRegisteredUsersIsVisible() throws Exception {
    Change.Id changeId = changeOperations.newChange().project(project).create();
    ExternalUser user = createUserInGroup("1", "it-department");
    blockAnonymousRead();
    permissionBackend.user(user).change(changeNotesFactory.create(project, changeId)).check(ChangePermission.READ);
}
Also used : ExternalUser(com.google.gerrit.server.ExternalUser) Change(com.google.gerrit.entities.Change) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)8 ExternalUser (com.google.gerrit.server.ExternalUser)8 Test (org.junit.Test)8 Change (com.google.gerrit.entities.Change)4 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)2 AccountGroup (com.google.gerrit.entities.AccountGroup)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1