AbstractDaemonTest: Inline methods to update multiple capabilities
For the cases where it was passing a fixed list of capabilities, rewrite as a single TestProjectUpdate. In one case we actually iterate over a dynamic list of permissions. Change-Id: Id5771afda3cca334f589106ca604dc88f65c50e3
This commit is contained in:
@@ -21,8 +21,6 @@ import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static com.google.common.truth.TruthJUnit.assume;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.capabilityKey;
|
||||
import static com.google.gerrit.extensions.api.changes.SubmittedTogetherOption.NON_VISIBLE_CHANGES;
|
||||
import static com.google.gerrit.reviewdb.client.Patch.COMMIT_MSG;
|
||||
import static com.google.gerrit.reviewdb.client.Patch.MERGE_LIST;
|
||||
@@ -39,13 +37,11 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.jimfs.Jimfs;
|
||||
import com.google.common.primitives.Chars;
|
||||
import com.google.gerrit.acceptance.AcceptanceTestRequestScope.Context;
|
||||
import com.google.gerrit.acceptance.testsuite.account.TestSshKeys;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
@@ -881,47 +877,6 @@ public abstract class AbstractDaemonTest {
|
||||
return gApi.changes().id(r.getChangeId()).current();
|
||||
}
|
||||
|
||||
protected void allowGlobalCapabilities(
|
||||
AccountGroup.UUID id, int min, int max, String... capabilityNames) throws Exception {
|
||||
// TODO(dborowitz): When inlining:
|
||||
// * add a variant that takes a single String
|
||||
// * explicitly add multiple values in callers instead of looping
|
||||
TestProjectUpdate.Builder b = projectOperations.project(allProjects).forUpdate();
|
||||
Arrays.stream(capabilityNames)
|
||||
.forEach(c -> b.add(allowCapability(c).group(id).range(min, max)));
|
||||
b.update();
|
||||
}
|
||||
|
||||
protected void allowGlobalCapabilities(AccountGroup.UUID id, String... capabilityNames)
|
||||
throws Exception {
|
||||
allowGlobalCapabilities(id, Arrays.asList(capabilityNames));
|
||||
}
|
||||
|
||||
protected void allowGlobalCapabilities(AccountGroup.UUID id, Iterable<String> capabilityNames)
|
||||
throws Exception {
|
||||
// TODO(dborowitz): When inlining:
|
||||
// * add a variant that takes a single String
|
||||
// * explicitly add multiple values in callers instead of looping
|
||||
TestProjectUpdate.Builder b = projectOperations.project(allProjects).forUpdate();
|
||||
Streams.stream(capabilityNames).forEach(c -> b.add(allowCapability(c).group(id)));
|
||||
b.update();
|
||||
}
|
||||
|
||||
protected void removeGlobalCapabilities(AccountGroup.UUID id, String... capabilityNames)
|
||||
throws Exception {
|
||||
removeGlobalCapabilities(id, Arrays.asList(capabilityNames));
|
||||
}
|
||||
|
||||
protected void removeGlobalCapabilities(AccountGroup.UUID id, Iterable<String> capabilityNames)
|
||||
throws Exception {
|
||||
// TODO(dborowitz): When inlining:
|
||||
// * add a variant that takes a single String
|
||||
// * explicitly add multiple values in callers instead of looping
|
||||
TestProjectUpdate.Builder b = projectOperations.project(allProjects).forUpdate();
|
||||
Streams.stream(capabilityNames).forEach(c -> b.remove(capabilityKey(c).group(id)));
|
||||
b.update();
|
||||
}
|
||||
|
||||
protected void setUseSignedOffBy(InheritableBoolean value) throws Exception {
|
||||
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
|
||||
ProjectConfig config = projectConfigFactory.read(md);
|
||||
|
||||
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth8.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.deleteRef;
|
||||
import static com.google.gerrit.acceptance.GitUtil.fetch;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowLabel;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.deny;
|
||||
@@ -1236,7 +1237,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@Sandboxed
|
||||
public void userCanSetNameOfOtherUserWithModifyAccountPermission() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.MODIFY_ACCOUNT);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.MODIFY_ACCOUNT).group(REGISTERED_USERS))
|
||||
.update();
|
||||
gApi.accounts().id(admin.username()).setName("Admin McAdminface");
|
||||
assertThat(gApi.accounts().id(admin.username()).get().name).isEqualTo("Admin McAdminface");
|
||||
}
|
||||
@@ -1524,7 +1529,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void pushAccountConfigToUserBranchForReviewDeactivateOtherAccount() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestAccount foo = accountCreator.create(name("foo"));
|
||||
assertThat(gApi.accounts().id(foo.id().get()).getActive()).isTrue();
|
||||
@@ -1793,7 +1802,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void pushAccountConfigToUserBranchDeactivateOtherAccount() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestAccount foo = accountCreator.create(name("foo"));
|
||||
assertThat(gApi.accounts().id(foo.id().get()).getActive()).isTrue();
|
||||
@@ -1849,7 +1862,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void createUserBranchWithAccessDatabaseCapability() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
projectOperations
|
||||
.project(allUsers)
|
||||
.forUpdate()
|
||||
@@ -1869,7 +1886,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void cannotCreateNonUserBranchUnderRefsUsersWithAccessDatabaseCapability()
|
||||
throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
projectOperations
|
||||
.project(allUsers)
|
||||
.forUpdate()
|
||||
@@ -1938,7 +1959,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void deleteUserBranchWithAccessDatabaseCapability() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
projectOperations
|
||||
.project(allUsers)
|
||||
.forUpdate()
|
||||
@@ -2203,7 +2228,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void checkConsistency() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
|
||||
// Create an account with a preferred email.
|
||||
@@ -2540,7 +2569,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void atomicReadMofifyWriteExternalIds() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
Account.Id accountId = Account.id(seq.nextAccountId());
|
||||
ExternalId extIdA1 = ExternalId.create("foo", "A-1", accountId);
|
||||
|
||||
@@ -23,6 +23,7 @@ import static com.google.gerrit.acceptance.PushOneCommit.FILE_CONTENT;
|
||||
import static com.google.gerrit.acceptance.PushOneCommit.FILE_NAME;
|
||||
import static com.google.gerrit.acceptance.PushOneCommit.SUBJECT;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.permissionKey;
|
||||
import static com.google.gerrit.extensions.client.ListChangesOption.ALL_REVISIONS;
|
||||
@@ -2540,8 +2541,14 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void queryChangesNoLimit() throws Exception {
|
||||
allowGlobalCapabilities(
|
||||
SystemGroupBackend.REGISTERED_USERS, 0, 2, GlobalCapability.QUERY_LIMIT);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(
|
||||
allowCapability(GlobalCapability.QUERY_LIMIT)
|
||||
.group(SystemGroupBackend.REGISTERED_USERS)
|
||||
.range(0, 2))
|
||||
.update();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
createChange();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.api.group;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
@@ -60,7 +61,11 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
||||
|
||||
@Before
|
||||
public void basicSetup() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
String name1 = groupOperations.newGroup().name("g1").create().get();
|
||||
String name2 = groupOperations.newGroup().name("g2").create().get();
|
||||
|
||||
@@ -23,6 +23,7 @@ import static com.google.gerrit.acceptance.GitUtil.fetch;
|
||||
import static com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo;
|
||||
import static com.google.gerrit.acceptance.rest.account.AccountAssert.assertAccountInfos;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowLabel;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
@@ -1046,7 +1047,11 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void pushToGroupNamesBranchIsRejectedForAllUsersRepo() throws Exception {
|
||||
// refs/meta/group-names isn't usually available for fetch, so grant ACCESS_DATABASE
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
assertPushToGroupBranch(allUsers, RefNames.REFS_GROUPNAMES, "group update not allowed");
|
||||
}
|
||||
|
||||
@@ -1189,7 +1194,11 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
// refs/meta/group-names is only visible with ACCESS_DATABASE
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
testCannotCreateGroupBranch(RefNames.REFS_GROUPNAMES, RefNames.REFS_GROUPNAMES);
|
||||
}
|
||||
@@ -1228,7 +1237,11 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void cannotDeleteGroupNamesBranch() throws Exception {
|
||||
// refs/meta/group-names is only visible with ACCESS_DATABASE
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
testCannotDeleteGroupBranch(RefNames.REFS_GROUPNAMES, RefNames.REFS_GROUPNAMES);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import static com.google.gerrit.acceptance.GitUtil.pushHead;
|
||||
import static com.google.gerrit.acceptance.GitUtil.pushOne;
|
||||
import static com.google.gerrit.acceptance.PushOneCommit.FILE_NAME;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block;
|
||||
import static com.google.gerrit.common.FooterConstants.CHANGE_ID;
|
||||
import static com.google.gerrit.extensions.client.ListChangesOption.ALL_REVISIONS;
|
||||
@@ -2333,7 +2334,11 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
pr = pushOne(testRepo, c.name(), ref, false, false, opts);
|
||||
assertPushRejected(pr, ref, "NoteDb update requires access database permission");
|
||||
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
pr = pushOne(testRepo, c.name(), ref, false, false, opts);
|
||||
assertPushRejected(pr, ref, "prohibited by Gerrit: not permitted: create");
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.common.truth.TruthJUnit.assume;
|
||||
import static com.google.gerrit.acceptance.GitUtil.fetch;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.deny;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
@@ -335,7 +336,11 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void uploadPackSubsetOfRefsVisibleWithAccessDatabase() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
projectOperations
|
||||
.project(project)
|
||||
.forUpdate()
|
||||
@@ -409,7 +414,11 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
public void uploadPackSequencesWithAccessDatabase() throws Exception {
|
||||
assertRefs(allProjects, user, true);
|
||||
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
assertRefs(allProjects, user, true, "refs/sequences/changes");
|
||||
}
|
||||
|
||||
@@ -538,7 +547,11 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void advertisedReferencesIncludeAllUserBranchesWithAccessDatabase() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
TestRepository<?> userTestRepository = cloneProject(allUsers, user);
|
||||
try (Git git = userTestRepository.git()) {
|
||||
assertThat(getUserRefs(git))
|
||||
@@ -577,7 +590,11 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void advertisedReferencesIncludeAllGroupBranchesWithAccessDatabase() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
AccountGroup.UUID users = createGroup("Users", admins);
|
||||
TestRepository<?> userTestRepository = cloneProject(allUsers, user);
|
||||
try (Git git = userTestRepository.git()) {
|
||||
@@ -596,7 +613,11 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
.forUpdate()
|
||||
.add(allow(Permission.READ).ref(RefNames.REFS_GROUPS + "*").group(REGISTERED_USERS))
|
||||
.update();
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ADMINISTRATE_SERVER);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ADMINISTRATE_SERVER).group(REGISTERED_USERS))
|
||||
.update();
|
||||
AccountGroup.UUID users = createGroup("Users", admins);
|
||||
TestRepository<?> userTestRepository = cloneProject(allUsers, user);
|
||||
try (Git git = userTestRepository.git()) {
|
||||
@@ -734,7 +755,11 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void hideMetadata() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
// create change
|
||||
TestRepository<?> allUsersRepo = cloneProject(allUsers);
|
||||
fetch(allUsersRepo, RefNames.REFS_USERS_SELF + ":userRef");
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.account;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.capabilityKey;
|
||||
import static com.google.gerrit.common.data.GlobalCapability.ACCESS_DATABASE;
|
||||
import static com.google.gerrit.common.data.GlobalCapability.ADMINISTRATE_SERVER;
|
||||
import static com.google.gerrit.common.data.GlobalCapability.BATCH_CHANGES_LIMIT;
|
||||
@@ -26,9 +29,10 @@ import static com.google.gerrit.common.data.GlobalCapability.QUERY_LIMIT;
|
||||
import static com.google.gerrit.common.data.GlobalCapability.RUN_AS;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@@ -38,12 +42,13 @@ public class CapabilitiesIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void capabilitiesUser() throws Exception {
|
||||
Iterable<String> all =
|
||||
Iterables.filter(
|
||||
GlobalCapability.getAllNames(),
|
||||
c -> !ADMINISTRATE_SERVER.equals(c) && !PRIORITY.equals(c));
|
||||
|
||||
allowGlobalCapabilities(REGISTERED_USERS, all);
|
||||
ImmutableList<String> all =
|
||||
GlobalCapability.getAllNames().stream()
|
||||
.filter(c -> !ADMINISTRATE_SERVER.equals(c) && !PRIORITY.equals(c))
|
||||
.collect(toImmutableList());
|
||||
TestProjectUpdate.Builder allowBuilder = projectOperations.project(allProjects).forUpdate();
|
||||
all.forEach(c -> allowBuilder.add(allowCapability(c).group(REGISTERED_USERS)));
|
||||
allowBuilder.update();
|
||||
try {
|
||||
RestResponse r = userRestSession.get("/accounts/self/capabilities");
|
||||
r.assertOK();
|
||||
@@ -67,7 +72,9 @@ public class CapabilitiesIT extends AbstractDaemonTest {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
removeGlobalCapabilities(REGISTERED_USERS, all);
|
||||
TestProjectUpdate.Builder removeBuilder = projectOperations.project(allProjects).forUpdate();
|
||||
all.forEach(c -> removeBuilder.remove(capabilityKey(c).group(REGISTERED_USERS)));
|
||||
removeBuilder.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth8.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.fetch;
|
||||
import static com.google.gerrit.acceptance.GitUtil.pushHead;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_MAILTO;
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USERNAME;
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_UUID;
|
||||
@@ -122,7 +123,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void getExternalIdsOfOtherUserWithAccessDatabase() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
Collection<ExternalId> expectedIds = getAccountState(admin.id()).getExternalIds();
|
||||
List<AccountExternalIdInfo> expectedIdInfos = toExternalIdInfos(expectedIds);
|
||||
@@ -196,7 +201,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void deleteExternalIdsOfOtherUserWithAccessDatabase() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
List<AccountExternalIdInfo> externalIds = gApi.accounts().self().getExternalIds();
|
||||
|
||||
@@ -269,7 +278,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Remote does not have " + RefNames.REFS_EXTERNAL_IDS + " available for fetch.");
|
||||
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
// re-clone to get new request context, otherwise the old global capabilities are still cached
|
||||
// in the IdentifiedUser object
|
||||
@@ -279,7 +292,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void pushToExternalIdsBranch() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
|
||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
|
||||
@@ -304,7 +321,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void pushToExternalIdsBranchRejectsExternalIdWithoutAccountId() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
|
||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
|
||||
@@ -322,7 +343,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void pushToExternalIdsBranchRejectsExternalIdWithKeyThatDoesntMatchTheNoteId()
|
||||
throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
|
||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
|
||||
@@ -339,7 +364,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void pushToExternalIdsBranchRejectsExternalIdWithInvalidConfig() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
|
||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
|
||||
@@ -356,7 +385,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void pushToExternalIdsBranchRejectsExternalIdWithEmptyNote() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
|
||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
|
||||
@@ -396,7 +429,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
private void testPushToExternalIdsBranchRejectsInvalidExternalId(ExternalId invalidExtId)
|
||||
throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
|
||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
|
||||
@@ -412,7 +449,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void readExternalIdsWhenInvalidExternalIdsExist() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
|
||||
insertValidExternalIds();
|
||||
@@ -433,7 +474,11 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void checkConsistency() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
|
||||
insertValidExternalIds();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.acceptance.rest.binding;
|
||||
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -83,7 +84,11 @@ public class ConfigRestApiBindingsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void configEndpoints() throws Exception {
|
||||
// 'Access Database' is needed for the '/config/server/check.consistency' REST endpoint
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
RestApiCallHelper.execute(adminRestSession, CONFIG_ENDPOINTS);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.rest.change;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.gerrit.acceptance.PushOneCommit.FILE_NAME;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.extensions.client.ListChangesOption.MESSAGES;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.parseCommitMessageRange;
|
||||
@@ -168,7 +169,11 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void deleteCanBeAppliedWithAdministrateServerCapability() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ADMINISTRATE_SERVER);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.ADMINISTRATE_SERVER).group(REGISTERED_USERS))
|
||||
.update();
|
||||
int changeNum = createOneChangeWithMultipleChangeMessagesInHistory();
|
||||
requestScopeOperations.setApiUser(user.id());
|
||||
deleteOneChangeMessage(changeNum, 0, user, "spam");
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.acceptance.rest.change;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
@@ -184,7 +185,11 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
|
||||
// Clear cached group info.
|
||||
requestScopeOperations.setApiUser(user1.id());
|
||||
allowGlobalCapabilities(group1, GlobalCapability.VIEW_ALL_ACCOUNTS);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.VIEW_ALL_ACCOUNTS).group(group1))
|
||||
.update();
|
||||
reviewers = suggestReviewers(changeId, user2.username(), 2);
|
||||
assertThat(reviewers).hasSize(1);
|
||||
assertThat(Iterables.getOnlyElement(reviewers).account.name).isEqualTo(user2.fullName());
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package com.google.gerrit.acceptance.rest.config;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.capabilityKey;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static com.google.gerrit.server.restapi.config.PostCaches.Operation.FLUSH;
|
||||
import static com.google.gerrit.server.restapi.config.PostCaches.Operation.FLUSH_ALL;
|
||||
@@ -124,8 +126,12 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flushWebSessions_Forbidden() throws Exception {
|
||||
allowGlobalCapabilities(
|
||||
REGISTERED_USERS, GlobalCapability.FLUSH_CACHES, GlobalCapability.VIEW_CACHES);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.FLUSH_CACHES).group(REGISTERED_USERS))
|
||||
.add(allowCapability(GlobalCapability.VIEW_CACHES).group(REGISTERED_USERS))
|
||||
.update();
|
||||
try {
|
||||
RestResponse r =
|
||||
userRestSession.post(
|
||||
@@ -138,8 +144,12 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
"/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("web_sessions")))
|
||||
.assertForbidden();
|
||||
} finally {
|
||||
removeGlobalCapabilities(
|
||||
REGISTERED_USERS, GlobalCapability.FLUSH_CACHES, GlobalCapability.VIEW_CACHES);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.remove(capabilityKey(GlobalCapability.FLUSH_CACHES).group(REGISTERED_USERS))
|
||||
.remove(capabilityKey(GlobalCapability.VIEW_CACHES).group(REGISTERED_USERS))
|
||||
.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package com.google.gerrit.acceptance.rest.config;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.capabilityKey;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
@@ -65,8 +67,12 @@ public class FlushCacheIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flushWebSessionsCache_Forbidden() throws Exception {
|
||||
allowGlobalCapabilities(
|
||||
REGISTERED_USERS, GlobalCapability.VIEW_CACHES, GlobalCapability.FLUSH_CACHES);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(allowCapability(GlobalCapability.FLUSH_CACHES).group(REGISTERED_USERS))
|
||||
.add(allowCapability(GlobalCapability.VIEW_CACHES).group(REGISTERED_USERS))
|
||||
.update();
|
||||
try {
|
||||
RestResponse r = userRestSession.post("/config/server/caches/accounts/flush");
|
||||
r.assertOK();
|
||||
@@ -74,8 +80,12 @@ public class FlushCacheIT extends AbstractDaemonTest {
|
||||
|
||||
userRestSession.post("/config/server/caches/web_sessions/flush").assertForbidden();
|
||||
} finally {
|
||||
removeGlobalCapabilities(
|
||||
REGISTERED_USERS, GlobalCapability.VIEW_CACHES, GlobalCapability.FLUSH_CACHES);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.remove(capabilityKey(GlobalCapability.FLUSH_CACHES).group(REGISTERED_USERS))
|
||||
.remove(capabilityKey(GlobalCapability.VIEW_CACHES).group(REGISTERED_USERS))
|
||||
.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo;
|
||||
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectOwners;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability;
|
||||
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.capabilityKey;
|
||||
import static com.google.gerrit.server.project.ProjectConfig.PROJECT_CONFIG;
|
||||
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -324,7 +326,13 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void createProjectWithCapability() throws Exception {
|
||||
allowGlobalCapabilities(SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(
|
||||
allowCapability(GlobalCapability.CREATE_PROJECT)
|
||||
.group(SystemGroupBackend.REGISTERED_USERS))
|
||||
.update();
|
||||
try {
|
||||
requestScopeOperations.setApiUser(user.id());
|
||||
ProjectInput in = new ProjectInput();
|
||||
@@ -332,8 +340,13 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
ProjectInfo p = gApi.projects().create(in).get();
|
||||
assertThat(p.name).isEqualTo(in.name);
|
||||
} finally {
|
||||
removeGlobalCapabilities(
|
||||
SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.remove(
|
||||
capabilityKey(GlobalCapability.CREATE_PROJECT)
|
||||
.group(SystemGroupBackend.REGISTERED_USERS))
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +369,13 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
public void createProjectWithCreateProjectCapabilityAndParentNotVisible() throws Exception {
|
||||
Project parent = projectCache.get(allProjects).getProject();
|
||||
parent.setState(com.google.gerrit.extensions.client.ProjectState.HIDDEN);
|
||||
allowGlobalCapabilities(SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.add(
|
||||
allowCapability(GlobalCapability.CREATE_PROJECT)
|
||||
.group(SystemGroupBackend.REGISTERED_USERS))
|
||||
.update();
|
||||
try {
|
||||
requestScopeOperations.setApiUser(user.id());
|
||||
ProjectInput in = new ProjectInput();
|
||||
@@ -365,8 +384,13 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
assertThat(p.name).isEqualTo(in.name);
|
||||
} finally {
|
||||
parent.setState(com.google.gerrit.extensions.client.ProjectState.ACTIVE);
|
||||
removeGlobalCapabilities(
|
||||
SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
|
||||
projectOperations
|
||||
.project(allProjects)
|
||||
.forUpdate()
|
||||
.remove(
|
||||
capabilityKey(GlobalCapability.CREATE_PROJECT)
|
||||
.group(SystemGroupBackend.REGISTERED_USERS))
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user