use of com.google.gerrit.entities.AccessSection in project gerrit by GerritCodeReview.
the class AccountIT method assertLabelPermission.
protected void assertLabelPermission(Project.NameKey project, GroupReference groupReference, String ref, boolean exclusive, String labelName, int min, int max) {
Optional<AccessSection> accessSection = projectCache.get(project).orElseThrow(illegalState(project)).getConfig().getAccessSection(ref);
assertThat(accessSection).isPresent();
String permissionName = Permission.LABEL + labelName;
Permission permission = accessSection.get().getPermission(permissionName);
assertPermission(permission, permissionName, exclusive, labelName);
assertPermissionRule(permission.getRule(groupReference), groupReference, Action.ALLOW, false, min, max);
}
use of com.google.gerrit.entities.AccessSection in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method assertPermissions.
protected void assertPermissions(Project.NameKey project, GroupReference groupReference, String ref, boolean exclusive, String... permissionNames) {
Optional<AccessSection> accessSection = projectCache.get(project).orElseThrow(illegalState(project)).getConfig().getAccessSection(ref);
assertThat(accessSection).isPresent();
for (String permissionName : permissionNames) {
Permission permission = accessSection.get().getPermission(permissionName);
assertPermission(permission, permissionName, exclusive, null);
assertPermissionRule(permission.getRule(groupReference), groupReference, Action.ALLOW, false, 0, 0);
}
}
use of com.google.gerrit.entities.AccessSection in project gerrit by GerritCodeReview.
the class ProjectControl method canPerformOnAnyRef.
private boolean canPerformOnAnyRef(String permissionName) {
for (SectionMatcher matcher : access()) {
AccessSection section = matcher.getSection();
Permission permission = section.getPermission(permissionName);
if (permission == null) {
continue;
}
Boolean can = canPerform(permissionName, section, permission);
if (can != null) {
return can;
}
}
return false;
}
use of com.google.gerrit.entities.AccessSection in project gerrit by GerritCodeReview.
the class ProjectControl method canPerformOnTagRef.
private boolean canPerformOnTagRef(String permissionName) {
for (SectionMatcher matcher : access()) {
AccessSection section = matcher.getSection();
if (section.getName().startsWith(REFS_TAGS) || section.getName().startsWith(REGEX_PREFIX + REFS_TAGS)) {
Permission permission = section.getPermission(permissionName);
if (permission == null) {
continue;
}
Boolean can = canPerform(permissionName, section, permission);
if (can != null) {
return can;
}
}
}
return false;
}
use of com.google.gerrit.entities.AccessSection in project gerrit by GerritCodeReview.
the class AccessIT method grantRevertPermissionOnlyWorksOnce.
@Test
public void grantRevertPermissionOnlyWorksOnce() throws Exception {
grantRevertPermission.execute(newProjectName);
grantRevertPermission.execute(newProjectName);
try (Repository repo = repoManager.openRepository(newProjectName)) {
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, newProjectName, repo);
ProjectConfig projectConfig = projectConfigFactory.read(md);
AccessSection all = projectConfig.getAccessSection(AccessSection.ALL);
Permission permission = all.getPermission(Permission.REVERT);
assertThat(permission.getRules()).hasSize(1);
}
}
Aggregations