Search in sources :

Example 41 with ConfiguredWithCode

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"));
}
Also used : Jenkins(jenkins.model.Jenkins) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 42 with ConfiguredWithCode

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());
}
Also used : Jenkins(jenkins.model.Jenkins) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 43 with ConfiguredWithCode

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));
}
Also used : CNode(io.jenkins.plugins.casc.model.CNode) Util.toYamlString(io.jenkins.plugins.casc.misc.Util.toYamlString) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 44 with ConfiguredWithCode

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));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Util.toYamlString(io.jenkins.plugins.casc.misc.Util.toYamlString) WebClient(org.jvnet.hudson.test.JenkinsRule.WebClient) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 45 with ConfiguredWithCode

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());
}
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)

Aggregations

ConfiguredWithCode (io.jenkins.plugins.casc.misc.ConfiguredWithCode)52 Test (org.junit.Test)51 Issue (org.jvnet.hudson.test.Issue)18 CNode (io.jenkins.plugins.casc.model.CNode)16 Jenkins (jenkins.model.Jenkins)15 ConfigurationContext (io.jenkins.plugins.casc.ConfigurationContext)8 ConfiguratorRegistry (io.jenkins.plugins.casc.ConfiguratorRegistry)8 Util.toYamlString (io.jenkins.plugins.casc.misc.Util.toYamlString)8 Mapping (io.jenkins.plugins.casc.model.Mapping)7 BasicSSHUserPrivateKey (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey)5 Configurator (io.jenkins.plugins.casc.Configurator)5 ProxyConfiguration (hudson.ProxyConfiguration)4 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)3 UsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials)3 AdminWhitelistRule (jenkins.security.s2m.AdminWhitelistRule)3 CredentialsRootConfigurator (com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator)2 Role (com.michelin.cio.hudson.plugins.rolestrategy.Role)2 RoleBasedAuthorizationStrategy (com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy)2 FreeStyleProject (hudson.model.FreeStyleProject)2 User (hudson.model.User)2