Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed May 2, 2019
1 parent d244751 commit 1b57dbd
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.jenkinsci.plugins.matrixauth;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.security.GlobalMatrixAuthorizationStrategy;
import jenkins.model.Jenkins;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

public class Jenkins57313Test {
@Rule
public JenkinsRule j = new JenkinsRule();

@Test
@Issue("JENKINS-57313")
public void testFormValidation() throws Exception {
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
GlobalMatrixAuthorizationStrategy authorizationStrategy = new GlobalMatrixAuthorizationStrategy();
authorizationStrategy.add(Jenkins.ADMINISTER, "anonymous");
j.jenkins.setAuthorizationStrategy(authorizationStrategy);
HtmlPage page = j.createWebClient().goTo(authorizationStrategy.getDescriptor().getDescriptorUrl() + "/checkName?value=[alice]");
Assert.assertEquals(200, page.getWebResponse().getStatusCode());
String responseText = page.getWebResponse().getContentAsString();
Assert.assertTrue(responseText.contains("alice"));
Assert.assertTrue(responseText.contains("person.png"));
}
}

0 comments on commit 1b57dbd

Please sign in to comment.