Search in sources :

Example 6 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.

the class ActiveDirectoryTest method configure_active_directory.

@Test
@ConfiguredWithCode(value = "ActiveDirectoryTest.yml")
public void configure_active_directory() throws Exception {
    final Jenkins jenkins = Jenkins.getInstance();
    final ActiveDirectorySecurityRealm realm = (ActiveDirectorySecurityRealm) jenkins.getSecurityRealm();
    assertEquals(1, realm.domains.size());
    final ActiveDirectoryDomain domain = realm.domains.get(0);
    assertEquals("acme", domain.name);
    assertEquals("admin", domain.bindName);
    assertEquals("ADMIN123", domain.bindPassword.getPlainText());
    assertEquals("ad1.acme.com:123,ad2.acme.com:456", domain.servers);
    assertTrue(realm.removeIrrelevantGroups);
    assertTrue(realm.startTls);
}
Also used : Jenkins(jenkins.model.Jenkins) ActiveDirectorySecurityRealm(hudson.plugins.active_directory.ActiveDirectorySecurityRealm) ActiveDirectoryDomain(hudson.plugins.active_directory.ActiveDirectoryDomain) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 7 with ConfiguredWithCode

use of org.jenkinsci.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() throws Exception {
    final Jenkins jenkins = Jenkins.getInstance();
    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(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 8 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.

the class DockerCloudTest method configure_docker_cloud.

@Test
@ConfiguredWithCode("DockerCloudTest.yml")
public void configure_docker_cloud() throws Exception {
    final DockerCloud docker = DockerCloud.getCloudByName("docker");
    assertNotNull(docker);
    assertNotNull(docker.getDockerApi());
    assertNotNull(docker.getDockerApi().getDockerHost());
    assertEquals("unix:///var/run/docker.sock", docker.getDockerApi().getDockerHost().getUri());
    final DockerTemplate template = docker.getTemplate("jenkins/slave");
    checkTemplate(template, "docker-agent", "jenkins", "/home/jenkins/agent", "10");
}
Also used : DockerTemplate(com.nirima.jenkins.plugins.docker.DockerTemplate) DockerCloud(com.nirima.jenkins.plugins.docker.DockerCloud) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 9 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.

the class DockerCloudTest method update_docker_cloud.

@Test
@ConfiguredWithCode("DockerCloudTest/update_docker_cloud/DockerCloudTest1.yml")
public void update_docker_cloud() throws Exception {
    DockerCloud docker = DockerCloud.getCloudByName("docker");
    assertNotNull(docker);
    assertNotNull(docker.getDockerApi());
    assertNotNull(docker.getDockerApi().getDockerHost());
    assertEquals("unix:///var/run/docker.sock", docker.getDockerApi().getDockerHost().getUri());
    DockerTemplate template = docker.getTemplate(Label.get("docker-agent"));
    checkTemplate(template, "docker-agent", "jenkins", "/home/jenkins/agent", "10");
    TestConfiguration.withCode("DockerCloudTest/update_docker_cloud/DockerCloudTest2.yml").configure(getClass());
    docker = DockerCloud.getCloudByName("docker");
    assertNotNull(docker);
    assertNotNull(docker.getDockerApi());
    assertNotNull(docker.getDockerApi().getDockerHost());
    assertEquals("unix:///var/run/docker.sock", docker.getDockerApi().getDockerHost().getUri());
    template = docker.getTemplate(Label.get("docker-agent"));
    checkTemplate(template, "docker-agent", "jenkins", "/home/jenkins/agent", "10");
    template = docker.getTemplate(Label.get("generic"));
    checkTemplate(template, "generic", "jenkins", "/home/jenkins/agent2", "5");
}
Also used : DockerTemplate(com.nirima.jenkins.plugins.docker.DockerTemplate) DockerCloud(com.nirima.jenkins.plugins.docker.DockerCloud) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 10 with ConfiguredWithCode

use of org.jenkinsci.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() throws Exception {
    final Jenkins jenkins = Jenkins.getInstance();
    final TopLevelItem test = jenkins.getItem("configuration-as-code");
    assertNotNull(test);
    assertTrue(test instanceof WorkflowMultiBranchProject);
}
Also used : Jenkins(jenkins.model.Jenkins) WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) TopLevelItem(hudson.model.TopLevelItem) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Aggregations

ConfiguredWithCode (org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)21 Test (org.junit.Test)20 Jenkins (jenkins.model.Jenkins)13 Issue (org.jvnet.hudson.test.Issue)3 DockerCloud (com.nirima.jenkins.plugins.docker.DockerCloud)2 DockerTemplate (com.nirima.jenkins.plugins.docker.DockerTemplate)2 TopLevelItem (hudson.model.TopLevelItem)2 User (hudson.model.User)2 FullControlOnceLoggedInAuthorizationStrategy (hudson.security.FullControlOnceLoggedInAuthorizationStrategy)2 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)2 ArrayList (java.util.ArrayList)2 AdminWhitelistRule (jenkins.security.s2m.AdminWhitelistRule)2 Folder (com.cloudbees.hudson.plugins.folder.Folder)1 BasicSSHUserPrivateKey (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey)1 CertificateCredentials (com.cloudbees.plugins.credentials.common.CertificateCredentials)1 UsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials)1 Role (com.michelin.cio.hudson.plugins.rolestrategy.Role)1 RoleBasedAuthorizationStrategy (com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy)1 Computer (hudson.model.Computer)1 FreeStyleProject (hudson.model.FreeStyleProject)1