Search in sources :

Example 71 with GroupInfo

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);
}
Also used : GroupInfo(com.google.gerrit.extensions.common.GroupInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 72 with GroupInfo

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);
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) Test(org.junit.Test)

Example 73 with GroupInfo

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");
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) Message(com.google.gerrit.testing.FakeEmailSender.Message) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 74 with GroupInfo

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();
}
Also used : AccountGroup(com.google.gerrit.entities.AccountGroup) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 75 with GroupInfo

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);
}
Also used : Account(com.google.gerrit.entities.Account) AccountGroup(com.google.gerrit.entities.AccountGroup) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

GroupInfo (com.google.gerrit.extensions.common.GroupInfo)92 Test (org.junit.Test)60 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)43 AccountGroup (com.google.gerrit.entities.AccountGroup)28 GroupAssert.assertGroupInfo (com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo)24 ArrayList (java.util.ArrayList)11 GroupInput (com.google.gerrit.extensions.api.groups.GroupInput)10 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)10 Account (com.google.gerrit.entities.Account)8 AuthException (com.google.gerrit.extensions.restapi.AuthException)8 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)8 GroupControl (com.google.gerrit.server.account.GroupControl)8 GroupDescription (com.google.gerrit.entities.GroupDescription)7 GroupReference (com.google.gerrit.entities.GroupReference)7 TestAccount (com.google.gerrit.acceptance.TestAccount)6 InternalGroup (com.google.gerrit.entities.InternalGroup)6 GroupDescription (com.google.gerrit.common.data.GroupDescription)5 NoSuchGroupException (com.google.gerrit.exceptions.NoSuchGroupException)5 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)5 InternalGroupDescription (com.google.gerrit.server.group.InternalGroupDescription)5