Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from jenkinsci/workflow-compatibility
[JENKINS-28642] Workflow compatibility for embeddable build status
- Loading branch information
Showing
7 changed files
with
97 additions
and
27 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
target | ||
work | ||
.idea/ | ||
*.iml | ||
.eclipse |
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
17 changes: 4 additions & 13 deletions
17
src/main/java/org/jenkinsci/plugins/badge/BadgeAction.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
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
62 changes: 62 additions & 0 deletions
62
src/test/java/org/jenkinsci/plugins/badge/WorkflowBadgeActionTest.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,62 @@ | ||
package org.jenkinsci.plugins.badge; | ||
|
||
|
||
import hudson.security.GlobalMatrixAuthorizationStrategy; | ||
import hudson.security.SecurityRealm; | ||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.recipes.PresetData; | ||
|
||
|
||
/** | ||
* Just the fun bits: check that actions register correctly | ||
*/ | ||
public class WorkflowBadgeActionTest { | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@PresetData(PresetData.DataSet.NO_ANONYMOUS_READACCESS) | ||
@Test | ||
public void authenticatedAccess() throws Exception { | ||
WorkflowJob job = j.getInstance().createProject(WorkflowJob.class, "wf"); | ||
job.setDefinition(new CpsFlowDefinition("println('hello')")); | ||
|
||
JenkinsRule.WebClient wc = j.createWebClient(); | ||
wc.login("alice", "alice"); | ||
|
||
wc.goTo("buildStatus/icon?job=wf", "image/svg+xml"); | ||
job.setQuietPeriod(0); | ||
job.scheduleBuild(); | ||
j.waitUntilNoActivityUpTo(5000); | ||
wc.goTo("buildStatus/icon?job=wf&build=1", "image/svg+xml"); | ||
} | ||
|
||
@Test | ||
public void anonymousViewStatusAccess() throws Exception { | ||
// Allows anonymous access at security realm level | ||
final SecurityRealm realm = j.createDummySecurityRealm(); | ||
j.jenkins.setSecurityRealm(realm); | ||
GlobalMatrixAuthorizationStrategy auth = new GlobalMatrixAuthorizationStrategy(); | ||
auth.add(PublicBadgeAction.VIEW_STATUS, "anonymous"); | ||
j.getInstance().setSecurityRealm(realm); | ||
j.getInstance().setAuthorizationStrategy(auth); | ||
|
||
WorkflowJob job = j.getInstance().createProject(WorkflowJob.class, "wf"); | ||
job.setDefinition(new CpsFlowDefinition("println('hello')")); | ||
JenkinsRule.WebClient wc = j.createWebClient(); | ||
wc.goTo("buildStatus/icon?job=wf&", "image/svg+xml"); | ||
} | ||
|
||
@PresetData(PresetData.DataSet.ANONYMOUS_READONLY) | ||
@Test | ||
public void anonymousRead() throws Exception { | ||
WorkflowJob job = j.getInstance().createProject(WorkflowJob.class, "wf"); | ||
job.setDefinition(new CpsFlowDefinition("println('hello')")); | ||
JenkinsRule.WebClient wc = j.createWebClient(); | ||
wc.goTo("buildStatus/icon?job=wf&", "image/svg+xml"); | ||
} | ||
} |