use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class SeedJobTest method configure_seed_job.
@Test
@ConfiguredWithCode("SeedJobTest.yml")
public void configure_seed_job() {
final Jenkins jenkins = Jenkins.get();
assertNotNull(jenkins.getItem("testJob1"));
assertNotNull(jenkins.getItem("testJob2"));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class AgentProtocolsTest method configure_agent_protocols.
@Test
@ConfiguredWithCode(value = "AgentProtocolsTest.yml")
public void configure_agent_protocols() {
final Jenkins jenkins = Jenkins.get();
final Set<String> agentProtocols = Arrays.stream(new String[] { "JNLP4-connect", "Ping" }).collect(Collectors.toSet());
assertEquals(agentProtocols, jenkins.getAgentProtocols());
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ConfigurationAsCodeTest method string_to_literal_in_export.
@Test
@ConfiguredWithCode("multi-line2.yml")
public void string_to_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 doViewExport_should_require_authentication.
@Test
@ConfiguredWithCode("admin.yml")
public void doViewExport_should_require_authentication() throws Exception {
WebClient client = j.createWebClient();
WebRequest request = new WebRequest(client.createCrumbedUrl("configuration-as-code/viewExport"), POST);
WebResponse response = client.loadWebResponse(request);
assertThat(response.getStatusCode(), is(403));
String user = "admin";
WebClient loggedInClient = client.login(user, user);
response = loggedInClient.loadWebResponse(request);
assertThat(response.getStatusCode(), is(200));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class AdminWhitelistRuleConfiguratorTest method checkM2ASecurityKillSwitch_enabled.
@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_disabled.yml")
public void checkM2ASecurityKillSwitch_enabled() {
final Jenkins jenkins = Jenkins.get();
AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
Assert.assertTrue("MasterToAgent Security should be enabled", rule.getMasterKillSwitch());
}
Aggregations