com.gargoylesoftware.htmlunit.html.HtmlForm Java Examples
The following examples show how to use
com.gargoylesoftware.htmlunit.html.HtmlForm.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeFlowTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testAccessAndRefreshTokenInjectionWithoutIndexHtmlWithQuery() throws Exception { try (final WebClient webClient = createWebClient()) { HtmlPage page = webClient.getPage("http://localhost:8081/web-app/refresh-query?a=aValue"); assertEquals("/web-app/refresh-query?a=aValue", getStateCookieSavedPath(webClient, null)); assertEquals("Log in to quarkus", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertEquals("RT injected:aValue", page.getBody().asText()); webClient.getCookieManager().clearCookies(); } }
Example #2
Source File: Window.java From htmlunit with Apache License 2.0 | 6 votes |
private boolean matches(final Object object) { if (object instanceof HtmlEmbed || object instanceof HtmlForm || object instanceof HtmlImage || object instanceof HtmlObject) { return true; } return includeFormFields_ && (object instanceof HtmlAnchor || object instanceof HtmlButton || object instanceof HtmlInput || object instanceof HtmlMap || object instanceof HtmlSelect || object instanceof HtmlTextArea); }
Example #3
Source File: IntegrationTest.java From zulip-plugin with MIT License | 6 votes |
@Test public void testGlobalConfig() throws Exception { HtmlPage p = j.createWebClient().goTo("configure"); HtmlForm f = p.getFormByName("config"); f.getInputByName("url").setValueAttribute("ZulipUrl"); f.getInputByName("email").setValueAttribute("[email protected]"); f.getInputByName("apiKey").setValueAttribute("secret"); f.getInputByName("stream").setValueAttribute("defaultStream"); f.getInputByName("topic").setValueAttribute("defaultTopic"); f.getInputByName("smartNotify").setChecked(true); f.getInputByName("jenkinsUrl").setValueAttribute("JenkinsUrl"); j.submit(f); verifyGlobalConfig(); // Do a round-trip to verify settings load & save correctly p = j.createWebClient().goTo("configure"); f = p.getFormByName("config"); j.submit(f); verifyGlobalConfig(); }
Example #4
Source File: CsrfIT.java From ozark with Apache License 2.0 | 6 votes |
/** * Retrieves a form, removes CSRF hidden field and attempts to submit. Should * result in a 403 error. * * @throws Exception an error occurs or validation fails. */ @Test public void testFormFail() throws Exception { HtmlPage page1 = webClient.getPage(webUrl + "resources/csrf"); HtmlForm form = (HtmlForm) page1.getDocumentElement().getHtmlElementsByTagName("form").get(0); // Remove hidden input field to cause a CSRF validation failure HtmlElement input = form.getHtmlElementsByTagName("input").get(1); form.removeChild(input); // Submit form - should fail HtmlSubmitInput button = (HtmlSubmitInput) form.getHtmlElementsByTagName("input").get(0); try { button.click(); fail("CSRF validation should have failed!"); } catch (FailingHttpStatusCodeException e) { // falls through } }
Example #5
Source File: CodeFlowTest.java From quarkus-quickstarts with Apache License 2.0 | 6 votes |
@Test public void testLogInDefaultTenant() throws IOException { try (final WebClient webClient = createWebClient()) { HtmlPage page = webClient.getPage("http://localhost:8081/default"); assertEquals("Log in to quarkus", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertTrue(page.asText().contains("tenant")); } }
Example #6
Source File: Document.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Returns the value of the {@code forms} property. * @return the value of the {@code forms} property */ @JsxGetter({CHROME, IE}) public Object getForms() { return new HTMLCollection(getDomNodeOrDie(), false) { @Override protected boolean isMatching(final DomNode node) { return node instanceof HtmlForm && node.getPrefix() == null; } @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { if (getBrowserVersion().hasFeature(JS_DOCUMENT_FORMS_FUNCTION_SUPPORTED)) { return super.call(cx, scope, thisObj, args); } throw Context.reportRuntimeError("TypeError: document.forms is not a function"); } }; }
Example #7
Source File: HTTPTestUtils.java From cxf-fediz with Apache License 2.0 | 6 votes |
public static String loginWithCookieManager(String url, String user, String password, String idpPort, String formName, CookieManager cookieManager) throws IOException { final WebClient webClient = new WebClient(); webClient.setCookieManager(cookieManager); webClient.getOptions().setUseInsecureSSL(true); webClient.getCredentialsProvider().setCredentials( new AuthScope("localhost", Integer.parseInt(idpPort)), new UsernamePasswordCredentials(user, password)); webClient.getOptions().setJavaScriptEnabled(false); final HtmlPage idpPage = webClient.getPage(url); webClient.getOptions().setJavaScriptEnabled(true); Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText()); final HtmlForm form = idpPage.getFormByName(formName); final HtmlSubmitInput button = form.getInputByName("_eventId_submit"); final HtmlPage rpPage = button.click(); Assert.assertTrue("WS Federation Systests Examples".equals(rpPage.getTitleText()) || "WS Federation Systests Spring Examples".equals(rpPage.getTitleText())); webClient.close(); return rpPage.getBody().getTextContent(); }
Example #8
Source File: HTMLDocument.java From htmlunit with Apache License 2.0 | 6 votes |
private static List<DomNode> getItComputeElements(final HtmlPage page, final String name, final boolean forIDAndOrName, final boolean alsoFrames) { final List<DomElement> elements; if (forIDAndOrName) { elements = page.getElementsByIdAndOrName(name); } else { elements = page.getElementsByName(name); } final List<DomNode> matchingElements = new ArrayList<>(); for (final DomElement elt : elements) { if (elt instanceof HtmlForm || elt instanceof HtmlImage || elt instanceof HtmlApplet || (alsoFrames && elt instanceof BaseFrameElement)) { matchingElements.add(elt); } } return matchingElements; }
Example #9
Source File: HTMLElement.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Sets the DOM node that corresponds to this JavaScript object. * @param domNode the DOM node */ @Override public void setDomNode(final DomNode domNode) { super.setDomNode(domNode); final String name = domNode.getLocalName(); if ("wbr".equalsIgnoreCase(name) || "basefont".equalsIgnoreCase(name) || "keygen".equalsIgnoreCase(name) || "track".equalsIgnoreCase(name)) { endTagForbidden_ = true; } if ("input".equalsIgnoreCase(name) || "button".equalsIgnoreCase(name) || "textarea".equalsIgnoreCase(name) || "select".equalsIgnoreCase(name)) { final HtmlForm form = ((HtmlElement) domNode).getEnclosingForm(); if (form != null) { setParentScope(getScriptableFor(form)); } } }
Example #10
Source File: AbstractOIDCTest.java From cxf-fediz with Apache License 2.0 | 6 votes |
private static <P extends Page> P login(final UriBuilder uriBuilder, final WebClient webClient) throws IOException { final HtmlPage idpPage = webClient.getPage( uriBuilder.queryParam("login_hint", "blabla@" + HOME_REALM).build().toURL()); assertEquals("IDP SignIn Response Form", idpPage.getTitleText()); webClient.getCredentialsProvider().clear(); // Test the SAML Version here String wresult = null; for (DomElement result : idpPage.getElementsByTagName("input")) { if ("wresult".equals(result.getAttributeNS(null, "name"))) { wresult = result.getAttributeNS(null, "value"); assertTrue(wresult.contains("urn:oasis:names:tc:SAML:2.0:cm:bearer")); break; } } assertNotNull(wresult); final HtmlForm form = idpPage.getFormByName("signinresponseform"); final HtmlSubmitInput button = form.getInputByName("_eventId_submit"); return button.click(); }
Example #11
Source File: Document.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
/** * Returns the value of the {@code forms} property. * @return the value of the {@code forms} property */ @JsxGetter({CHROME, IE}) public Object getForms() { return new HTMLCollection(getDomNodeOrDie(), false) { @Override protected boolean isMatching(final DomNode node) { return node instanceof HtmlForm && node.getPrefix() == null; } @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { if (getBrowserVersion().hasFeature(JS_DOCUMENT_FORMS_FUNCTION_SUPPORTED)) { return super.call(cx, scope, thisObj, args); } throw Context.reportRuntimeError("TypeError: document.forms is not a function"); } }; }
Example #12
Source File: FormAuthServletTest.java From tomee with Apache License 2.0 | 6 votes |
@Test public void authenticate() throws Exception { final WebClient webClient = new WebClient(); final HtmlPage page = webClient.getPage(getAppUrl() + "/form"); assertEquals(200, page.getWebResponse().getStatusCode()); final HtmlForm login = page.getFormByName("login"); login.getInputByName("j_username").setValueAttribute("tomcat"); login.getInputByName("j_password").setValueAttribute("tomcat"); final Page result = login.getInputByName("submit").click(); assertEquals(200, result.getWebResponse().getStatusCode()); assertEquals("ok!", result.getWebResponse().getContentAsString()); assertEquals("ok!", webClient.getPage(getAppUrl() + "/form").getWebResponse().getContentAsString()); }
Example #13
Source File: AbstractOIDCTest.java From cxf-fediz with Apache License 2.0 | 6 votes |
private static HtmlPage registerClient(HtmlPage registerPage, String clientName, String redirectURI, String clientAudience, String logoutURI, boolean confidential) throws IOException { final HtmlForm form = registerPage.getForms().get(0); // Set new client values final HtmlTextInput clientNameInput = form.getInputByName("client_name"); clientNameInput.setValueAttribute(clientName); final HtmlSelect clientTypeSelect = form.getSelectByName("client_type"); clientTypeSelect.setSelectedAttribute(confidential ? "confidential" : "public", true); final HtmlTextInput redirectURIInput = form.getInputByName("client_redirectURI"); redirectURIInput.setValueAttribute(redirectURI); final HtmlTextInput clientAudienceURIInput = form.getInputByName("client_audience"); clientAudienceURIInput.setValueAttribute(clientAudience); final HtmlTextInput clientLogoutURI = form.getInputByName("client_logoutURI"); clientLogoutURI.setValueAttribute(logoutURI); final HtmlButton button = form.getButtonByName("submit_button"); return button.click(); }
Example #14
Source File: CodeFlowTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testAccessAndRefreshTokenInjectionWithoutIndexHtml() throws IOException, InterruptedException { try (final WebClient webClient = createWebClient()) { HtmlPage page = webClient.getPage("http://localhost:8081/web-app/refresh"); assertEquals("/web-app/refresh", getStateCookieSavedPath(webClient, null)); assertEquals("Log in to quarkus", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertEquals("RT injected", page.getBody().asText()); webClient.getCookieManager().clearCookies(); } }
Example #15
Source File: UiIntegrationTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 6 votes |
@Test public void shouldUpdateProperCloudWhenMultiple() throws IOException, SAXException { EC2FleetCloud cloud1 = new EC2FleetCloud(null, null, null, null, null, null, null, null, null, null, false, false, 0, 0, 0, 0, false, false, false, 0, 0, false, 10, false); j.jenkins.clouds.add(cloud1); EC2FleetCloud cloud2 = new EC2FleetCloud(null, null, null, null, null, null, null, null, null, null, false, false, 0, 0, 0, 0, false, false, false, 0, 0, false, 10, false); j.jenkins.clouds.add(cloud2); HtmlPage page = j.createWebClient().goTo("configure"); HtmlForm form = page.getFormByName("config"); ((HtmlTextInput) getElementsByNameWithoutJdk(page, "_.name").get(0)).setText("a"); HtmlFormUtil.submit(form); assertEquals("a", j.jenkins.clouds.get(0).name); assertEquals("FleetCloud", j.jenkins.clouds.get(1).name); }
Example #16
Source File: MockMvcWebClientCreateTaskTests.java From spring4-sandbox with Apache License 2.0 | 6 votes |
@Test public void testCreateTasks() throws Exception { HtmlPage createTaskPage = webClient.getPage("http://localhost:8080/tasks/new"); HtmlForm form = createTaskPage.getHtmlElementById("form"); HtmlTextInput nameInput = createTaskPage.getHtmlElementById("name"); nameInput.setValueAttribute("My first task"); HtmlTextArea descriptionInput = createTaskPage.getHtmlElementById("description"); descriptionInput.setText("Description of my first task"); HtmlButton submit = form.getOneHtmlElementByAttribute("button", "type", "submit"); HtmlPage taskListPage = submit.click(); Assertions.assertThat(taskListPage.getUrl().toString()).endsWith("/tasks"); // String id = taskListPage.getHtmlElementById("todolist").getTextContent(); // assertThat(id).isEqualTo("123"); // String summary = newMessagePage.getHtmlElementById("summary").getTextContent(); // assertThat(summary).isEqualTo("Spring Rocks"); // String text = newMessagePage.getHtmlElementById("text").getTextContent(); // assertThat(text).isEqualTo("In case you didn't know, Spring Rocks!"); }
Example #17
Source File: HTTPTestUtils.java From cxf-fediz with Apache License 2.0 | 6 votes |
public static String login(String url, String user, String password, String idpPort, String formName) throws IOException { final WebClient webClient = new WebClient(); webClient.getOptions().setUseInsecureSSL(true); webClient.getCredentialsProvider().setCredentials( new AuthScope("localhost", Integer.parseInt(idpPort)), new UsernamePasswordCredentials(user, password)); webClient.getOptions().setJavaScriptEnabled(false); final HtmlPage idpPage = webClient.getPage(url); webClient.getOptions().setJavaScriptEnabled(true); Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText()); final HtmlForm form = idpPage.getFormByName(formName); final HtmlSubmitInput button = form.getInputByName("_eventId_submit"); final HtmlPage rpPage = button.click(); Assert.assertTrue("WS Federation Systests Examples".equals(rpPage.getTitleText()) || "WS Federation Systests Spring Examples".equals(rpPage.getTitleText())); webClient.close(); return rpPage.getBody().getTextContent(); }
Example #18
Source File: CodeFlowTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testIdTokenInjection() throws IOException { try (final WebClient webClient = createWebClient()) { HtmlPage page = webClient.getPage("http://localhost:8081/index.html"); assertEquals("/index.html", getStateCookieSavedPath(webClient, null)); assertEquals("Log in to quarkus", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertEquals("Welcome to Test App", page.getTitleText()); page = webClient.getPage("http://localhost:8081/web-app"); assertEquals("alice", page.getBody().asText()); webClient.getCookieManager().clearCookies(); } }
Example #19
Source File: BearerTokenAuthorizationTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testReAuthenticateWhenSwitchingTenants() throws IOException { try (final WebClient webClient = createWebClient()) { // tenant-web-app HtmlPage page = webClient.getPage("http://localhost:8081/tenant/tenant-web-app/api/user"); assertNull(getStateCookieSavedPath(webClient, "tenant-web-app")); assertEquals("Log in to quarkus-webapp", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertEquals("tenant-web-app:alice", page.getBody().asText()); // tenant-web-app2 page = webClient.getPage("http://localhost:8081/tenant/tenant-web-app2/api/user"); assertNull(getStateCookieSavedPath(webClient, "tenant-web-app2")); assertEquals("Log in to quarkus-webapp2", page.getTitleText()); loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertEquals("tenant-web-app2:alice", page.getBody().asText()); webClient.getCookieManager().clearCookies(); } }
Example #20
Source File: BearerTokenAuthorizationTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testResolveTenantIdentifierWebApp2() throws IOException { try (final WebClient webClient = createWebClient()) { HtmlPage page = webClient.getPage("http://localhost:8081/tenant/tenant-web-app2/api/user"); // State cookie is available but there must be no saved path parameter // as the tenant-web-app configuration does not set a redirect-path property assertNull(getStateCookieSavedPath(webClient, "tenant-web-app2")); assertEquals("Log in to quarkus-webapp2", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertEquals("tenant-web-app2:alice", page.getBody().asText()); webClient.getCookieManager().clearCookies(); } }
Example #21
Source File: BearerTokenAuthorizationTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testResolveTenantIdentifierWebApp() throws IOException { try (final WebClient webClient = createWebClient()) { HtmlPage page = webClient.getPage("http://localhost:8081/tenant/tenant-web-app/api/user"); // State cookie is available but there must be no saved path parameter // as the tenant-web-app configuration does not set a redirect-path property assertNull(getStateCookieSavedPath(webClient, "tenant-web-app")); assertEquals("Log in to quarkus-webapp", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); loginForm.getInputByName("username").setValueAttribute("alice"); loginForm.getInputByName("password").setValueAttribute("alice"); page = loginForm.getInputByName("login").click(); assertEquals("tenant-web-app:alice", page.getBody().asText()); webClient.getCookieManager().clearCookies(); } }
Example #22
Source File: CsrfIT.java From ozark with Apache License 2.0 | 6 votes |
/** * Retrieve a form and submit it making sure the CSRF hidden field is present * * @throws Exception an error occurs or validation fails. */ @Test public void testFormOk() throws Exception { HtmlPage page1 = webClient.getPage(webUrl + "resources/csrf"); HtmlForm form = (HtmlForm) page1.getDocumentElement().getHtmlElementsByTagName("form").get(0); // Check hidden input field HtmlElement input = form.getHtmlElementsByTagName("input").get(1); assertTrue(input.getAttribute("type").equals("hidden")); assertTrue(input.getAttribute("name").equals(CSRF_PARAM)); assertTrue(input.hasAttribute("value")); // token // Submit form HtmlSubmitInput button = (HtmlSubmitInput) form.getHtmlElementsByTagName("input").get(0); HtmlPage page2 = button.click(); Iterator<HtmlElement> it = page2.getDocumentElement().getHtmlElementsByTagName("h1").iterator(); assertTrue(it.next().asText().contains("CSRF Protection OK")); }
Example #23
Source File: I18NValidationIT.java From krazo with Apache License 2.0 | 5 votes |
@Test public void testGermanValidationMessage() throws Exception { HtmlPage page1 = webClient.getPage(webUrl + "resources/validation?lang=de"); HtmlForm form1 = page1.getFormByName("form"); form1.getInputByName("name").setValueAttribute("foo"); HtmlPage page2 = form1.getInputByName("button").click(); assertThat(page2.getWebResponse().getContentAsString(), CoreMatchers.containsString("muss zwischen 5 und 10 liegen")); }
Example #24
Source File: CsrfValidateFilterIT.java From krazo with Apache License 2.0 | 5 votes |
@Test public void testPostWithoutCsrfFieldFailsWithStatusCode403() throws Exception { final HtmlPage page1 = webClient.getPage(baseURL + "resources/csrf-methods/exception-post"); final HtmlForm form = (HtmlForm) page1.getElementById("form"); final HtmlSubmitInput button = form.getInputByName("submit"); final Page result = button.click(); assertEquals(403, result.getWebResponse() .getStatusCode()); }
Example #25
Source File: CsrfValidateFilterIT.java From krazo with Apache License 2.0 | 5 votes |
@Test public void testPatchWithCsrfFieldWorksWithStatusCode200() throws Exception { final HtmlPage page1 = webClient.getPage(baseURL + "resources/csrf-methods/ok-patch"); final HtmlForm form = (HtmlForm) page1.getElementById("form"); final HtmlSubmitInput button = form.getInputByName("submit"); final Page result = button.click(); assertEquals(200, result.getWebResponse() .getStatusCode()); }
Example #26
Source File: CsrfValidateFilterIT.java From krazo with Apache License 2.0 | 5 votes |
@Test public void testPutWithoutCsrfFieldFailsWithStatusCode403() throws Exception { final HtmlPage page1 = webClient.getPage(baseURL + "resources/csrf-methods/exception-put"); final HtmlForm form = (HtmlForm) page1.getElementById("form"); final HtmlSubmitInput button = form.getInputByName("submit"); final Page result = button.click(); assertEquals(403, result.getWebResponse() .getStatusCode()); }
Example #27
Source File: IntegrationTest.java From zulip-plugin with MIT License | 5 votes |
@Test public void testFreestyle() throws Exception { // Initialize project with send and notification step FreeStyleProject project = j.createFreeStyleProject(); ZulipSendStep sendStep = new ZulipSendStep(); sendStep.setStream("testStream"); sendStep.setTopic("testTopic"); sendStep.setMessage("testMessage"); project.getBuildersList().add(sendStep); ZulipNotifier notifier = new ZulipNotifier(); notifier.setStream("testStream"); notifier.setTopic("testTopic"); project.getPublishersList().add(notifier); // Do a round-trip to verify project settings load & save correctly JenkinsRule.WebClient webClient = j.createWebClient(); HtmlPage p = webClient.getPage(project, "configure"); HtmlForm f = p.getFormByName("config"); j.submit(f); ZulipSendStep assertStep = project.getBuildersList().get(ZulipSendStep.class); assertEquals("testStream", assertStep.getStream()); assertEquals("testTopic", assertStep.getTopic()); assertEquals("testMessage", assertStep.getMessage()); ZulipNotifier assertNotifier = project.getPublishersList().get(ZulipNotifier.class); assertEquals("testStream", assertNotifier.getStream()); assertEquals("testTopic", assertNotifier.getTopic()); // Perform build and verify it's successful j.buildAndAssertSuccess(project); verifyNotificationsSent(2); }
Example #28
Source File: ConverterPriorityIT.java From krazo with Apache License 2.0 | 5 votes |
@Test public void testCorrectCustomConverterIsUsedForDoubleValue() throws Exception { final HtmlPage page1 = webClient.getPage(baseURL + "resources/converter"); final HtmlForm form = (HtmlForm) page1.getElementById("form"); final HtmlSubmitInput button = form.getInputByName("submit"); final HtmlPage resultPage = button.click(); final double result = Double.parseDouble(resultPage.getElementById("result").getTextContent()); assertEquals(42.0D, result, 0); }
Example #29
Source File: I18NValidationIT.java From krazo with Apache License 2.0 | 5 votes |
@Test public void testFrenchValidationMessage() throws Exception { HtmlPage page1 = webClient.getPage(webUrl + "resources/validation?lang=fr"); HtmlForm form1 = page1.getFormByName("form"); form1.getInputByName("name").setValueAttribute("foo"); HtmlPage page2 = form1.getInputByName("button").click(); assertThat(page2.getWebResponse().getContentAsString(), CoreMatchers.containsString("entre 5 et 10")); }
Example #30
Source File: CsrfValidateFilterIT.java From krazo with Apache License 2.0 | 5 votes |
@Test public void testPatchWithoutCsrfFieldFailsWithStatusCode403() throws Exception { final HtmlPage page1 = webClient.getPage(baseURL + "resources/csrf-methods/exception-patch"); final HtmlForm form = (HtmlForm) page1.getElementById("form"); final HtmlSubmitInput button = form.getInputByName("submit"); final Page result = button.click(); assertEquals(403, result.getWebResponse() .getStatusCode()); }