Skip to content
Permalink
Browse files

[JENKINS-41760] Reproduced bad output in test: blank (but not empty) …

…creds for freestyle; blank or empty for Pipeline.
  • Loading branch information
jglick committed Aug 8, 2017
1 parent b141c6f commit f982299fc51ff205a2d3a4be861b14abd4142edc
@@ -80,6 +80,7 @@
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.*;
import org.junit.ClassRule;
import org.junit.Ignore;

import org.junit.Rule;
import org.junit.Test;
@@ -428,6 +429,21 @@ public void testTrackingOfCredential() {
});
}

@Ignore("TODO")
@Issue("JENKINS-41760")
@Test public void emptyOrBlankCreds() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {withCredentials([]) {echo 'normal output'}}", true));
story.j.assertLogContains("normal output", story.j.buildAndAssertSuccess(p));
CredentialsProvider.lookupStores(story.j.jenkins).iterator().next().addCredentials(Domain.global(), new StringCredentialsImpl(CredentialsScope.GLOBAL, "creds", null, Secret.fromString("")));
p.setDefinition(new CpsFlowDefinition("node {withCredentials([string(variable: 'SECRET', credentialsId: 'creds')]) {echo 'normal output'}}", true));
story.j.assertLogContains("normal output", story.j.buildAndAssertSuccess(p));
}
});
}

private static Set<String> grep(File dir, String text) throws IOException {
Set<String> matches = new TreeSet<String>();
grep(dir, text, "", matches);
@@ -44,9 +44,13 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.jvnet.hudson.test.BuildWatcher;

public class SecretBuildWrapperTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public JenkinsRule r = new JenkinsRule();

@Issue("JENKINS-24805")
@@ -96,4 +100,15 @@
FreeStyleBuild b = r.buildAndAssertSuccess(f);
r.assertLogContains("PASSES", b);
}

@Ignore("TODO")
@Issue("JENKINS-41760")
@Test public void emptySecret() throws Exception {
CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), new StringCredentialsImpl(CredentialsScope.GLOBAL, "creds", null, Secret.fromString("")));
FreeStyleProject p = r.createFreeStyleProject();
p.getBuildWrappersList().add(new SecretBuildWrapper(Collections.singletonList(new StringBinding("SECRET", "creds"))));
p.getBuildersList().add(Functions.isWindows() ? new BatchFile("echo PASSES") : new Shell("echo PASSES"));
r.assertLogContains("PASSES", r.buildAndAssertSuccess(p));
}

}

0 comments on commit f982299

Please sign in to comment.
You can’t perform that action at this time.