-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
1 parent
f71495a
commit 37bd66a
Showing
5 changed files
with
69 additions
and
1 deletion.
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
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,50 @@ | ||
package jenkins.security; | ||
|
||
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; | ||
import hudson.model.UnprotectedRootAction; | ||
import java.io.IOException; | ||
import org.junit.Assert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.TestExtension; | ||
|
||
public class Security2777Test { | ||
public static final String ACTION_URL = "security2777"; | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Test | ||
public void testView() throws IOException { | ||
final JenkinsRule.WebClient wc = j.createWebClient(); | ||
|
||
// no exception on action index page | ||
wc.getPage(wc.getContextPath() + ACTION_URL); | ||
|
||
final FailingHttpStatusCodeException ex2 = Assert.assertThrows("no icon, no response", FailingHttpStatusCodeException.class, () -> wc.getPage(wc.getContextPath() + ACTION_URL + "/fragmentWithoutIcon")); | ||
Assert.assertEquals("it's 404", 404, ex2.getStatusCode()); | ||
|
||
final FailingHttpStatusCodeException ex3 = Assert.assertThrows("icon, still no response", FailingHttpStatusCodeException.class, () -> wc.getPage(wc.getContextPath() + ACTION_URL + "/fragmentWithIcon")); | ||
Assert.assertEquals("it's 404", 404, ex3.getStatusCode()); | ||
} | ||
|
||
@TestExtension | ||
public static class ViewHolder implements UnprotectedRootAction { | ||
|
||
@Override | ||
public String getIconFileName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getUrlName() { | ||
return ACTION_URL; | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
test/src/test/resources/jenkins/security/Security2777Test/ViewHolder/fragmentWithIcon.jelly
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 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout"> | ||
<j:new var="h" className="hudson.Functions" /> | ||
<l:icon src="lol" /> | ||
<h2>Help!</h2> | ||
</j:jelly> |
5 changes: 5 additions & 0 deletions
5
...src/test/resources/jenkins/security/Security2777Test/ViewHolder/fragmentWithoutIcon.jelly
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,5 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
<h2>Help!</h2> | ||
<p>I'm just HTML!</p> | ||
</j:jelly> |
8 changes: 8 additions & 0 deletions
8
test/src/test/resources/jenkins/security/Security2777Test/ViewHolder/index.jelly
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,8 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout"> | ||
<l:layout> | ||
<l:main-panel> | ||
<h1>Hello</h1> | ||
</l:main-panel> | ||
</l:layout> | ||
</j:jelly> |