Search in sources :

Example 16 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class MavenConfiguratorTest method configure_maven_tool.

@Test
@ConfiguredWithReadme("maven/README.md#0")
public void configure_maven_tool() {
    final Maven.DescriptorImpl descriptor = ExtensionList.lookupSingleton(Maven.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);
    Maven.MavenInstallation maven = descriptor.getInstallations()[0];
    assertEquals("maven3", maven.getName());
    assertEquals("/maven3", maven.getHome());
    InstallSourceProperty installSourceProperty = maven.getProperties().get(InstallSourceProperty.class);
    assertEquals(1, installSourceProperty.installers.size());
    MavenInstaller installer = installSourceProperty.installers.get(MavenInstaller.class);
    assertEquals("3.8.4", installer.id);
}
Also used : Maven(hudson.tasks.Maven) InstallSourceProperty(hudson.tools.InstallSourceProperty) MavenInstaller(hudson.tasks.Maven.MavenInstaller) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 17 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class MesosTest method configure_mesos_cloud.

@Test
@ConfiguredWithReadme("mesos/README.md")
public void configure_mesos_cloud() {
    final MesosCloud cloud = Jenkins.get().clouds.get(MesosCloud.class);
    assertNotNull(cloud);
    assertFalse(cloud.isCheckpoint());
    assertThat(cloud.getCloudID(), is("mesos-name"));
    assertThat(cloud.getCredentialsId(), is("MESOS_CREDENTIALS"));
    assertThat(cloud.getDeclineOfferDuration(), is("600"));
    assertThat(cloud.getDescription(), is("My Mesos Cloud"));
    assertThat(cloud.getFrameworkName(), is("Jenkins Framework"));
    assertThat(cloud.getJenkinsURL(), is("https://jenkins.mesos.cloud"));
    assertThat(cloud.getMaster(), is("1.2.3.4:8000"));
    assertThat(cloud.getRole(), is("*"));
    assertThat(cloud.getSlavesUser(), is("jenkins"));
    assertThat(cloud.getSlavesUser(), is("jenkins"));
    final List<MesosSlaveInfo> slaves = cloud.getSlaveInfos();
    assertThat(slaves, hasSize(1));
    final MesosSlaveInfo slaveInfo = slaves.get(0);
    assertThat(slaveInfo.getLabelString(), is("docker"));
    assertThat(slaveInfo.getContainerInfo().getType(), is("DOCKER"));
    assertThat(slaveInfo.getContainerInfo().getDockerImage(), is("cloudbees/java-with-docker-client:latest"));
    assertThat(slaveInfo.getContainerInfo().getVolumes(), hasSize(2));
    assertThat(slaveInfo.getMinExecutors(), is(1));
    assertThat(slaveInfo.getMaxExecutors(), is(2));
    assertThat(slaveInfo.getMode(), is(Mode.NORMAL));
    assertThat(slaveInfo.getSlaveCpus(), is(0.1));
    assertThat(slaveInfo.getSlaveMem(), is(512));
    assertThat(slaveInfo.getRemoteFSRoot(), is("jenkins"));
    assertThat(slaveInfo.getJnlpArgs(), is(""));
    assertThat(slaveInfo.getSlaveAttributes().toString(), containsString("\"rack\":\"jenkins-build-agents\""));
    assertTrue(slaveInfo.isDefaultSlave());
}
Also used : MesosSlaveInfo(org.jenkinsci.plugins.mesos.MesosSlaveInfo) MesosCloud(org.jenkinsci.plugins.mesos.MesosCloud) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 18 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class LDAPTest method configure_ldap.

@Test
@ConfiguredWithReadme("ldap/README.md")
public void configure_ldap() {
    final Jenkins jenkins = Jenkins.get();
    final LDAPSecurityRealm securityRealm = (LDAPSecurityRealm) jenkins.getSecurityRealm();
    assertEquals(1, securityRealm.getConfigurations().size());
    assertTrue(securityRealm.getUserIdStrategy() instanceof IdStrategy.CaseInsensitive);
    assertTrue(securityRealm.getGroupIdStrategy() instanceof IdStrategy.CaseSensitive);
    final LDAPConfiguration configuration = securityRealm.getConfigurations().get(0);
    assertEquals("ldap.acme.com", configuration.getServer());
    assertEquals("SECRET", configuration.getManagerPassword());
    assertEquals("manager", configuration.getManagerDN());
    assertEquals("(&(objectCategory=User)(sAMAccountName={0}))", configuration.getUserSearch());
    assertEquals("(&(cn={0})(objectclass=group))", configuration.getGroupSearchFilter());
    final FromGroupSearchLDAPGroupMembershipStrategy strategy = ((FromGroupSearchLDAPGroupMembershipStrategy) configuration.getGroupMembershipStrategy());
    assertEquals("(&(objectClass=group)(|(cn=GROUP_1)(cn=GROUP_2)))", strategy.getFilter());
}
Also used : Jenkins(jenkins.model.Jenkins) LDAPSecurityRealm(hudson.security.LDAPSecurityRealm) FromGroupSearchLDAPGroupMembershipStrategy(jenkins.security.plugins.ldap.FromGroupSearchLDAPGroupMembershipStrategy) IdStrategy(jenkins.model.IdStrategy) LDAPConfiguration(jenkins.security.plugins.ldap.LDAPConfiguration) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 19 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class MailerTest method configure_mailer.

@Test
@ConfiguredWithReadme("mailer/README.md")
public void configure_mailer() {
    final Jenkins jenkins = Jenkins.get();
    final Mailer.DescriptorImpl descriptor = (Mailer.DescriptorImpl) jenkins.getDescriptor(Mailer.class);
    assertEquals("4441", descriptor.getSmtpPort());
    assertEquals("do-not-reply@acme.org", descriptor.getReplyToAddress());
    assertEquals("smtp.acme.org", descriptor.getSmtpHost());
}
Also used : Jenkins(jenkins.model.Jenkins) Mailer(hudson.tasks.Mailer) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 20 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class NodeJSTest method configure_nodejs.

@Test
@ConfiguredWithReadme("nodejs/README.md")
public void configure_nodejs() {
    final NodeJSInstallation.DescriptorImpl descriptor = ExtensionList.lookupSingleton(NodeJSInstallation.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);
    final NodeJSInstallation nodejs = descriptor.getInstallations()[0];
    final InstallSourceProperty installSourceProperty = nodejs.getProperties().get(InstallSourceProperty.class);
    final NodeJSInstaller nodeJSInstaller = installSourceProperty.installers.get(NodeJSInstaller.class);
    assertEquals("12.11.1", nodeJSInstaller.id);
    assertEquals(48, nodeJSInstaller.getNpmPackagesRefreshHours().longValue());
}
Also used : NodeJSInstallation(jenkins.plugins.nodejs.tools.NodeJSInstallation) InstallSourceProperty(hudson.tools.InstallSourceProperty) NodeJSInstaller(jenkins.plugins.nodejs.tools.NodeJSInstaller) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Aggregations

ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)46 Test (org.junit.Test)46 Jenkins (jenkins.model.Jenkins)12 User (hudson.model.User)3 LDAPSecurityRealm (hudson.security.LDAPSecurityRealm)3 SecurityRealm (hudson.security.SecurityRealm)3 InstallSourceProperty (hudson.tools.InstallSourceProperty)3 BasicSSHUserPrivateKey (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey)2 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)2 DockerCloud (com.nirima.jenkins.plugins.docker.DockerCloud)2 DockerTemplate (com.nirima.jenkins.plugins.docker.DockerTemplate)2 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)2 Util.toYamlString (io.jenkins.plugins.casc.misc.Util.toYamlString)2 CNode (io.jenkins.plugins.casc.model.CNode)2 AWSCredentialsImpl (com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl)1 DirectEntryPrivateKeySource (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.DirectEntryPrivateKeySource)1 Credentials (com.cloudbees.plugins.credentials.Credentials)1 SecretBytes (com.cloudbees.plugins.credentials.SecretBytes)1 SystemCredentialsProvider (com.cloudbees.plugins.credentials.SystemCredentialsProvider)1 UsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials)1