Search in sources :

Example 1 with PluginProjectPermissionDefinition

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";
                }
            });
        }
    };
}
Also used : CapabilityDefinition(com.google.gerrit.extensions.config.CapabilityDefinition) PluginProjectPermissionDefinition(com.google.gerrit.extensions.config.PluginProjectPermissionDefinition) AbstractModule(com.google.inject.AbstractModule)

Example 2 with PluginProjectPermissionDefinition

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);
    }
}
Also used : PermissionInfo(com.google.gerrit.extensions.api.access.PermissionInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PermissionRuleInfo(com.google.gerrit.extensions.api.access.PermissionRuleInfo) ProjectAccessInfo(com.google.gerrit.extensions.api.access.ProjectAccessInfo) AccessSectionInfo(com.google.gerrit.extensions.api.access.AccessSectionInfo) ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput) PluginProjectPermissionDefinition(com.google.gerrit.extensions.config.PluginProjectPermissionDefinition) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

PluginProjectPermissionDefinition (com.google.gerrit.extensions.config.PluginProjectPermissionDefinition)2 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)1 AccessSectionInfo (com.google.gerrit.extensions.api.access.AccessSectionInfo)1 PermissionInfo (com.google.gerrit.extensions.api.access.PermissionInfo)1 PermissionRuleInfo (com.google.gerrit.extensions.api.access.PermissionRuleInfo)1 ProjectAccessInfo (com.google.gerrit.extensions.api.access.ProjectAccessInfo)1 ProjectAccessInput (com.google.gerrit.extensions.api.access.ProjectAccessInput)1 CapabilityDefinition (com.google.gerrit.extensions.config.CapabilityDefinition)1 AbstractModule (com.google.inject.AbstractModule)1 Test (org.junit.Test)1