Search in sources :

Example 6 with ConfiguredWithReadme

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

the class DockerWorkflowTest method configure_global_definition.

@Test
@ConfiguredWithReadme("docker-workflow/README.md")
public void configure_global_definition() {
    GlobalConfig config = GlobalConfig.get();
    assertNotNull(config);
    assertEquals("label-casc", config.getDockerLabel());
    assertEquals("my.docker.endpoint", config.getRegistry().getUrl());
    assertEquals("credId", config.getRegistry().getCredentialsId());
}
Also used : GlobalConfig(org.jenkinsci.plugins.docker.workflow.declarative.GlobalConfig) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 7 with ConfiguredWithReadme

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

the class GitHubTest method configure_github.

@Test
@ConfiguredWithReadme("github/README.md")
public void configure_github() {
    final GitHubPluginConfig configuration = GlobalConfiguration.all().get(GitHubPluginConfig.class);
    assertThat(configuration.getConfigs(), hasSize(1));
    GitHubServerConfig config = configuration.getConfigs().get(0);
    assertThat(config.getApiUrl(), is("https://github.domain.local/api/v3"));
    assertThat(config.getCredentialsId(), is("[GitHubEEUser]"));
    assertThat(config.getName(), is("InHouse GitHub EE"));
    assertTrue(config.isManageHooks());
}
Also used : GitHubServerConfig(org.jenkinsci.plugins.github.config.GitHubServerConfig) GitHubPluginConfig(org.jenkinsci.plugins.github.config.GitHubPluginConfig) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 8 with ConfiguredWithReadme

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

the class GithubOAuthTest method testSampleVersionForOAuth.

@Test
@ConfiguredWithReadme("github-oauth/README.md")
public void testSampleVersionForOAuth() {
    SecurityRealm realm = Jenkins.get().getSecurityRealm();
    assertThat(realm, instanceOf(GithubSecurityRealm.class));
    GithubSecurityRealm gsh = (GithubSecurityRealm) realm;
    assertEquals("someId", gsh.getClientID());
    assertEquals("https://api.github.com", gsh.getGithubApiUri());
    assertEquals("https://github.com", gsh.getGithubWebUri());
    assertEquals("j985j8fhfhh377", gsh.getClientSecret().getPlainText());
    assertEquals("read:org,user:email", gsh.getOauthScopes());
}
Also used : GithubSecurityRealm(org.jenkinsci.plugins.GithubSecurityRealm) SecurityRealm(hudson.security.SecurityRealm) GithubSecurityRealm(org.jenkinsci.plugins.GithubSecurityRealm) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 9 with ConfiguredWithReadme

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

the class EC2CloudTest method configure_ec2_cloud.

@Test
@ConfiguredWithReadme("ec2/README.md")
public void configure_ec2_cloud() {
    final AmazonEC2Cloud ec2Cloud = (AmazonEC2Cloud) Jenkins.get().getCloud("ec2-ec2");
    assertNotNull(ec2Cloud);
    assertTrue(ec2Cloud.isUseInstanceProfileForCredentials());
    assertThat(ec2Cloud.getSshKeysCredentialsId(), is("ssh-key-credential-id"));
    final List<SlaveTemplate> templates = ec2Cloud.getTemplates();
    assertThat(templates, hasSize(2));
    SlaveTemplate slaveTemplate = templates.get(0);
    assertThat(slaveTemplate.getDisplayName(), containsString("Auto configured EC2 Agent Small"));
    assertFalse(slaveTemplate.getAssociatePublicIp());
    assertFalse(slaveTemplate.isConnectBySSHProcess());
    assertFalse(slaveTemplate.deleteRootOnTermination);
    assertFalse(slaveTemplate.ebsOptimized);
    assertFalse(slaveTemplate.monitoring);
    assertFalse(slaveTemplate.stopOnTerminate);
    assertFalse(slaveTemplate.useEphemeralDevices);
    assertThat(slaveTemplate.type, is(InstanceType.T2Small));
    assertThat(slaveTemplate.getAmi(), equalTo("ami-0c6bb742864ffa3f3"));
    assertThat(slaveTemplate.getLabelString(), containsString("Small"));
    assertThat(slaveTemplate.getLabelSet(), is(notNullValue()));
    assertThat(slaveTemplate.remoteFS, equalTo("/home/ec2-user"));
    assertThat(slaveTemplate.getRemoteAdmin(), equalTo("ec2-user"));
    assertThat(slaveTemplate.zone, equalTo("us-east-1"));
    assertThat(slaveTemplate.getSecurityGroupString(), equalTo("some-group"));
    // fails here without mode specified
    assertTrue(ec2Cloud.canProvision(new LabelAtom("Small")));
    // Checks that the AMI type is Unix and configured
    AMITypeData amiType = slaveTemplate.getAmiType();
    assertTrue(amiType.isUnix());
    assertTrue(amiType instanceof UnixData);
    UnixData unixData = (UnixData) amiType;
    assertThat(unixData.getRootCommandPrefix(), equalTo("sudo"));
    assertThat(unixData.getSlaveCommandPrefix(), equalTo("sudo -u jenkins"));
    assertThat(unixData.getSshPort(), equalTo("61120"));
    slaveTemplate = templates.get(1);
    assertThat(slaveTemplate.getDisplayName(), containsString("Auto configured EC2 Agent Large"));
    assertFalse(slaveTemplate.getAssociatePublicIp());
    assertFalse(slaveTemplate.isConnectBySSHProcess());
    assertFalse(slaveTemplate.deleteRootOnTermination);
    assertFalse(slaveTemplate.ebsOptimized);
    assertFalse(slaveTemplate.monitoring);
    assertFalse(slaveTemplate.stopOnTerminate);
    assertFalse(slaveTemplate.useEphemeralDevices);
    assertThat(slaveTemplate.type, is(InstanceType.T2Xlarge));
    assertThat(slaveTemplate.getAmi(), equalTo("ami-0c6bb742864ffa3f3"));
    assertThat(slaveTemplate.getLabelString(), containsString("Large"));
    assertThat(slaveTemplate.getLabelSet(), is(notNullValue()));
    assertThat(slaveTemplate.remoteFS, equalTo("/home/ec2-user"));
    assertThat(slaveTemplate.getRemoteAdmin(), equalTo("ec2-user"));
    assertThat(slaveTemplate.zone, equalTo("us-east-1"));
    assertThat(slaveTemplate.getSecurityGroupString(), equalTo("some-group"));
    // fails here without mode specified
    assertTrue(ec2Cloud.canProvision(new LabelAtom("Large")));
    // Checks that the AMI type is Unix and configured
    amiType = slaveTemplate.getAmiType();
    assertTrue(amiType.isUnix());
    assertTrue(amiType instanceof UnixData);
    unixData = (UnixData) amiType;
    assertThat(unixData.getRootCommandPrefix(), equalTo("sudo"));
    assertThat(unixData.getSlaveCommandPrefix(), equalTo("sudo -u jenkins"));
    assertThat(unixData.getSshPort(), equalTo("61120"));
}
Also used : SlaveTemplate(hudson.plugins.ec2.SlaveTemplate) LabelAtom(hudson.model.labels.LabelAtom) AmazonEC2Cloud(hudson.plugins.ec2.AmazonEC2Cloud) UnixData(hudson.plugins.ec2.UnixData) AMITypeData(hudson.plugins.ec2.AMITypeData) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 10 with ConfiguredWithReadme

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

the class GitLabConfigurationTest method configure_gitlab_api_token.

@Test
@ConfiguredWithReadme("gitlab/README.md")
public void configure_gitlab_api_token() {
    SystemCredentialsProvider systemCreds = SystemCredentialsProvider.getInstance();
    List<DomainCredentials> domainCredentials = systemCreds.getDomainCredentials();
    assertEquals(1, domainCredentials.size());
    final DomainCredentials gitLabCredential = domainCredentials.get(0);
    assertEquals(Domain.global(), gitLabCredential.getDomain());
    assertEquals(1, gitLabCredential.getCredentials().size());
    final GitLabApiToken apiToken = (GitLabApiToken) gitLabCredential.getCredentials().get(0);
    assertEquals("gitlab_token", apiToken.getId());
    assertEquals("qwertyuiopasdfghjklzxcvbnm", apiToken.getApiToken().getPlainText());
    assertEquals("Gitlab Token", apiToken.getDescription());
}
Also used : DomainCredentials(com.cloudbees.plugins.credentials.domains.DomainCredentials) SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) GitLabApiToken(com.dabsquared.gitlabjenkins.connection.GitLabApiToken) 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