Search in sources :

Example 1 with AdminWhitelistRule

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

the class AdminWhitelistRuleConfiguratorTest method checkM2SSecurityKillSwitch_enabled.

@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Slave2MasterSecurityKillSwitch_enabled.yml")
public void checkM2SSecurityKillSwitch_enabled() throws Exception {
    final Jenkins jenkins = Jenkins.getInstance();
    AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
    Assert.assertTrue("MasterToSlave Security should be enabled", rule.getMasterKillSwitch());
}
Also used : Jenkins(jenkins.model.Jenkins) AdminWhitelistRule(jenkins.security.s2m.AdminWhitelistRule) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 2 with AdminWhitelistRule

use of jenkins.security.s2m.AdminWhitelistRule 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 3 with AdminWhitelistRule

use of jenkins.security.s2m.AdminWhitelistRule 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)

Example 4 with AdminWhitelistRule

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

the class AdminWhitelistRuleConfiguratorTest method checkM2ASecurityKillSwitch_disabled.

@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_enabled.yml")
public void checkM2ASecurityKillSwitch_disabled() {
    final Jenkins jenkins = Jenkins.get();
    AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
    Assert.assertFalse("MasterToAgent Security should be disabled", rule.getMasterKillSwitch());
}
Also used : Jenkins(jenkins.model.Jenkins) AdminWhitelistRule(jenkins.security.s2m.AdminWhitelistRule) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 5 with AdminWhitelistRule

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

the class AdminWhitelistRuleConfiguratorTest method checkM2SSecurityKillSwitch_disabled.

@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Slave2MasterSecurityKillSwitch_disabled.yml")
public void checkM2SSecurityKillSwitch_disabled() throws Exception {
    final Jenkins jenkins = Jenkins.getInstance();
    AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
    Assert.assertFalse("MasterToSlave Security should be disabled", rule.getMasterKillSwitch());
}
Also used : Jenkins(jenkins.model.Jenkins) AdminWhitelistRule(jenkins.security.s2m.AdminWhitelistRule) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Aggregations

AdminWhitelistRule (jenkins.security.s2m.AdminWhitelistRule)7 Jenkins (jenkins.model.Jenkins)6 Test (org.junit.Test)6 Issue (org.jvnet.hudson.test.Issue)6 ConfiguredWithCode (io.jenkins.plugins.casc.misc.ConfiguredWithCode)4 ConfigurationContext (io.jenkins.plugins.casc.ConfigurationContext)2 Configurator (io.jenkins.plugins.casc.Configurator)2 ConfiguratorRegistry (io.jenkins.plugins.casc.ConfiguratorRegistry)2 CNode (io.jenkins.plugins.casc.model.CNode)2 Mapping (io.jenkins.plugins.casc.model.Mapping)2 MasterKillSwitchConfiguration (jenkins.security.s2m.MasterKillSwitchConfiguration)2 ConfiguredWithCode (org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)2 Injector (com.google.inject.Injector)1