Search in sources :

Example 1 with MasterKillSwitchConfiguration

use of jenkins.security.s2m.MasterKillSwitchConfiguration in project configuration-as-code-plugin by jenkinsci.

the class AdminWhitelistRuleConfiguratorTest method checkA2MAccessControl_disable.

@Test
@Issue("Issue #172")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_disabled.yml")
public void checkA2MAccessControl_disable() throws Exception {
    final Jenkins jenkins = Jenkins.get();
    MasterKillSwitchConfiguration config = jenkins.getDescriptorByType(MasterKillSwitchConfiguration.class);
    Assert.assertFalse("Agent → Master Access Control should be disabled", config.getMasterToSlaveAccessControl());
    AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
    ConfiguratorRegistry registry = ConfiguratorRegistry.get();
    ConfigurationContext context = new ConfigurationContext(registry);
    final Configurator c = context.lookupOrFail(AdminWhitelistRule.class);
    final CNode node = c.describe(rule, context);
    final Mapping agent = node.asMapping();
    assertEquals("false", agent.get("enabled").toString());
}
Also used : Jenkins(jenkins.model.Jenkins) CNode(io.jenkins.plugins.casc.model.CNode) ConfiguratorRegistry(io.jenkins.plugins.casc.ConfiguratorRegistry) ConfigurationContext(io.jenkins.plugins.casc.ConfigurationContext) AdminWhitelistRule(jenkins.security.s2m.AdminWhitelistRule) Configurator(io.jenkins.plugins.casc.Configurator) MasterKillSwitchConfiguration(jenkins.security.s2m.MasterKillSwitchConfiguration) Mapping(io.jenkins.plugins.casc.model.Mapping) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 2 with MasterKillSwitchConfiguration

use of jenkins.security.s2m.MasterKillSwitchConfiguration in project configuration-as-code-plugin by jenkinsci.

the class AdminWhitelistRuleConfiguratorTest method checkA2MAccessControl_enabled.

@Test
@Issue("Issue #172")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_enabled.yml")
public void checkA2MAccessControl_enabled() throws Exception {
    final Jenkins jenkins = Jenkins.get();
    MasterKillSwitchConfiguration config = jenkins.getDescriptorByType(MasterKillSwitchConfiguration.class);
    Assert.assertTrue("Agent → Master Access Control should be enabled", config.getMasterToSlaveAccessControl());
    AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
    ConfiguratorRegistry registry = ConfiguratorRegistry.get();
    ConfigurationContext context = new ConfigurationContext(registry);
    final Configurator c = context.lookupOrFail(AdminWhitelistRule.class);
    final CNode node = c.describe(rule, context);
    final Mapping agent = node.asMapping();
    assertEquals("true", agent.get("enabled").toString());
}
Also used : Jenkins(jenkins.model.Jenkins) CNode(io.jenkins.plugins.casc.model.CNode) ConfiguratorRegistry(io.jenkins.plugins.casc.ConfiguratorRegistry) ConfigurationContext(io.jenkins.plugins.casc.ConfigurationContext) AdminWhitelistRule(jenkins.security.s2m.AdminWhitelistRule) Configurator(io.jenkins.plugins.casc.Configurator) MasterKillSwitchConfiguration(jenkins.security.s2m.MasterKillSwitchConfiguration) Mapping(io.jenkins.plugins.casc.model.Mapping) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Aggregations

ConfigurationContext (io.jenkins.plugins.casc.ConfigurationContext)2 Configurator (io.jenkins.plugins.casc.Configurator)2 ConfiguratorRegistry (io.jenkins.plugins.casc.ConfiguratorRegistry)2 ConfiguredWithCode (io.jenkins.plugins.casc.misc.ConfiguredWithCode)2 CNode (io.jenkins.plugins.casc.model.CNode)2 Mapping (io.jenkins.plugins.casc.model.Mapping)2 Jenkins (jenkins.model.Jenkins)2 AdminWhitelistRule (jenkins.security.s2m.AdminWhitelistRule)2 MasterKillSwitchConfiguration (jenkins.security.s2m.MasterKillSwitchConfiguration)2 Test (org.junit.Test)2 Issue (org.jvnet.hudson.test.Issue)2