use of com.google.gerrit.extensions.config.CapabilityDefinition in project gerrit by GerritCodeReview.
the class TestPluginModule method configure.
@Override
protected void configure() {
bind(CapabilityDefinition.class).annotatedWith(Exports.named(PLUGIN_CAPABILITY)).toInstance(new CapabilityDefinition() {
@Override
public String getDescription() {
return "Print Hello";
}
});
install(new RestApiModule() {
@Override
protected void configure() {
DynamicMap.mapOf(binder(), PLUGIN_KIND);
child(CONFIG_KIND, PLUGIN_COLLECTION).to(PluginCollection.class);
get(PLUGIN_KIND).to(GetTestPlugin.class);
create(PLUGIN_KIND).to(CreateTestPlugin.class);
}
});
}
use of com.google.gerrit.extensions.config.CapabilityDefinition 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.CapabilityDefinition in project gerrit by GerritCodeReview.
the class AccessIT method addPluginGlobalCapability.
@Test
public void addPluginGlobalCapability() throws Exception {
try (Registration registration = extensionRegistry.newRegistration().add(new CapabilityDefinition() {
@Override
public String getDescription() {
return "A Plugin Global Capability";
}
}, "fooCapability")) {
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(ExtensionRegistry.PLUGIN_NAME + "-fooCapability", foo);
accessInput.add.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
ProjectAccessInfo updatedAccessSectionInfo = gApi.projects().name(allProjects.get()).access(accessInput);
assertThatMap(updatedAccessSectionInfo.local.get(AccessSection.GLOBAL_CAPABILITIES).permissions).keys().containsAtLeastElementsIn(accessSectionInfo.permissions.keySet());
}
}
use of com.google.gerrit.extensions.config.CapabilityDefinition in project gerrit by GerritCodeReview.
the class ListCapabilitiesTest method setUp.
@Before
public void setUp() throws Exception {
AbstractModule mod = new AbstractModule() {
@Override
protected void configure() {
DynamicMap.mapOf(binder(), CapabilityDefinition.class);
DynamicMap.mapOf(binder(), PluginProjectPermissionDefinition.class);
bind(CapabilityDefinition.class).annotatedWith(Exports.named("foo")).toInstance(new CapabilityDefinition() {
@Override
public String getDescription() {
return "Print Hello";
}
});
bind(CapabilityDefinition.class).annotatedWith(Exports.named("bar")).toInstance(new CapabilityDefinition() {
@Override
public String getDescription() {
return "Print Hello";
}
});
bind(PermissionBackend.class).to(FakePermissionBackend.class);
}
};
injector = Guice.createInjector(mod);
}
Aggregations