adjusted WebWolfMacro

This commit is contained in:
René Zubcevic
2019-12-20 19:21:50 +01:00
committed by Nanne Baars
parent b6aa677594
commit 59076fc9ef
3 changed files with 39 additions and 8 deletions

View File

@ -22,8 +22,19 @@ public abstract class IntegrationTest {
protected static int WG_PORT = 8080;
protected static int WW_PORT = 9090;
private static String WEBGOAT_URL = "http://127.0.0.1:" + WG_PORT + "/WebGoat/";
private static String WEBWOLF_URL = "http://127.0.0.1:" + WW_PORT + "/";
private static String WEBGOAT_HOSTNAME = "127.0.0.1";//"www.webgoat.local";
private static String WEBWOLF_HOSTNAME = "127.0.0.1";//"www.webwolf.local";
/*
* To test docker compose/stack solution:
* add localhost settings in hosts file: 127.0.0.1 www.webgoat.local www.webwolf.local
* Then set the above values to the specified host names and set the port to 80
*/
private static String WEBGOAT_HOSTHEADER = WEBGOAT_HOSTNAME +":"+WG_PORT;
private static String WEBWOLF_HOSTHEADER = WEBWOLF_HOSTNAME +":"+WW_PORT;
private static String WEBGOAT_URL = "http://" + WEBGOAT_HOSTHEADER + "/WebGoat/";
private static String WEBWOLF_URL = "http://" + WEBWOLF_HOSTHEADER + "/";
private static boolean WG_SSL = false;//enable this if you want to run the test on ssl
@Getter
@ -178,6 +189,7 @@ public abstract class IntegrationTest {
.formParams(params)
.post(url)
.then()
.log().all()
.statusCode(200)
.extract().path("lessonCompleted"), CoreMatchers.is(expectedResult));
}
@ -277,6 +289,14 @@ public abstract class IntegrationTest {
result = result.replace("%20", " ");
return result;
}
/**
* In order to facilitate tests with
* @return
*/
public String getWebWolfHostHeader() {
return WEBWOLF_HOSTHEADER;
}
}

View File

@ -46,6 +46,7 @@ public class PasswordResetLessonTest extends IntegrationTest {
.formParams("resetLink", link, "password", "123456")
.post(url("PasswordReset/reset/change-password"))
.then()
.log().all()
.statusCode(200);
}
@ -56,6 +57,7 @@ public class PasswordResetLessonTest extends IntegrationTest {
.cookie("WEBWOLFSESSION", getWebWolfCookie())
.get(webWolfUrl("WebWolf/requests"))
.then()
.log().all()
.extract().response().getBody().asString();
int startIndex = responseBody.lastIndexOf("/PasswordReset/reset/reset-password/");
var link = responseBody.substring(startIndex + "/PasswordReset/reset/reset-password/".length(), responseBody.indexOf(",", startIndex) - 1);
@ -65,7 +67,7 @@ public class PasswordResetLessonTest extends IntegrationTest {
private void clickForgotEmailLink(String user) {
RestAssured.given()
.when()
.header("host", "localhost:9090")
.header("host", getWebWolfHostHeader())
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.formParams("email", user)