use of com.google.gerrit.extensions.config.PluginProjectPermissionDefinition in project gerrit by GerritCodeReview.
the class PluginAccessIT method createModule.
@Override
public Module createModule() {
return new AbstractModule() {
@Override
protected void configure() {
bind(CapabilityDefinition.class).annotatedWith(Exports.named(TEST_PLUGIN_CAPABILITY)).toInstance(new CapabilityDefinition() {
@Override
public String getDescription() {
return "A Plugin Capability";
}
});
bind(PluginProjectPermissionDefinition.class).annotatedWith(Exports.named(TEST_PLUGIN_PROJECT_PERMISSION)).toInstance(new PluginProjectPermissionDefinition() {
@Override
public String getDescription() {
return "A Plugin Project Permission";
}
});
}
};
}
use of com.google.gerrit.extensions.config.PluginProjectPermissionDefinition in project gerrit by GerritCodeReview.
the class AccessIT method addAccessSectionForPluginPermission.
@Test
public void addAccessSectionForPluginPermission() throws Exception {
try (Registration registration = extensionRegistry.newRegistration().add(new PluginProjectPermissionDefinition() {
@Override
public String getDescription() {
return "A Plugin Project Permission";
}
}, "fooPermission")) {
ProjectAccessInput accessInput = newProjectAccessInput();
AccessSectionInfo accessSectionInfo = newAccessSectionInfo();
PermissionInfo foo = newPermissionInfo();
PermissionRuleInfo pri = new PermissionRuleInfo(PermissionRuleInfo.Action.ALLOW, false);
foo.rules.put(SystemGroupBackend.REGISTERED_USERS.get(), pri);
accessSectionInfo.permissions.put("plugin-" + ExtensionRegistry.PLUGIN_NAME + "-fooPermission", foo);
accessInput.add.put(REFS_HEADS, accessSectionInfo);
ProjectAccessInfo updatedAccessSectionInfo = pApi().access(accessInput);
assertThat(updatedAccessSectionInfo.local).isEqualTo(accessInput.add);
assertThat(pApi().access().local).isEqualTo(accessInput.add);
}
}
Aggregations