use of com.google.gerrit.extensions.api.access.AccessSectionInfo in project gerrit by GerritCodeReview.
the class AccessIT method addGlobalCapabilityForNonRootProject.
@Test
public void addGlobalCapabilityForNonRootProject() throws Exception {
ProjectAccessInput accessInput = newProjectAccessInput();
AccessSectionInfo accessSectionInfo = createDefaultGlobalCapabilitiesAccessSectionInfo();
accessInput.add.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
exception.expect(BadRequestException.class);
pApi.access(accessInput);
}
use of com.google.gerrit.extensions.api.access.AccessSectionInfo in project gerrit by GerritCodeReview.
the class AccessIT method createDefaultAccessSectionInfo.
private AccessSectionInfo createDefaultAccessSectionInfo() {
AccessSectionInfo accessSection = newAccessSectionInfo();
PermissionInfo push = newPermissionInfo();
PermissionRuleInfo pri = new PermissionRuleInfo(PermissionRuleInfo.Action.ALLOW, false);
push.rules.put(SystemGroupBackend.REGISTERED_USERS.get(), pri);
accessSection.permissions.put(Permission.PUSH, push);
PermissionInfo codeReview = newPermissionInfo();
codeReview.label = LABEL_CODE_REVIEW;
pri = new PermissionRuleInfo(PermissionRuleInfo.Action.DENY, false);
codeReview.rules.put(SystemGroupBackend.REGISTERED_USERS.get(), pri);
pri = new PermissionRuleInfo(PermissionRuleInfo.Action.ALLOW, false);
pri.max = 1;
pri.min = -1;
codeReview.rules.put(SystemGroupBackend.PROJECT_OWNERS.get(), pri);
accessSection.permissions.put(Permission.LABEL + LABEL_CODE_REVIEW, codeReview);
return accessSection;
}
use of com.google.gerrit.extensions.api.access.AccessSectionInfo in project gerrit by GerritCodeReview.
the class AccessIT method setPermissionsWithDisallowedUser.
@Test
public void setPermissionsWithDisallowedUser() throws Exception {
// Add initial permission set
ProjectAccessInput accessInput = newProjectAccessInput();
AccessSectionInfo accessSectionInfo = createAccessSectionInfoDenyAll();
// Disallow READ
accessInput.add.put(REFS_ALL, accessSectionInfo);
pApi.access(accessInput);
// Create a change to apply
ProjectAccessInput accessInfoToApply = newProjectAccessInput();
AccessSectionInfo accessSectionInfoToApply = createDefaultAccessSectionInfo();
accessInfoToApply.add.put(REFS_HEADS, accessSectionInfoToApply);
setApiUser(user);
exception.expect(ResourceNotFoundException.class);
gApi.projects().name(newProjectName).access();
}
use of com.google.gerrit.extensions.api.access.AccessSectionInfo in project gerrit by GerritCodeReview.
the class AccessIT method createAccessSectionInfoDenyAll.
private AccessSectionInfo createAccessSectionInfoDenyAll() {
AccessSectionInfo accessSection = newAccessSectionInfo();
PermissionInfo read = newPermissionInfo();
PermissionRuleInfo pri = new PermissionRuleInfo(PermissionRuleInfo.Action.DENY, false);
read.rules.put(SystemGroupBackend.ANONYMOUS_USERS.get(), pri);
accessSection.permissions.put(Permission.READ, read);
return accessSection;
}
use of com.google.gerrit.extensions.api.access.AccessSectionInfo in project gerrit by GerritCodeReview.
the class AccessIT method getPermissionsWithDisallowedUser.
@Test
public void getPermissionsWithDisallowedUser() throws Exception {
// Add initial permission set
ProjectAccessInput accessInput = newProjectAccessInput();
AccessSectionInfo accessSectionInfo = createAccessSectionInfoDenyAll();
// Disallow READ
accessInput.add.put(REFS_ALL, accessSectionInfo);
pApi.access(accessInput);
setApiUser(user);
exception.expect(ResourceNotFoundException.class);
gApi.projects().name(newProjectName).access();
}
Aggregations