Skip to content

Commit

Permalink
Merge pull request #77 from schottsfired/jcasc
Browse files Browse the repository at this point in the history
Add JCasC Test
  • Loading branch information
escoem authored Jun 25, 2020
2 parents 2273229 + d7da918 commit 2ae45df
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 31 deletions.
62 changes: 31 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
~ THE SOFTWARE.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.37</version>
<version>4.2</version>
<relativePath />
</parent>

Expand All @@ -39,6 +39,12 @@

<name>CloudBees AWS Credentials Plugin</name>
<url>https://wiki.jenkins.io/display/JENKINS/CloudBees+AWS+Credentials+Plugin</url>
<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
Expand All @@ -47,46 +53,29 @@
<tag>${scmTag}</tag>
</scm>

<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>

<properties>
<revision>1.29</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.73.3</jenkins.version>
<jenkins.version>2.164.3</jenkins.version>
<java.level>8</java.level>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.16</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.164.x</artifactId>
<version>10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- plugin dependencies -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>2.1.18</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -96,12 +85,11 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials-binding</artifactId>
<version>1.16</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
<version>2.8.11.3</version>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
Expand All @@ -112,17 +100,19 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>variant</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.53</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>io.jenkins</groupId>
<artifactId>configuration-as-code</artifactId>
<scope>test</scope>
</dependency>
<!-- jenkins dependencies -->
<!-- test dependencies -->
Expand All @@ -131,6 +121,17 @@
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.jenkins.configuration-as-code</groupId>
<artifactId>test-harness</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand All @@ -146,5 +147,4 @@
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.cloudbees.jenkins.plugins.awscredentials;

import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
import hudson.security.ACL;
import io.jenkins.plugins.casc.misc.RoundTripAbstractTest;
import org.jvnet.hudson.test.RestartableJenkinsRule;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class ConfigurationAsCodeTest extends RoundTripAbstractTest {

@Override
protected void assertConfiguredAsExpected(RestartableJenkinsRule restartableJenkinsRule, String s) {
AWSCredentialsImpl credentials = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(AWSCredentialsImpl.class,
r.j.jenkins, ACL.SYSTEM, (DomainRequirement) null),
CredentialsMatchers.withId("aws-credentials-casc"));
assertNotNull(credentials);
assertEquals(credentials.getAccessKey(), "foo");
assertEquals(credentials.getDescription(), "foo-description");
assertEquals(credentials.getIamMfaSerialNumber(), "arn:aws:iam::123456789012:mfa/user");
assertEquals(credentials.getIamRoleArn(), "arn:aws:iam::123456789012:role/MyIAMRoleName");
assertEquals(credentials.getId(), "aws-credentials-casc");
assertEquals(credentials.getScope(), CredentialsScope.GLOBAL);
assertEquals(credentials.getSecretKey().getPlainText(), "bar");
}

@Override
protected String stringInLogExpected() {
return "AWSCredentialsImpl";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
credentials:
system:
domainCredentials:
- credentials:
- aws:
accessKey: "foo"
description: "foo-description"
iamMfaSerialNumber: "arn:aws:iam::123456789012:mfa/user"
iamRoleArn: "arn:aws:iam::123456789012:role/MyIAMRoleName"
id: "aws-credentials-casc"
scope: GLOBAL
secretKey: "bar"

0 comments on commit 2ae45df

Please sign in to comment.