use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestBeans method testDeveloperMistypesBeanNameVsFormNames.
/*
* Have the controller method be postUser(UserDbo user, String password) BUT then in the html have
* entity.name, entity.age, entity.password INSTEAD of user.name, etc. such that there
* is a mismatch and verify there is a clean error for that
*
* GET /adduser HTTP/1.1
* Host: localhost:59786
* User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0
* Accept: text/html,application/xhtml+xml,application/xml;q=0.9,XX/XX;q=0.8
* Accept-Language: en-US,en;q=0.5
* Accept-Encoding: gzip, deflate
* Referer: http://localhost:59786/adduser
* Cookie: webSession=1-gzvc03bKRP2YYvWySwgENREwFSg=:__ST=3a2fda5dad7547d3b15b1f61bd3d12f5; webFlash=1:_message=Invalid+values+below&user.address.zipCode=Text+instead+of+number&__secureToken=3a2fda5dad7547d3b15b1f61bd3d12f5&user.firstName=Dean+Hiller; webErrors=1:user.address.zipCode=Could+not+convert+value
* Connection: keep-alive
*/
@Test
public void testDeveloperMistypesBeanNameVsFormNames() {
HttpFullRequest req = Requests.createPostRequest("/postuser", "entity.firstName", "D&D", "entity.lastName", "Hiller", "entity.fullName", "Dean Hiller", "password", "hi");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestHttps method simulateLogin.
private Header simulateLogin() {
HttpFullRequest req1 = Requests.createRequest(KnownHttpMethod.POST, "/postLogin");
XFuture<HttpFullResponse> respFuture = https11Socket.send(req1);
ResponseWrapper response1 = ResponseExtract.waitResponseAndWrap(respFuture);
Header header = response1.getResponse().getHeaderLookupStruct().getHeader(KnownHeaderName.SET_COOKIE);
String value = header.getValue();
value = value.replace("; path=/; HttpOnly", "");
Header cookie = new Header(KnownHeaderName.COOKIE, value);
return cookie;
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestFlashAndSelect method testNullWillFlashProperly.
@Test
public void testNullWillFlashProperly() {
HttpFullRequest req1 = Requests.createPostRequest("/user/post", "entity.id", user.getId() + "", // invalid first name
"entity.firstName", // invalid first name
"NextName", "entity.email", "dean@zz.com", "entity.lastName", "", "entity.password", "", "entity.levelOfEducation", "");
XFuture<HttpFullResponse> respFuture1 = http11Socket.send(req1);
ResponseWrapper response1 = ResponseExtract.waitResponseAndWrap(respFuture1);
response1.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
String urlPath = "/user/edit/" + user.getId();
Assert.assertEquals("http://myhost.com" + urlPath, response1.getRedirectUrl());
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, urlPath);
Header cookieHeader = response1.createCookieRequestHeader();
req.addHeader(cookieHeader);
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
// assert the nulls came through
response.assertContains("<input type=`text` name=`entity.lastName` value=`` class=`input-xlarge`>".replace('`', '\"'));
response.assertContains("<option value=`` selected=`selected`>Unselected</option>".replace('`', '\"'));
response.assertContains("<option value=`k` >Kindergarten</script>".replace('`', '\"'));
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestFlashAndSelect method testMultiSelect.
@Test
public void testMultiSelect() {
HttpFullRequest req1 = Requests.createPostRequest("/multiselect", "entity.id", user.getId() + "", // invalid first name
"entity.firstName", // invalid first name
"NextName", "entity.email", "dean@zz.com", "entity.lastName", "", "entity.password", "", "entity.levelOfEducation", "", "selectedRoles", "j", "selectedRoles", "d");
XFuture<HttpFullResponse> respFuture1 = http11Socket.send(req1);
ResponseWrapper response1 = ResponseExtract.waitResponseAndWrap(respFuture1);
response1.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
String urlPath = "/multiselect/" + user.getId();
Assert.assertEquals("http://myhost.com" + urlPath, response1.getRedirectUrl());
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, urlPath);
Header cookieHeader = response1.createCookieRequestHeader();
req.addHeader(cookieHeader);
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("<option value=`b` >Badass</script>".replace('`', '\"'));
response.assertContains("<option value=`j` selected=`selected`>Jerk</script>".replace('`', '\"'));
response.assertContains("<option value=`d` selected=`selected`>Delinquint</script>".replace('`', '\"'));
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestSyncHibernate method testDbUseWhileRenderingPage.
/**
* Tests when we load user but not company, user.company.name will blow up since company was not
* loaded in the controller from the database.
*
* (ie. we only let you traverse the loaded graph so that we don't accidentally have 1+N queries running)
*/
@Test
public void testDbUseWhileRenderingPage() {
Integer id = loadDataInDb().getId();
verifyLazyLoad(id);
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/dynamic/" + id);
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
}
Aggregations