Merge branch 'stable-3.0' into stable-3.1
* stable-3.0:
Upgrade bazlets to latest stable-3.0 to build with 3.0.12 API
Upgrade bazlets to latest stable-2.16 to build with 2.16.22 API
Change-Id: Ic55e5d33318d86188f5bd77ea85018542e9810ca
diff --git a/WORKSPACE b/WORKSPACE
index dcce13b..dff60ca 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "6d2b8f41ed34dad925b767399d1e4be378abb029",
+ commit = "b6cb89690a5e06261932eb30c95fd8db34a7943a",
#local_path = "/home/<user>/projects/bazlets",
)
diff --git a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java
index 2b7e337..7f0942b 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java
@@ -17,11 +17,11 @@
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.exceptions.InvalidNameException;
import com.google.gerrit.extensions.annotations.PluginData;
import com.google.gerrit.extensions.events.NewProjectCreatedListener;
-import com.google.gerrit.reviewdb.client.AccountGroup;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.group.InternalGroup;
@@ -191,7 +191,7 @@
// we need to check if group exist if if it does, get its
// uuid.
Optional<InternalGroup> group =
- groupCache.get(new AccountGroup.NameKey(rule.getGroup().getName()));
+ groupCache.get(AccountGroup.nameKey(rule.getGroup().getName()));
if (!group.isPresent()) {
log.error("Group {} not found", rule.getGroup().getName());
diff --git a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java
index f764b9e..331c968 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java
@@ -17,6 +17,8 @@
import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import com.google.gerrit.common.data.GroupReference;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.annotations.PluginCanonicalWebUrl;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.api.groups.Groups;
@@ -24,8 +26,6 @@
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException;
-import com.google.gerrit.reviewdb.client.AccountGroup;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.config.AllProjectsNameProvider;
diff --git a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRightsIT.java b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRightsIT.java
index 33a986d..5d562e0 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRightsIT.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRightsIT.java
@@ -15,19 +15,22 @@
package com.ericsson.gerrit.plugins.projectgroupstructure;
import static com.google.common.truth.Truth.assertThat;
+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.LightweightPluginDaemonTest;
import com.google.gerrit.acceptance.TestPlugin;
+import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.Permission;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.restapi.Url;
-import com.google.gerrit.reviewdb.client.AccountGroup;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.project.ProjectConfig;
import com.google.gerrit.server.project.ProjectState;
+import com.google.inject.Inject;
import java.nio.file.Files;
import org.junit.Before;
import org.junit.Test;
@@ -37,6 +40,8 @@
sysModule = "com.ericsson.gerrit.plugins.projectgroupstructure.Module")
public class DefaultAccessRightsIT extends LightweightPluginDaemonTest {
+ @Inject private ProjectOperations projectOperations;
+
@Override
@Before
public void setUpTestPlugin() throws Exception {
@@ -60,8 +65,16 @@
super.setUpTestPlugin();
// These access rights are mandatory configuration for this plugin as
// documented in config.md
- allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.CREATE_GROUP);
- allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
+ projectOperations
+ .project(allProjects)
+ .forUpdate()
+ .add(allowCapability(GlobalCapability.CREATE_GROUP).group(REGISTERED_USERS))
+ .update();
+ projectOperations
+ .project(allProjects)
+ .forUpdate()
+ .add(allowCapability(GlobalCapability.CREATE_PROJECT).group(REGISTERED_USERS))
+ .update();
}
@Test
@@ -71,7 +84,7 @@
String projectName = name("someProject");
userRestSession.put("/projects/" + projectName, in).assertCreated();
- ProjectState projectState = projectCache.get(new Project.NameKey(projectName));
+ ProjectState projectState = projectCache.get(Project.nameKey(projectName));
AccountGroup.UUID ownerUUID = projectState.getOwners().iterator().next();
ProjectConfig projectConfig = projectState.getConfig();
@@ -126,11 +139,7 @@
adminRestSession.put("/projects/" + Url.encode(projectName), in).assertCreated();
assertThat(
- projectCache
- .get(new Project.NameKey(projectName))
- .getConfig()
- .getAccessSections()
- .size())
+ projectCache.get(Project.nameKey(projectName)).getConfig().getAccessSections().size())
.isEqualTo(0);
}
}
diff --git a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java
index f390a30..b190c59 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java
@@ -15,6 +15,7 @@
package com.ericsson.gerrit.plugins.projectgroupstructure;
import static com.google.common.truth.Truth.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.base.Charsets;
@@ -23,15 +24,17 @@
import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.TestPlugin;
+import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.GroupReference;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.api.groups.GroupApi;
import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.restapi.Url;
-import com.google.gerrit.reviewdb.client.AccountGroup;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.project.ProjectConfig;
import com.google.gerrit.server.project.ProjectState;
+import com.google.inject.Inject;
import org.junit.Before;
import org.junit.Test;
@@ -40,6 +43,8 @@
sysModule = "com.ericsson.gerrit.plugins.projectgroupstructure.Module")
public class ProjectCreationValidatorIT extends LightweightPluginDaemonTest {
+ @Inject private ProjectOperations projectOperations;
+
private static final String PLUGIN_NAME = "project-group-structure";
@Override
@@ -48,8 +53,16 @@
super.setUpTestPlugin();
// These access rights are mandatory configuration for this plugin as
// documented in config.md
- allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.CREATE_GROUP);
- allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
+ projectOperations
+ .project(allProjects)
+ .forUpdate()
+ .add(allowCapability(GlobalCapability.CREATE_GROUP).group(REGISTERED_USERS))
+ .update();
+ projectOperations
+ .project(allProjects)
+ .forUpdate()
+ .add(allowCapability(GlobalCapability.CREATE_PROJECT).group(REGISTERED_USERS))
+ .update();
}
@Test
@@ -159,18 +172,18 @@
ProjectInput in = new ProjectInput();
in.permissionsOnly = true;
userRestSession.put("/projects/" + rootProject, in).assertCreated();
- ProjectState projectState = projectCache.get(new Project.NameKey(rootProject));
+ ProjectState projectState = projectCache.get(Project.nameKey(rootProject));
assertThat(projectState.getOwners().size()).isEqualTo(1);
assertThat(projectState.getOwners())
.contains(
- groupCache.get(new AccountGroup.NameKey(rootProject + "-admins")).get().getGroupUUID());
+ groupCache.get(AccountGroup.nameKey(rootProject + "-admins")).get().getGroupUUID());
// case when <project-name>-admins group already exists
rootProject = name("rootProject2");
String existingGroupName = rootProject + "-admins";
gApi.groups().create(existingGroupName);
userRestSession.put("/projects/" + rootProject, in).assertCreated();
- projectState = projectCache.get(new Project.NameKey(rootProject));
+ projectState = projectCache.get(Project.nameKey(rootProject));
assertThat(projectState.getOwners().size()).isEqualTo(1);
String expectedOwnerGroup =
existingGroupName
@@ -180,8 +193,7 @@
.toString()
.substring(0, 7);
assertThat(projectState.getOwners())
- .contains(
- groupCache.get(new AccountGroup.NameKey(expectedOwnerGroup)).get().getGroupUUID());
+ .contains(groupCache.get(AccountGroup.nameKey(expectedOwnerGroup)).get().getGroupUUID());
}
@Test
@@ -213,7 +225,7 @@
GroupApi dGroup = gApi.groups().create(delegatingGroup);
dGroup.addMembers(user.username());
// the group is in the project.config
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();
String gId = gApi.groups().id(delegatingGroup).get().id;
@@ -236,7 +248,7 @@
String delegatingGroup = name("someGroup");
GroupApi dGroup = gApi.groups().create(delegatingGroup);
dGroup.addMembers(user.username());
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();
String gId = gApi.groups().id(delegatingGroup).get().id;
@@ -252,21 +264,18 @@
in.parent = parent;
String childProject = parent + "/childProject";
userRestSession.put("/projects/" + Url.encode(childProject), in).assertCreated();
- ProjectState projectState = projectCache.get(new Project.NameKey(childProject));
+ ProjectState projectState = projectCache.get(Project.nameKey(childProject));
assertThat(projectState.getOwners().size()).isEqualTo(1);
assertThat(projectState.getOwners())
.contains(
- groupCache
- .get(new AccountGroup.NameKey(childProject + "-admins"))
- .get()
- .getGroupUUID());
+ groupCache.get(AccountGroup.nameKey(childProject + "-admins")).get().getGroupUUID());
// case when <project-name>-admins group already exists
String childProject2 = parent + "/childProject2";
String existingGroupName = childProject2 + "-admins";
gApi.groups().create(existingGroupName);
userRestSession.put("/projects/" + Url.encode(childProject2), in).assertCreated();
- projectState = projectCache.get(new Project.NameKey(childProject2));
+ projectState = projectCache.get(Project.nameKey(childProject2));
assertThat(projectState.getOwners().size()).isEqualTo(1);
String expectedOwnerGroup =
existingGroupName
@@ -276,8 +285,7 @@
.toString()
.substring(0, 7);
assertThat(projectState.getOwners())
- .contains(
- groupCache.get(new AccountGroup.NameKey(expectedOwnerGroup)).get().getGroupUUID());
+ .contains(groupCache.get(AccountGroup.nameKey(expectedOwnerGroup)).get().getGroupUUID());
}
@Test
@@ -291,7 +299,7 @@
String delegatingGroup = name("someGroup");
GroupApi dGroup = gApi.groups().create(delegatingGroup);
dGroup.addMembers(user.username());
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();
String gId = gApi.groups().id(delegatingGroup).get().id;
@@ -308,7 +316,7 @@
in.parent = parent;
String childProject = parent + "/childProject";
userRestSession.put("/projects/" + Url.encode(childProject), in).assertCreated();
- ProjectState projectState = projectCache.get(new Project.NameKey(childProject));
+ ProjectState projectState = projectCache.get(Project.nameKey(childProject));
assertThat(projectState.getOwners().size()).isEqualTo(0);
}
@@ -334,7 +342,7 @@
GroupApi dGroup = gApi.groups().create(delegatingGroup);
dGroup.addMembers(user.username());
// the group is in the project.config
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();
cfg.getPluginConfig(PLUGIN_NAME)
@@ -371,7 +379,7 @@
dGroup.addGroups(nestedGroup);
// the group is in the project.config
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();
String gId = gApi.groups().id(delegatingGroup).get().id;
@@ -406,7 +414,7 @@
gApi.groups().create(delegatingGroup);
// The user is not added to the delegated group
// the group is in the project.config
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();
String gId = gApi.groups().id(delegatingGroup).get().id;
@@ -439,7 +447,7 @@
// The delegating group is not created
String delegatingGroup = name("groupB");
// the group is in the project.config
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();
String gId = "fake-gId";
@@ -474,7 +482,7 @@
GroupApi dGroup = gApi.groups().create(delegatingGroup);
dGroup.addMembers(user.username());
// the group is in the project.config
- Project.NameKey parentNameKey = new Project.NameKey(parent);
+ Project.NameKey parentNameKey = Project.nameKey(parent);
try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
ProjectConfig cfg = cfgUpdate.getConfig();