Search in sources :

Example 16 with PresetData

use of org.jvnet.hudson.test.recipes.PresetData in project jenkins by jenkinsci.

the class LoginRedirectTest method redirect2.

/*
     * Verifies that HTTP 403 is sent first. This is important for machine agents.
     */
@PresetData(DataSet.NO_ANONYMOUS_READACCESS)
@Test
public void redirect2() throws Exception {
    WebClient wc = j.createWebClient();
    wc.assertFails("", HttpURLConnection.HTTP_FORBIDDEN);
}
Also used : WebClient(org.jvnet.hudson.test.JenkinsRule.WebClient) PresetData(org.jvnet.hudson.test.recipes.PresetData) Test(org.junit.Test)

Example 17 with PresetData

use of org.jvnet.hudson.test.recipes.PresetData in project jenkins by jenkinsci.

the class LoginTest method loginDisabledRememberMe.

/**
 * Test that 'remember me' cookie will not be set if disabled even if requested by user.
 * This models the case when the feature is disabled between another user loading and submitting the login page.
 */
@Test
@PresetData(DataSet.SECURED_ACEGI)
public void loginDisabledRememberMe() throws Exception {
    WebClient wc = j.createWebClient();
    HtmlForm form = prepareLoginFormWithRememberMeChecked(wc);
    j.jenkins.setDisableRememberMe(true);
    HtmlFormUtil.submit(form, null);
    assertNull(getRememberMeCookie(wc));
}
Also used : HtmlForm(com.gargoylesoftware.htmlunit.html.HtmlForm) WebClient(org.jvnet.hudson.test.JenkinsRule.WebClient) Test(org.junit.Test) PresetData(org.jvnet.hudson.test.recipes.PresetData)

Example 18 with PresetData

use of org.jvnet.hudson.test.recipes.PresetData in project implied-labels-plugin by jenkinsci.

the class ConfigTest method notAuthorizedToRead.

@PresetData(DataSet.NO_ANONYMOUS_READACCESS)
@Test
public void notAuthorizedToRead() throws Exception {
    WebClient wc = j.createWebClient();
    try {
        wc.getOptions().setPrintContentOnFailingStatusCode(false);
        wc.goTo("label-implications");
    } catch (FailingHttpStatusCodeException ex) {
        assertThat(ex.getStatusMessage(), equalTo("Forbidden"));
    }
}
Also used : FailingHttpStatusCodeException(com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException) WebClient(org.jvnet.hudson.test.JenkinsRule.WebClient) PresetData(org.jvnet.hudson.test.recipes.PresetData) Test(org.junit.Test)

Aggregations

PresetData (org.jvnet.hudson.test.recipes.PresetData)18 Test (org.junit.Test)17 WebClient (org.jvnet.hudson.test.JenkinsRule.WebClient)10 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)4 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 FailingHttpStatusCodeException (com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException)2 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)2 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)2 HtmlLink (com.gargoylesoftware.htmlunit.html.HtmlLink)2 Future (java.util.concurrent.Future)2 Issue (org.jvnet.hudson.test.Issue)2 Page (com.gargoylesoftware.htmlunit.Page)1 XmlPage (com.gargoylesoftware.htmlunit.xml.XmlPage)1 Launcher (hudson.Launcher)1 Proc (hudson.Proc)1 FreeStyleProject (hudson.model.FreeStyleProject)1 Slave (hudson.model.Slave)1 Channel (hudson.remoting.Channel)1 GlobalMatrixAuthorizationStrategy (hudson.security.GlobalMatrixAuthorizationStrategy)1