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