use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class ListGroupsIT method listAllGroups.
@Test
public void listAllGroups() throws Exception {
RestResponse response = adminRestSession.get("/groups/");
response.assertOK();
Map<String, GroupInfo> groupMap = newGson().fromJson(response.getReader(), new TypeToken<Map<String, GroupInfo>>() {
}.getType());
assertThat(groupMap.keySet()).containsExactly("Administrators", ServiceUserClassifier.SERVICE_USERS);
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class AbstractQueryAccountsTest method byCansee.
@Test
public void byCansee() throws Exception {
String domain = name("test.com");
AccountInfo user1 = newAccountWithEmail("account1", "account1@" + domain);
AccountInfo user2 = newAccountWithEmail("account2", "account2@" + domain);
AccountInfo user3 = newAccountWithEmail("account3", "account3@" + domain);
Project.NameKey p = createProject(name("p"));
ChangeInfo c = createChange(p);
assertQuery("name:" + domain + " cansee:" + c.changeId, user1, user2, user3);
GroupInfo group = createGroup(name("group"), user1, user2);
blockRead(p, group);
assertQuery("name:" + domain + " cansee:" + c.changeId, user3);
}
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 = projectOperations.newProject().create().get();
// create group that can view all private changes
GroupInfo groupThatCanViewPrivateChanges = gApi.groups().create("groupThatCanViewPrivateChanges").get();
projectOperations.project(Project.nameKey(watchedProject)).forUpdate().add(allow(Permission.VIEW_PRIVATE_CHANGES).ref("refs/*").group(AccountGroup.uuid(groupThatCanViewPrivateChanges.id))).update();
// watch project as user that can't view private changes
requestScopeOperations.setApiUser(user.id());
watch(watchedProject);
// watch project as user that can view all private change
TestAccount userThatCanViewPrivateChanges = accountCreator.create("user2", "user2@example.com", "User2", null, groupThatCanViewPrivateChanges.name);
requestScopeOperations.setApiUser(userThatCanViewPrivateChanges.id());
watch(watchedProject);
// push a private change to watched project -> should trigger email notification for
// userThatCanViewPrivateChanges, but not for user
requestScopeOperations.setApiUser(admin.id());
TestRepository<InMemoryRepository> watchedRepo = cloneProject(Project.nameKey(watchedProject), admin);
PushOneCommit.Result r = pushFactory.create(admin.newIdent(), 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.getNameEmail());
assertThat(m.body()).contains("Change subject: TRIGGER\n");
assertThat(m.body()).contains("Gerrit-PatchSet: 1\n");
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class GroupOperationsImplTest method requestingNoSubgroupsIsPossibleForGroupCreation.
@Test
public void requestingNoSubgroupsIsPossibleForGroupCreation() throws Exception {
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create();
GroupInfo foundGroup = getGroupFromServer(groupUuid);
assertThat(foundGroup.includes).isEmpty();
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class GroupOperationsImplTest method specifiedMembersAreRespectedForGroupCreation.
@Test
public void specifiedMembersAreRespectedForGroupCreation() throws Exception {
Account.Id account1Id = accountOperations.newAccount().create();
Account.Id account2Id = accountOperations.newAccount().create();
Account.Id account3Id = accountOperations.newAccount().create();
Account.Id account4Id = accountOperations.newAccount().create();
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(account1Id, account2Id).addMember(account3Id).addMember(account4Id).create();
GroupInfo foundGroup = getGroupFromServer(groupUuid);
assertThat(foundGroup.members).comparingElementsUsing(getAccountToIdCorrespondence()).containsExactly(account1Id, account2Id, account3Id, account4Id);
}
Aggregations