use of org.jenkinsci.plugins.casc.Configurator in project configuration-as-code-plugin by jenkinsci.
the class ProjectMatrixAuthorizationTest method shouldReturnCustomConfigurator.
@Test
public void shouldReturnCustomConfigurator() {
Configurator configurator = Configurator.lookup(ProjectMatrixAuthorizationStrategy.class);
assertNotNull("Failed to find configurator for GlobalMatrixAuthorizationStrategy", configurator);
assertEquals("Retrieved wrong configurator", ProjectMatrixAuthorizationStrategyConfigurator.class, configurator.getClass());
}
use of org.jenkinsci.plugins.casc.Configurator in project configuration-as-code-plugin by jenkinsci.
the class RoleBasedAuthorizationStrategyConfigurator method configure.
@Override
public RoleBasedAuthorizationStrategy configure(Object config) throws Exception {
// TODO: API should return a qualified type
final Configurator<RoleDefinition> roleDefinitionConfigurator = (Configurator<RoleDefinition>) Configurator.lookup(RoleDefinition.class);
if (roleDefinitionConfigurator == null) {
throw new IOException("Cannot find configurator for" + RoleDefinition.class);
}
Map map = (Map) config;
Map<String, RoleMap> grantedRoles = new HashMap<>();
Object rolesConfig = map.get("roles");
if (rolesConfig != null) {
grantedRoles.put(RoleBasedAuthorizationStrategy.GLOBAL, retrieveRoleMap(rolesConfig, "global", roleDefinitionConfigurator));
grantedRoles.put(RoleBasedAuthorizationStrategy.PROJECT, retrieveRoleMap(rolesConfig, "items", roleDefinitionConfigurator));
grantedRoles.put(RoleBasedAuthorizationStrategy.SLAVE, retrieveRoleMap(rolesConfig, "agents", roleDefinitionConfigurator));
}
return new RoleBasedAuthorizationStrategy(grantedRoles);
}
use of org.jenkinsci.plugins.casc.Configurator in project configuration-as-code-plugin by jenkinsci.
the class GlobalMatrixAuthorizationTest method shouldReturnCustomConfigurator.
@Test
public void shouldReturnCustomConfigurator() {
Configurator configurator = Configurator.lookup(GlobalMatrixAuthorizationStrategy.class);
assertNotNull("Failed to find configurator for GlobalMatrixAuthorizationStrategy", configurator);
assertEquals("Retrieved wrong configurator", GlobalMatrixAuthorizationStrategyConfigurator.class, configurator.getClass());
}
use of org.jenkinsci.plugins.casc.Configurator in project configuration-as-code-plugin by jenkinsci.
the class GlobalMatrixAuthorizationTest method shouldReturnCustomConfiguratorForBaseType.
@Test
public void shouldReturnCustomConfiguratorForBaseType() {
Configurator c = Configurator.lookupForBaseType(AuthorizationStrategy.class, "globalMatrix");
assertNotNull("Failed to find configurator for GlobalMatrixAuthorizationStrategy", c);
assertEquals("Retrieved wrong configurator", GlobalMatrixAuthorizationStrategyConfigurator.class, c.getClass());
Configurator.lookup(GlobalMatrixAuthorizationStrategy.class);
}
use of org.jenkinsci.plugins.casc.Configurator in project configuration-as-code-plugin by jenkinsci.
the class ProjectMatrixAuthorizationTest method shouldReturnCustomConfiguratorForBaseType.
@Test
public void shouldReturnCustomConfiguratorForBaseType() {
Configurator c = Configurator.lookupForBaseType(AuthorizationStrategy.class, "projectMatrix");
assertNotNull("Failed to find configurator for ProjectMatrixAuthorizationStrategy", c);
assertEquals("Retrieved wrong configurator", ProjectMatrixAuthorizationStrategyConfigurator.class, c.getClass());
Configurator.lookup(ProjectMatrixAuthorizationStrategy.class);
}
Aggregations