use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.
the class ExternalUserPermissionIT method externalUser_isNotContainedInRegisteredUsersIfNotConfigured.
@GerritConfig(name = "groups.includeExternalUsersInRegisteredUsersGroup", value = "false")
@Test
public void externalUser_isNotContainedInRegisteredUsersIfNotConfigured() {
ExternalUser user = createUserInGroup("1", "it-department");
assertThat(user.getEffectiveGroups().contains(REGISTERED_USERS)).isFalse();
}
use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.
the class ExternalUserPermissionIT method defaultRefFilter_refVisibilityIsAgnosticOfProvidedGroups.
@Test
public void defaultRefFilter_refVisibilityIsAgnosticOfProvidedGroups() throws Exception {
ExternalUser user = createUserInGroup("1", "it-department");
// Check that refs/meta/config isn't visible by default
assertThat(getVisibleRefNames(user)).containsExactly("HEAD", "refs/heads/master");
// Grant access
projectOperations.project(project).forUpdate().add(allow(Permission.READ).ref("refs/meta/config").group(EXTERNAL_GROUP)).update();
// Check that refs/meta/config became visible
assertThat(getVisibleRefNames(user)).containsExactly("HEAD", "refs/heads/master", "refs/meta/config");
}
use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.
the class ExternalUserPermissionIT method changeVisibility_changeOnBranchVisibleToAnonymousIsVisible.
@Test
public void changeVisibility_changeOnBranchVisibleToAnonymousIsVisible() throws Exception {
Change.Id changeId = changeOperations.newChange().project(project).create();
ExternalUser user = createUserInGroup("1", "it-department");
permissionBackend.user(user).change(changeNotesFactory.create(project, changeId)).check(ChangePermission.READ);
}
use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.
the class ExternalUserPermissionIT method defaultRefFilter_changeVisibilityIsAgnosticOfProvidedGroups.
@Test
public void defaultRefFilter_changeVisibilityIsAgnosticOfProvidedGroups() throws Exception {
ExternalUser user = createUserInGroup("1", "it-department");
Change.Id changeOnMaster = changeOperations.newChange().project(project).create();
Change.Id changeOnRefsMetaConfig = changeOperations.newChange().project(project).branch("refs/meta/config").create();
// Check that only the change on the default branch is visible
assertThat(getVisibleRefNames(user)).containsExactly("HEAD", "refs/heads/master", RefNames.changeMetaRef(changeOnMaster), RefNames.patchSetRef(PatchSet.id(changeOnMaster, 1)));
// Grant access
projectOperations.project(project).forUpdate().add(allow(Permission.READ).ref("refs/meta/config").group(EXTERNAL_GROUP)).update();
// Check that both changes are visible now
assertThat(getVisibleRefNames(user)).containsExactly("HEAD", "refs/heads/master", "refs/meta/config", RefNames.changeMetaRef(changeOnMaster), RefNames.patchSetRef(PatchSet.id(changeOnMaster, 1)), RefNames.changeMetaRef(changeOnRefsMetaConfig), RefNames.patchSetRef(PatchSet.id(changeOnRefsMetaConfig, 1)));
}
use of com.google.gerrit.server.ExternalUser in project gerrit by GerritCodeReview.
the class ExternalUserPermissionIT method changeVisibility_changeOnInvisibleBranchNotVisible.
@Test
public void changeVisibility_changeOnInvisibleBranchNotVisible() throws Exception {
// Create a change that is not visible to members of 'externalGroup'
Change.Id invisibleChange = changeOperations.newChange().project(project).branch("refs/meta/config").create();
ExternalUser user = createUserInGroup("1", "it-department");
AuthException thrown = assertThrows(AuthException.class, () -> permissionBackend.user(user).change(changeNotesFactory.create(project, invisibleChange)).check(ChangePermission.READ));
assertThat(thrown).hasMessageThat().isEqualTo("read not permitted");
}
Aggregations