use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class GroupsIT method getSystemGroupByDefaultName.
@Test
public void getSystemGroupByDefaultName() throws Exception {
GroupReference anonymousUsersGroup = systemGroupBackend.getGroup(ANONYMOUS_USERS);
GroupInfo group = gApi.groups().id("Anonymous Users").get();
assertThat(group.name).isEqualTo(anonymousUsersGroup.getName());
assertThat(group.id).isEqualTo(Url.encode((anonymousUsersGroup.getUUID().get())));
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class GroupsIT method allGroupInfoFieldsSetCorrectly.
@Test
public void allGroupInfoFieldsSetCorrectly() throws Exception {
AccountGroup adminGroup = getFromCache("Administrators");
Map<String, GroupInfo> groups = gApi.groups().list().addGroup(adminGroup.getName()).getAsMap();
assertThat(groups).hasSize(1);
assertThat(groups).containsKey("Administrators");
assertGroupInfo(adminGroup, Iterables.getOnlyElement(groups.values()));
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class GroupsIT method getSystemGroupByConfiguredName.
@Test
@GerritConfig(name = "groups.global:Anonymous-Users.name", value = "All Users")
public void getSystemGroupByConfiguredName() throws Exception {
GroupReference anonymousUsersGroup = systemGroupBackend.getGroup(ANONYMOUS_USERS);
assertThat(anonymousUsersGroup.getName()).isEqualTo("All Users");
GroupInfo group = gApi.groups().id(anonymousUsersGroup.getUUID().get()).get();
assertThat(group.name).isEqualTo(anonymousUsersGroup.getName());
group = gApi.groups().id(anonymousUsersGroup.getName()).get();
assertThat(group.id).isEqualTo(Url.encode((anonymousUsersGroup.getUUID().get())));
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method group.
private AccountGroup group(String name) throws Exception {
GroupInfo group = createGroupFactory.create(name(name)).apply(TopLevelResource.INSTANCE, null);
GroupDescription.Basic d = groups.parseInternal(Url.decode(group.id));
return GroupDescriptions.toAccountGroup(d);
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class ProjectWatchIT method watchProjectNotifyOnPrivateChange.
@Test
public void watchProjectNotifyOnPrivateChange() throws Exception {
String watchedProject = createProject("watchedProject").get();
// create group that can view all private changes
GroupInfo groupThatCanViewPrivateChanges = gApi.groups().create("groupThatCanViewPrivateChanges").get();
grant(new Project.NameKey(watchedProject), "refs/*", Permission.VIEW_PRIVATE_CHANGES, false, new AccountGroup.UUID(groupThatCanViewPrivateChanges.id));
// watch project as user that can't view private changes
setApiUser(user);
watch(watchedProject, null);
// watch project as user that can view all private change
TestAccount userThatCanViewPrivateChanges = accounts.create("user2", "user2@test.com", "User2", groupThatCanViewPrivateChanges.name);
setApiUser(userThatCanViewPrivateChanges);
watch(watchedProject, null);
// push a private change to watched project -> should trigger email notification for
// userThatCanViewPrivateChanges, but not for user
setApiUser(admin);
TestRepository<InMemoryRepository> watchedRepo = cloneProject(new Project.NameKey(watchedProject), admin);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), watchedRepo, "TRIGGER", "a", "a1").to("refs/for/master%private");
r.assertOkStatus();
// assert email notification
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(userThatCanViewPrivateChanges.emailAddress);
assertThat(m.body()).contains("Change subject: TRIGGER\n");
assertThat(m.body()).contains("Gerrit-PatchSet: 1\n");
}
Aggregations