use of com.google.gerrit.common.data.Permission in project gerrit by GerritCodeReview.
the class ProjectControl method allRefPatterns.
private Set<String> allRefPatterns(String permissionName) {
Set<String> all = new HashSet<>();
for (SectionMatcher matcher : access()) {
AccessSection section = matcher.section;
Permission permission = section.getPermission(permissionName);
if (permission != null) {
all.add(section.getName());
}
}
return all;
}
use of com.google.gerrit.common.data.Permission in project gerrit by GerritCodeReview.
the class ProjectControl method canPerformOnAnyRef.
private boolean canPerformOnAnyRef(String permissionName) {
for (SectionMatcher matcher : access()) {
AccessSection section = matcher.section;
Permission permission = section.getPermission(permissionName);
if (permission == null) {
continue;
}
for (PermissionRule rule : permission.getRules()) {
if (rule.isBlock() || rule.isDeny() || !match(rule)) {
continue;
}
//
if (controlForRef(section.getName()).canPerform(permissionName)) {
return true;
}
break;
}
}
return false;
}
use of com.google.gerrit.common.data.Permission in project gerrit by GerritCodeReview.
the class GetCommitIT method unblockRead.
private void unblockRead() throws Exception {
ProjectConfig pc = projectCache.checkedGet(project).getConfig();
pc.getAccessSection("refs/*").remove(new Permission(Permission.READ));
saveProjectConfig(project, pc);
}
use of com.google.gerrit.common.data.Permission in project gerrit by GerritCodeReview.
the class ProjectAccessHandler method replace.
private void replace(ProjectConfig config, Set<String> toDelete, AccessSection section) throws NoSuchGroupException {
for (Permission permission : section.getPermissions()) {
for (PermissionRule rule : permission.getRules()) {
lookupGroup(rule);
}
}
config.replace(section);
toDelete.remove(section.getName());
}
use of com.google.gerrit.common.data.Permission in project gerrit by GerritCodeReview.
the class ProjectConfigTest method readConfig.
@Test
public void readConfig() throws Exception {
RevCommit rev = util.commit(//
util.tree(//
util.file("groups", util.blob(group(developers))), util.file("project.config", util.blob(//
"" + //
"[access \"refs/heads/*\"]\n" + //
" exclusiveGroupPermissions = read submit create\n" + //
" submit = group Developers\n" + //
" push = group Developers\n" + //
" read = group Developers\n" + //
"[accounts]\n" + //
" sameGroupVisibility = deny group Developers\n" + //
" sameGroupVisibility = block group Staff\n" + //
"[contributor-agreement \"Individual\"]\n" + //
" description = A simple description\n" + //
" accepted = group Developers\n" + //
" accepted = group Staff\n" + //
" autoVerify = group Developers\n" + //
" agreementUrl = http://www.example.com/agree\n"))));
ProjectConfig cfg = read(rev);
assertThat(cfg.getAccountsSection().getSameGroupVisibility()).hasSize(2);
ContributorAgreement ca = cfg.getContributorAgreement("Individual");
assertThat(ca.getName()).isEqualTo("Individual");
assertThat(ca.getDescription()).isEqualTo("A simple description");
assertThat(ca.getAgreementUrl()).isEqualTo("http://www.example.com/agree");
assertThat(ca.getAccepted()).hasSize(2);
assertThat(ca.getAccepted().get(0).getGroup()).isEqualTo(developers);
assertThat(ca.getAccepted().get(1).getGroup().getName()).isEqualTo("Staff");
assertThat(ca.getAutoVerify().getName()).isEqualTo("Developers");
AccessSection section = cfg.getAccessSection("refs/heads/*");
assertThat(section).isNotNull();
assertThat(cfg.getAccessSection("refs/*")).isNull();
Permission create = section.getPermission(Permission.CREATE);
Permission submit = section.getPermission(Permission.SUBMIT);
Permission read = section.getPermission(Permission.READ);
Permission push = section.getPermission(Permission.PUSH);
assertThat(create.getExclusiveGroup()).isTrue();
assertThat(submit.getExclusiveGroup()).isTrue();
assertThat(read.getExclusiveGroup()).isTrue();
assertThat(push.getExclusiveGroup()).isFalse();
}
Aggregations