Search in sources :

Example 26 with ConfiguredWithReadme

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

the class SimpleThemeTest method configure_simple_theme.

@Test
@ConfiguredWithReadme("simple-theme-plugin/README.md")
public void configure_simple_theme() {
    // Already tested within the plugin itself, let's run some basic tests.
    // https://github.com/jenkinsci/simple-theme-plugin/blob/master/src/test/java/org/jenkinsci/plugins/simpletheme/ConfigurationAsCodeTest.java
    SimpleThemeDecorator decorator = ExtensionList.lookupSingleton(SimpleThemeDecorator.class);
    assertNotNull(decorator);
}
Also used : SimpleThemeDecorator(org.codefirst.SimpleThemeDecorator) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 27 with ConfiguredWithReadme

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

the class SonarQubeTest method configure_sonar_globalconfig.

@Test
@ConfiguredWithReadme("sonarqube/README.md")
public void configure_sonar_globalconfig() {
    final SonarGlobalConfiguration configuration = GlobalConfiguration.all().get(SonarGlobalConfiguration.class);
    assertTrue(configuration.isBuildWrapperEnabled());
    final SonarInstallation installation = configuration.getInstallations()[0];
    assertEquals("TEST", installation.getName());
    assertEquals("http://url:9000", installation.getServerUrl());
    assertEquals("token", installation.getCredentialsId());
    assertEquals("mojoVersion", installation.getMojoVersion());
    assertEquals("additionalAnalysisProperties", installation.getAdditionalAnalysisProperties());
    final TriggersConfig triggers = installation.getTriggers();
    assertTrue(triggers.isSkipScmCause());
    assertTrue(triggers.isSkipUpstreamCause());
    assertEquals("envVar", triggers.getEnvVar());
}
Also used : SonarGlobalConfiguration(hudson.plugins.sonar.SonarGlobalConfiguration) SonarInstallation(hudson.plugins.sonar.SonarInstallation) TriggersConfig(hudson.plugins.sonar.model.TriggersConfig) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 28 with ConfiguredWithReadme

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

the class ArtifactoryTest method configure_artifactory.

@Test
@ConfiguredWithReadme(value = "artifactory/README.md")
public void configure_artifactory() {
    final Jenkins jenkins = Jenkins.get();
    final ArtifactoryBuilder.DescriptorImpl descriptor = (ArtifactoryBuilder.DescriptorImpl) jenkins.getDescriptor(ArtifactoryBuilder.class);
    assertTrue(descriptor.getUseCredentialsPlugin());
    final List<JFrogPlatformInstance> jfrogInstances = descriptor.getJfrogInstances();
    assertThat(jfrogInstances, hasSize(1));
    assertThat(jfrogInstances.get(0).getId(), is(equalTo("artifactory")));
    assertThat(jfrogInstances.get(0).getPlatformUrl(), is(equalTo("http://acme.com/artifactory")));
    assertThat(jfrogInstances.get(0).getArtifactoryUrl(), is(equalTo("http://acme.com/artifactory")));
    assertThat(jfrogInstances.get(0).getDistributionUrl(), is(equalTo("http://acme.com/distribution")));
    assertThat(jfrogInstances.get(0).getDeployerCredentialsConfig().getCredentialsId(), is(equalTo("artifactory")));
    assertThat(jfrogInstances.get(0).getResolverCredentialsConfig().getUsername(), is(equalTo("artifactory_user")));
    assertThat(jfrogInstances.get(0).getResolverCredentialsConfig().getPassword().getPlainText(), is(equalTo("password123")));
}
Also used : Jenkins(jenkins.model.Jenkins) ArtifactoryBuilder(org.jfrog.hudson.ArtifactoryBuilder) JFrogPlatformInstance(org.jfrog.hudson.JFrogPlatformInstance) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 29 with ConfiguredWithReadme

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

the class CredentialsReadmeTest method testDomainScopedCredentials.

@Test
@ConfiguredWithReadme("credentials/README.md#0")
@Envs({ @Env(name = "SUDO_PASSWORD", value = "SUDO") })
public void testDomainScopedCredentials() {
    List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, Jenkins.getInstanceOrNull(), null, Collections.emptyList());
    assertThat(creds.size(), is(1));
    StandardUsernamePasswordCredentials cred = creds.get(0);
    assertThat(cred.getId(), is("sudo_password"));
    assertThat(cred.getUsername(), is("root"));
    assertThat(cred.getPassword(), hasPlainText("SUDO"));
}
Also used : StandardUsernamePasswordCredentials(com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials) Test(org.junit.Test) Envs(io.jenkins.plugins.casc.misc.Envs) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 30 with ConfiguredWithReadme

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

the class DockerCloudTest method configure_docker_cloud.

@Test
@ConfiguredWithReadme("docker/README.md")
public void configure_docker_cloud() {
    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/agent");
    checkTemplate(template, "docker-agent", "jenkins", "/home/jenkins/agent", "10", new String[] { "hello:/hello", "world:/world" }, "hello=world\nfoo=bar");
    assertTrue(template.getRetentionStrategy() instanceof DockerOnceRetentionStrategy);
    assertEquals(1, ((DockerOnceRetentionStrategy) template.getRetentionStrategy()).getIdleMinutes());
}
Also used : DockerTemplate(com.nirima.jenkins.plugins.docker.DockerTemplate) DockerCloud(com.nirima.jenkins.plugins.docker.DockerCloud) DockerOnceRetentionStrategy(com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy) 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