use of com.cloudbees.hudson.plugins.folder.Folder in project pipeline-aws-plugin by jenkinsci.
the class WithAWSStepTest method testStepWithAWSIamMFAFolderCredentials.
@Test
public void testStepWithAWSIamMFAFolderCredentials() throws Exception {
String folderCredentialsId = "folders-aws-creds";
// Create a folder with credentials in its store
Folder folder = jenkinsRule.jenkins.createProject(Folder.class, "folder" + jenkinsRule.jenkins.getItems().size());
CredentialsStore folderStore = this.getFolderStore(folder);
AmazonWebServicesCredentials amazonWebServicesCredentials = new AWSCredentialsImpl(CredentialsScope.GLOBAL, folderCredentialsId, "global-aws-access-key-id", "global-aws-secret-access-key", "Aws-Description", "Arn::Something:or:Other", "12345678");
folderStore.addCredentials(Domain.global(), amazonWebServicesCredentials);
SystemCredentialsProvider.getInstance().save();
List<String> credentialIds = new ArrayList<>();
credentialIds.add(folderCredentialsId);
WorkflowJob job = folder.createProject(WorkflowJob.class, "testStepWithAWSIamMFAFolderCredentials");
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " withAWS (credentials: '" + folderCredentialsId + "', iamMfaToken: '1234567') {\n" + " echo 'It works!'\n" + " }\n" + "}\n", true));
WorkflowRun workflowRun = job.scheduleBuild2(0).get();
jenkinsRule.waitForCompletion(workflowRun);
jenkinsRule.assertBuildStatus(Result.FAILURE, workflowRun);
jenkinsRule.assertLogContains("The security token included in the request is invalid.", workflowRun);
jenkinsRule.assertLogContains("Constructing AWS Credentials", workflowRun);
jenkinsRule.assertLogContains("utilizing MFA Token", workflowRun);
}
use of com.cloudbees.hudson.plugins.folder.Folder in project pipeline-aws-plugin by jenkinsci.
the class WithAWSStepTest method testStepWithAWSFolderCredentials.
@Test
public void testStepWithAWSFolderCredentials() throws Exception {
String folderCredentialsId = "folders-aws-creds";
// Create a folder with credentials in its store
Folder folder = jenkinsRule.jenkins.createProject(Folder.class, "folder" + jenkinsRule.jenkins.getItems().size());
CredentialsStore folderStore = this.getFolderStore(folder);
AmazonWebServicesCredentials amazonWebServicesCredentials = new AWSCredentialsImpl(CredentialsScope.GLOBAL, folderCredentialsId, "global-aws-access-key-id", "global-aws-secret-access-key", "Aws-Description", "Arn::Something:or:Other", "12345678");
folderStore.addCredentials(Domain.global(), amazonWebServicesCredentials);
SystemCredentialsProvider.getInstance().save();
List<String> credentialIds = new ArrayList<>();
credentialIds.add(folderCredentialsId);
WorkflowJob job = folder.createProject(WorkflowJob.class, "testStepWithAWSFolderCredentials");
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " withAWS (credentials: '" + folderCredentialsId + "') {\n" + " echo 'It works!'\n" + " }\n" + "}\n", true));
WorkflowRun workflowRun = job.scheduleBuild2(0).get();
jenkinsRule.waitForCompletion(workflowRun);
jenkinsRule.assertBuildStatus(Result.FAILURE, workflowRun);
jenkinsRule.assertLogContains("The security token included in the request is invalid.", workflowRun);
jenkinsRule.assertLogContains("Constructing AWS Credentials", workflowRun);
}
Aggregations