Search in sources :

Example 1 with StringCredentials

use of org.jenkinsci.test.acceptance.plugins.credentials.StringCredentials in project acceptance-test-harness by jenkinsci.

the class CredentialsBindingTest method testTextBinding.

@Test
public void testTextBinding() {
    CredentialsPage mc = new CredentialsPage(jenkins, ManagedCredentials.DEFAULT_DOMAIN);
    mc.open();
    StringCredentials cred = mc.add(StringCredentials.class);
    cred.scope.select("GLOBAL");
    cred.secret.set(SECRET_TEXT);
    mc.create();
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.check("Use secret text(s) or file(s)");
    ManagedCredentialsBinding mcb = new ManagedCredentialsBinding(job);
    SecretStringCredentialsBinding cb = mcb.addCredentialBinding(SecretStringCredentialsBinding.class);
    cb.variable.set("BINDED_SECRET");
    ShellBuildStep shell = job.addBuildStep(ShellBuildStep.class);
    shell.command("if [ \"$BINDED_SECRET\" = \"" + SECRET_TEXT + "\" ] \n then \n echo \"" + SECRET_OUTPUT + "\" \n fi");
    job.save();
    Build b = job.scheduleBuild();
    b.shouldSucceed();
    assertThat(b.getConsole(), containsString(SECRET_OUTPUT));
}
Also used : SecretStringCredentialsBinding(org.jenkinsci.test.acceptance.plugins.credentialsbinding.SecretStringCredentialsBinding) ManagedCredentialsBinding(org.jenkinsci.test.acceptance.plugins.credentialsbinding.ManagedCredentialsBinding) CredentialsPage(org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage) Build(org.jenkinsci.test.acceptance.po.Build) StringCredentials(org.jenkinsci.test.acceptance.plugins.credentials.StringCredentials) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)1 CredentialsPage (org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage)1 StringCredentials (org.jenkinsci.test.acceptance.plugins.credentials.StringCredentials)1 ManagedCredentialsBinding (org.jenkinsci.test.acceptance.plugins.credentialsbinding.ManagedCredentialsBinding)1 SecretStringCredentialsBinding (org.jenkinsci.test.acceptance.plugins.credentialsbinding.SecretStringCredentialsBinding)1 Build (org.jenkinsci.test.acceptance.po.Build)1 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)1 ShellBuildStep (org.jenkinsci.test.acceptance.po.ShellBuildStep)1 Test (org.junit.Test)1