Search in sources :

Example 1 with Groups

use of com.google.gerrit.server.group.db.Groups in project gerrit by GerritCodeReview.

the class GroupsIT method groupsOfUserCanBeListedInSlaveMode.

@Test
@Sandboxed
public void groupsOfUserCanBeListedInSlaveMode() throws Exception {
    GroupInput groupInput = new GroupInput();
    groupInput.name = name("contributors");
    groupInput.members = ImmutableList.of(user.username());
    gApi.groups().create(groupInput).get();
    restartAsSlave();
    requestScopeOperations.setApiUser(user.id());
    List<GroupInfo> groups = gApi.groups().list().withUser(user.username()).get();
    ImmutableList<String> groupNames = groups.stream().map(group -> group.name).collect(toImmutableList());
    assertThat(groupNames).contains(groupInput.name);
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) GroupBackend(com.google.gerrit.server.account.GroupBackend) Arrays(java.util.Arrays) GlobalCapability(com.google.gerrit.common.data.GlobalCapability) TestAccount(com.google.gerrit.acceptance.TestAccount) SystemGroupBackend(com.google.gerrit.server.group.SystemGroupBackend) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) GroupIndexedListener(com.google.gerrit.extensions.events.GroupIndexedListener) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Config(org.eclipse.jgit.lib.Config) GroupAssert.assertGroupInfo(com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) Map(java.util.Map) ListRequest(com.google.gerrit.extensions.api.groups.Groups.ListRequest) GroupOperations(com.google.gerrit.acceptance.testsuite.group.GroupOperations) TestProjectUpdate.allow(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow) GitUtil.deleteRef(com.google.gerrit.acceptance.GitUtil.deleteRef) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) RefUpdate(org.eclipse.jgit.lib.RefUpdate) Constants(org.eclipse.jgit.lib.Constants) NoHttpd(com.google.gerrit.acceptance.NoHttpd) RequestScopeOperations(com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations) PersonIdent(org.eclipse.jgit.lib.PersonIdent) UseClockStep(com.google.gerrit.acceptance.UseClockStep) Stream(java.util.stream.Stream) PushResult(org.eclipse.jgit.transport.PushResult) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) GitUtil.fetch(com.google.gerrit.acceptance.GitUtil.fetch) GroupInput(com.google.gerrit.extensions.api.groups.GroupInput) ThrowingRunnable(com.google.gerrit.testing.GerritJUnit.ThrowingRunnable) Iterables(com.google.common.collect.Iterables) RevCommit(org.eclipse.jgit.revwalk.RevCommit) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) AccountOperations(com.google.gerrit.acceptance.testsuite.account.AccountOperations) GroupsSnapshotReader(com.google.gerrit.server.account.GroupsSnapshotReader) StalenessChecker(com.google.gerrit.server.index.group.StalenessChecker) FakeLdapGroupBackend(com.google.gerrit.auth.ldap.FakeLdapGroupBackend) GitUtil(com.google.gerrit.acceptance.GitUtil) ExtensionRegistry(com.google.gerrit.acceptance.ExtensionRegistry) ProjectResetter(com.google.gerrit.acceptance.ProjectResetter) AccountGroup(com.google.gerrit.entities.AccountGroup) MagicBranch(com.google.gerrit.server.util.MagicBranch) TestRepository(org.eclipse.jgit.junit.TestRepository) Sequences(com.google.gerrit.server.notedb.Sequences) IOException(java.io.IOException) Target(java.lang.annotation.Target) Test(org.junit.Test) ANONYMOUS_USERS(com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS) RUNTIME(java.lang.annotation.RetentionPolicy.RUNTIME) Correspondence(com.google.common.truth.Correspondence) METHOD(java.lang.annotation.ElementType.METHOD) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Project(com.google.gerrit.entities.Project) DynamicSet(com.google.gerrit.extensions.registration.DynamicSet) PeriodicGroupIndexer(com.google.gerrit.server.group.PeriodicGroupIndexer) TimeUtil(com.google.gerrit.server.util.time.TimeUtil) GroupDelta(com.google.gerrit.server.group.db.GroupDelta) Repository(org.eclipse.jgit.lib.Repository) AbstractModule(com.google.inject.AbstractModule) Module(com.google.inject.Module) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) GroupMemberAuditEventInfo(com.google.gerrit.extensions.common.GroupAuditEventInfo.GroupMemberAuditEventInfo) Groups(com.google.gerrit.server.group.db.Groups) Date(java.util.Date) Inject(com.google.inject.Inject) GroupApi(com.google.gerrit.extensions.api.groups.GroupApi) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) GroupsUpdate(com.google.gerrit.server.group.db.GroupsUpdate) Collectors.toMap(java.util.stream.Collectors.toMap) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) InternalGroupCreation(com.google.gerrit.server.group.db.InternalGroupCreation) After(org.junit.After) RefNames(com.google.gerrit.entities.RefNames) AuthException(com.google.gerrit.extensions.restapi.AuthException) GroupsConsistencyChecker(com.google.gerrit.server.group.db.GroupsConsistencyChecker) AtomicLongMap(com.google.common.util.concurrent.AtomicLongMap) ImmutableSet(com.google.common.collect.ImmutableSet) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) GroupAuditEventInfo(com.google.gerrit.extensions.common.GroupAuditEventInfo) Account(com.google.gerrit.entities.Account) Instant(java.time.Instant) GroupReference(com.google.gerrit.entities.GroupReference) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) Ref(org.eclipse.jgit.lib.Ref) Url(com.google.gerrit.extensions.restapi.Url) MapSubject.assertThatMap(com.google.gerrit.truth.MapSubject.assertThatMap) UserMemberAuditEventInfo(com.google.gerrit.extensions.common.GroupAuditEventInfo.UserMemberAuditEventInfo) TestProjectUpdate.allowLabel(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowLabel) InternalGroup(com.google.gerrit.entities.InternalGroup) LabelId(com.google.gerrit.entities.LabelId) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) Retention(java.lang.annotation.Retention) GroupIndexer(com.google.gerrit.server.index.group.GroupIndexer) AccountAssert.assertAccountInfos(com.google.gerrit.acceptance.rest.account.AccountAssert.assertAccountInfos) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) ImmutableList(com.google.common.collect.ImmutableList) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) GroupOptionsInfo(com.google.gerrit.extensions.common.GroupOptionsInfo) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) TestProjectUpdate.allowCapability(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability) Sandboxed(com.google.gerrit.acceptance.Sandboxed) Permission(com.google.gerrit.entities.Permission) Truth.assertThat(com.google.common.truth.Truth.assertThat) GroupIncludeCache(com.google.gerrit.server.account.GroupIncludeCache) ObjectId(org.eclipse.jgit.lib.ObjectId) Collectors.toList(java.util.stream.Collectors.toList) ProjectOperations(com.google.gerrit.acceptance.testsuite.project.ProjectOperations) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) ServerInitiated(com.google.gerrit.server.ServerInitiated) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) NullAwareCorrespondence(com.google.gerrit.truth.NullAwareCorrespondence) ServiceUserClassifier(com.google.gerrit.server.account.ServiceUserClassifier) GroupInput(com.google.gerrit.extensions.api.groups.GroupInput) GroupAssert.assertGroupInfo(com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test) Sandboxed(com.google.gerrit.acceptance.Sandboxed)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 MoreCollectors.onlyElement (com.google.common.collect.MoreCollectors.onlyElement)1 Correspondence (com.google.common.truth.Correspondence)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)1 AtomicLongMap (com.google.common.util.concurrent.AtomicLongMap)1 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 ExtensionRegistry (com.google.gerrit.acceptance.ExtensionRegistry)1 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)1 GitUtil (com.google.gerrit.acceptance.GitUtil)1 GitUtil.deleteRef (com.google.gerrit.acceptance.GitUtil.deleteRef)1 GitUtil.fetch (com.google.gerrit.acceptance.GitUtil.fetch)1 NoHttpd (com.google.gerrit.acceptance.NoHttpd)1 ProjectResetter (com.google.gerrit.acceptance.ProjectResetter)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 Sandboxed (com.google.gerrit.acceptance.Sandboxed)1 TestAccount (com.google.gerrit.acceptance.TestAccount)1