use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class AbstractRepositoryServletProxiedMetadataTestCase method requestMetadataOK.
protected String requestMetadataOK(String path) throws Exception {
// process the response code later, not via an exception.
// HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + path);
WebResponse response = getServletUnitClient().getResponse(request);
assertResponseOK(response);
return response.getContentAsString();
}
use of com.gargoylesoftware.htmlunit.WebRequest in project workflow-job-plugin by jenkinsci.
the class PipelineTriggersJobPropertyTest method triggerPresentDuringStart.
@Issue("JENKINS-42446")
@Test
public void triggerPresentDuringStart() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "triggerPresent");
assertNull(getTriggerFromList(QueryingMockTrigger.class, p.getTriggersJobProperty().getTriggers()));
JenkinsRule.WebClient wc = r.createWebClient();
String newConfig = org.apache.commons.io.IOUtils.toString(PipelineTriggersJobPropertyTest.class.getResourceAsStream("/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobPropertyTest/triggerPresentDuringStart.json"), "UTF-8");
WebRequest request = new WebRequest(new URL(p.getAbsoluteUrl() + "configSubmit"), HttpMethod.POST);
wc.addCrumb(request);
List<NameValuePair> params = new ArrayList<>();
params.addAll(request.getRequestParameters());
params.add(new NameValuePair("json", newConfig));
request.setRequestParameters(params);
wc.getPage(request);
QueryingMockTrigger t = getTriggerFromList(QueryingMockTrigger.class, p.getTriggersJobProperty().getTriggers());
assertNotNull(t);
assertTrue(t.isStarted);
assertTrue(t.foundSelf);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project javaee7-samples by javaee-samples.
the class MyResourceTest method testPut.
@Test
public void testPut() throws IOException, SAXException {
webClient.setCredentialsProvider(correctCreds);
try {
WebRequest postRequest = new WebRequest(toUrlUnsafe(base + "webresources/myresource"), PUT);
postRequest.setRequestBody("name=myname");
webClient.getPage(postRequest);
} catch (FailingHttpStatusCodeException e) {
assertEquals(403, e.getStatusCode());
return;
}
// All methods are excluded except for GET
fail("PUT is not authorized and can still be called");
}
use of com.gargoylesoftware.htmlunit.WebRequest in project javaee7-samples by javaee-samples.
the class SecureServletTest method tearDown.
@After
public void tearDown() throws IOException {
// Remove Bouncy Castle as provider
TextPage pageb = webClient.getPage(new WebRequest(new URL(base + "BouncyServlet"), HttpMethod.DELETE));
log.log(INFO, "Bouncy Castle provider removed: {0}", pageb.getContent());
webClient.getCookieManager().clearCookies();
// Internally throws:
//
// TransportContext.java:313|Fatal (INTERNAL_ERROR): closing inbound before receiving peer's close_notify (
// "throwable" : {
// javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
// at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:133)
// at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
// at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
// at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
// at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
// at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
// at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
// at org.apache.http.impl.BHttpConnectionBase.close(BHttpConnectionBase.java:325)
// at org.apache.http.impl.conn.LoggingManagedHttpClientConnection.close(LoggingManagedHttpClientConnection.java:81)
// at org.apache.http.impl.conn.CPoolEntry.closeConnection(CPoolEntry.java:70)
// at org.apache.http.impl.conn.CPoolEntry.close(CPoolEntry.java:96)
// at org.apache.http.pool.AbstractConnPool.shutdown(AbstractConnPool.java:148)
// at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.shutdown(PoolingHttpClientConnectionManager.java:411)
// at com.gargoylesoftware.htmlunit.HttpWebConnection.close(HttpWebConnection.java:1011)
//
// Visible when -Dssl.debug is used
//
// Should be fixed in JDK11.03, but isn't?
// See https://stackoverflow.com/questions/52016415/jdk-11-ssl-error-on-valid-certificate-working-in-previous-versions
webClient.close();
System.out.println("\n*********** TEST END ***************************\n");
}
use of com.gargoylesoftware.htmlunit.WebRequest in project javaee7-samples by javaee-samples.
the class SecureServletTest method testPutMethod.
@Test
public void testPutMethod() throws Exception {
webClient.setCredentialsProvider(correctCreds);
WebRequest request = new WebRequest(new URL(base + "SecureServlet"), PUT);
System.out.println("\n\n**** After request");
try {
TextPage p = webClient.getPage(request);
System.out.println(p.getContent());
} catch (FailingHttpStatusCodeException e) {
assertNotNull(e);
assertEquals(403, e.getStatusCode());
return;
}
fail("PUT method could be called even with deny-unocvered-http-methods");
}
Aggregations