Skip to content

Commit

Permalink
Merge pull request #1 from rsandell/basil-refresh
Browse files Browse the repository at this point in the history
Different secret source for jcasc test
  • Loading branch information
basil authored Aug 22, 2023
2 parents 6e3d022 + a3d6303 commit 36c4c9c
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package hudson.plugins.active_directory;

import hudson.Extension;
import io.jenkins.plugins.casc.SecretSource;
import io.jenkins.plugins.casc.misc.RoundTripAbstractTest;
import jenkins.model.Jenkins;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.jvnet.hudson.test.RestartableJenkinsRule;

import java.io.IOException;
import java.util.Optional;

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

@Ignore("setting environment variables is not supported in Java 17")
public class ActiveDirectoryJCasCCompatibilityTest extends RoundTripAbstractTest {

@Rule
public EnvironmentVariables env = new EnvironmentVariables()
.set("BIND_PASSWORD_1", "PASSW1")
.set("BIND_PASSWORD_2", "PASSW2");

@Override
protected void assertConfiguredAsExpected(RestartableJenkinsRule restartableJenkinsRule, String s) {
final Jenkins jenkins = Jenkins.getInstance();
Expand Down Expand Up @@ -66,4 +62,19 @@ protected void assertConfiguredAsExpected(RestartableJenkinsRule restartableJenk
protected String stringInLogExpected() {
return "Setting class hudson.plugins.active_directory.ActiveDirectorySecurityRealm.groupLookupStrategy = RECURSIVE";
}

@Extension
public static class TheSource extends SecretSource {
@Override
public Optional<String> reveal(String secret) throws IOException {
switch (secret) {
case "BIND_PASSWORD_1":
return Optional.of("PASSW1");
case "BIND_PASSWORD_2" :
return Optional.of("PASSW2");
default:
return Optional.empty();
}
}
}
}

0 comments on commit 36c4c9c

Please sign in to comment.