use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ConfigurationAsCodeTest method multiline_literal_stays_literal_in_export.
@Test
@ConfiguredWithCode("multi-line1.yml")
public void multiline_literal_stays_literal_in_export() throws Exception {
assertEquals("Welcome to our build server.\n\n" + "This Jenkins is 100% configured and managed 'as code'.\n", j.jenkins.getSystemMessage());
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
ConfigurationContext context = new ConfigurationContext(registry);
CNode systemMessage = getJenkinsRoot(context).get("systemMessage");
String exported = toYamlString(systemMessage);
String expected = "|\n" + " Welcome to our build server.\n\n" + " This Jenkins is 100% configured and managed 'as code'.\n";
assertThat(exported, is(expected));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ConfigurationAsCodeTest method checkWith_should_pass_against_input_which_has_same_entries_with_initial_config.
@Test
@Issue("Issue #653")
@ConfiguredWithCode("aNonEmpty.yml")
public void checkWith_should_pass_against_input_which_has_same_entries_with_initial_config() throws Exception {
String rawConf = getClass().getResource("JenkinsConfigTest.yml").toExternalForm();
YamlSource input = YamlSource.of(rawConf);
Map<Source, String> actual = ConfigurationAsCode.get().checkWith(input);
assertThat(actual.size(), is(0));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode 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());
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode 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());
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode 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());
}
Aggregations