Search in sources :

Example 16 with GroupInfo

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())));
}
Also used : GroupAssert.assertGroupInfo(com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) GroupReference(com.google.gerrit.common.data.GroupReference) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 17 with GroupInfo

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

Example 18 with GroupInfo

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())));
}
Also used : GroupAssert.assertGroupInfo(com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) GroupReference(com.google.gerrit.common.data.GroupReference) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 19 with GroupInfo

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);
}
Also used : GroupDescription(com.google.gerrit.common.data.GroupDescription) GroupInfo(com.google.gerrit.extensions.common.GroupInfo)

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

Aggregations

GroupInfo (com.google.gerrit.extensions.common.GroupInfo)38 Test (org.junit.Test)20 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)11 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)9 GroupAssert.assertGroupInfo (com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo)8 GroupDescription (com.google.gerrit.common.data.GroupDescription)5 ArrayList (java.util.ArrayList)5 GroupReference (com.google.gerrit.common.data.GroupReference)4 GroupInput (com.google.gerrit.extensions.api.groups.GroupInput)4 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)4 TestAccount (com.google.gerrit.acceptance.TestAccount)3 NoSuchGroupException (com.google.gerrit.common.errors.NoSuchGroupException)3 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)3 GroupControl (com.google.gerrit.server.account.GroupControl)3 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 AuthException (com.google.gerrit.extensions.restapi.AuthException)2 Account (com.google.gerrit.reviewdb.client.Account)2 AccountGroupById (com.google.gerrit.reviewdb.client.AccountGroupById)2 Project (com.google.gerrit.reviewdb.client.Project)2 Message (com.google.gerrit.testutil.FakeEmailSender.Message)2