-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
204 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @jenkinsci/reverse-proxy-auth-plugin-developers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: maven | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
ignore: | ||
- dependency-name: "org.jenkins-ci.main:jenkins-core" | ||
open-pull-requests-limit: 10 | ||
target-branch: master | ||
reviewers: | ||
- rda1ton | ||
- sboardwell | ||
labels: | ||
- skip-changelog | ||
- package-ecosystem: "maven" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
ignore: | ||
- dependency-name: "org.jenkins-ci.main:jenkins-core" | ||
open-pull-requests-limit: 10 | ||
reviewers: | ||
- rda1ton | ||
- sboardwell | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc | ||
--- | ||
_extends: .github | ||
tag-template: reverse-proxy-auth-plugin-$NEXT_PATCH_VERSION | ||
name-template: $NEXT_PATCH_VERSION | ||
version-template: $MAJOR.$MINOR.$PATCH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Automates creation of Release Drafts using Release Drafter | ||
# More Info: https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc | ||
--- | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
update_release_draft: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Drafts your next Release notes as Pull Requests are merged into "master" | ||
- uses: release-drafter/release-drafter@v6 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
target | ||
|
||
# mvn hpi:run | ||
work | ||
|
||
# IntelliJ IDEA project files | ||
*.iml | ||
*.iws | ||
*.ipr | ||
target | ||
work | ||
/.idea | ||
/.classpath | ||
/.project | ||
/.settings | ||
.vscode | ||
.idea | ||
|
||
# Eclipse project files | ||
.settings | ||
.classpath | ||
.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
// Build the plugin using https://github.com/jenkins-infra/pipeline-library | ||
buildPlugin(jdkVersions: [11,17]) | ||
buildPlugin(configurations: [ | ||
[platform: 'linux', jdk: 21], | ||
[platform: 'windows', jdk: 17], | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/test/java/org/jenkinsci/plugins/reverse_proxy_auth/docker/PlanetExpressTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package org.jenkinsci.plugins.reverse_proxy_auth.docker; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.StringContains.containsString; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assume.assumeFalse; | ||
import static org.junit.Assume.assumeTrue; | ||
|
||
import hudson.Functions; | ||
import hudson.tasks.MailAddressResolver; | ||
import hudson.util.Secret; | ||
import org.acegisecurity.userdetails.ldap.LdapUserDetails; | ||
import org.jenkinsci.plugins.reverse_proxy_auth.ReverseProxySecurityRealm; | ||
import org.junit.BeforeClass; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.RealJenkinsRule; | ||
import org.testcontainers.DockerClientFactory; | ||
import org.testcontainers.containers.GenericContainer; | ||
|
||
/** | ||
* Tests the plugin when logging in to rroemhild/test-openldap | ||
*/ | ||
public class PlanetExpressTest { | ||
|
||
static final String TEST_IMAGE = | ||
"rroemhild/test-openldap@sha256:b4e433bbcba1f17899d6bcb0a8e854bbe52c754faa4e785d0c27a2b55eb12cd8"; | ||
static final String DN = "dc=planetexpress,dc=com"; | ||
static final String MANAGER_DN = "cn=admin,dc=planetexpress,dc=com"; | ||
static final String MANAGER_SECRET = "GoodNewsEveryone"; | ||
|
||
@BeforeClass | ||
public static void requiresDocker() { | ||
assumeTrue(DockerClientFactory.instance().isDockerAvailable()); | ||
} | ||
|
||
@BeforeClass | ||
public static void linuxOnly() { | ||
assumeFalse( | ||
"Windows CI builders now have Docker installed…but it does not support Linux images", | ||
Functions.isWindows() && System.getenv("JENKINS_URL") != null); | ||
} | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Rule | ||
public GenericContainer container = new GenericContainer(TEST_IMAGE).withExposedPorts(389); | ||
|
||
@Rule | ||
public RealJenkinsRule rr = new RealJenkinsRule(); | ||
|
||
@Test | ||
public void login() throws Throwable { | ||
String server = container.getHost() + ":" + container.getFirstMappedPort(); | ||
rr.then(new Login(server)); | ||
} | ||
|
||
private static class Login implements RealJenkinsRule.Step { | ||
private final String server; | ||
|
||
Login(String server) { | ||
this.server = server; | ||
} | ||
|
||
@Override | ||
public void run(JenkinsRule j) throws Throwable { | ||
ReverseProxySecurityRealm realm = new ReverseProxySecurityRealm( | ||
"X-Forwarded-User", // forwardedUser | ||
"X-Forwarded-Email", // forwardedEmail | ||
"X-Forwarded-DisplayName", // forwardedDisplayName | ||
"X-Forwarded-Groups", // headerGroups | ||
"|", // headerGroupsDelimiter | ||
"", // customLogInUrl | ||
"", // customLogOutUrl | ||
server, // server | ||
DN, // rootDN | ||
false, // inhibitInferRootDN | ||
"", // userSearchBase | ||
"", // userSearch | ||
"", // groupSearchBase | ||
"", // groupSearchFilter | ||
"", // groupMembershipFilter | ||
"", // groupNameAttribute | ||
MANAGER_DN, // managerDN | ||
Secret.fromString(MANAGER_SECRET), // managerPassword | ||
15, // updateInterval | ||
false, // disableLdapEmailResolver | ||
"cn", // displayNameLdapAttribute | ||
"mail" // emailAddressLdapAttribute | ||
); | ||
j.jenkins.setSecurityRealm(realm); | ||
j.configRoundtrip(); | ||
try (JenkinsRule.WebClient wc = j.createWebClient()) { | ||
wc.addRequestHeader(realm.getForwardedUser(), "fry"); | ||
String content = wc.login("fry", "fry").goTo("whoAmI").getBody().getTextContent(); | ||
assertThat(content, containsString("Philip J. Fry")); | ||
} | ||
|
||
LdapUserDetails zoidberg = | ||
(LdapUserDetails) j.jenkins.getSecurityRealm().loadUserByUsername("zoidberg"); | ||
assertEquals("cn=John A. Zoidberg,ou=people,dc=planetexpress,dc=com", zoidberg.getDn()); | ||
|
||
String leelaEmail = MailAddressResolver.resolve(j.jenkins.getUser("leela")); | ||
assertEquals("[email protected]", leelaEmail); | ||
} | ||
} | ||
} |