-
-
Notifications
You must be signed in to change notification settings - Fork 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
84210ba
commit 42e2c74
Showing
2 changed files
with
37 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,34 @@ | ||
package hudson.model; | ||
|
||
import com.gargoylesoftware.htmlunit.FormEncodingType; | ||
import com.gargoylesoftware.htmlunit.HttpMethod; | ||
import com.gargoylesoftware.htmlunit.WebRequest; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.io.IOException; | ||
import java.net.URLEncoder; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
|
||
public class ViewSEC1871Test { | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Test | ||
@Issue("SECURITY-1871") | ||
public void shouldNotAllowInconsistentViewName() throws IOException { | ||
assertNull(j.jenkins.getView("ViewName")); | ||
JenkinsRule.WebClient wc = j.createWebClient(); | ||
WebRequest req = new WebRequest(wc.createCrumbedUrl("createView"), HttpMethod.POST); | ||
req.setEncodingType(FormEncodingType.URL_ENCODED); | ||
req.setRequestBody("name=ViewName&mode=hudson.model.ListView&json=" + URLEncoder.encode("{\"mode\":\"hudson.model.ListView\",\"name\":\"DifferentViewName\"}", "UTF-8")); | ||
wc.getPage(req); | ||
assertNull(j.jenkins.getView("DifferentViewName")); | ||
assertNotNull(j.jenkins.getView("ViewName")); | ||
} | ||
} |