params = new HashMap<>();
params.put("attributes", "userId,role");
- checkAssignment(url("IDOR/diff-attributes"), params, true);
+ checkAssignment(webGoatUrlConfig.url("IDOR/diff-attributes"), params, true);
// View profile another way - assignment 4
params.clear();
params.put("url", "WebGoat/IDOR/profile/2342384");
- checkAssignment(url("IDOR/profile/alt-path"), params, true);
+ checkAssignment(webGoatUrlConfig.url("IDOR/profile/alt-path"), params, true);
// assignment 5a
- MatcherAssert.assertThat(
+ MatcherAssert.assertThat(
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("IDOR/profile/2342388"))
+ .get(webGoatUrlConfig.url("IDOR/profile/2342388"))
.then()
.statusCode(200)
.extract()
@@ -85,7 +85,7 @@ public class IDORIntegrationTest extends IntegrationTest {
CoreMatchers.is(true));
// assignment 5b
- MatcherAssert.assertThat(
+ MatcherAssert.assertThat(
RestAssured.given()
.when()
.relaxedHTTPSValidation()
@@ -94,7 +94,7 @@ public class IDORIntegrationTest extends IntegrationTest {
.body(
"{\"role\":\"1\", \"color\":\"red\", \"size\":\"large\", \"name\":\"Buffalo Bill\","
+ " \"userId\":\"2342388\"}")
- .put(url("IDOR/profile/2342388"))
+ .put(webGoatUrlConfig.url("IDOR/profile/2342388"))
.then()
.statusCode(200)
.extract()
diff --git a/src/it/java/org/owasp/webgoat/integration/IntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/IntegrationTest.java
index 4ee2748cb..0258eb1d1 100644
--- a/src/it/java/org/owasp/webgoat/integration/IntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/IntegrationTest.java
@@ -20,66 +20,13 @@ import org.springframework.http.HttpStatus;
public abstract class IntegrationTest {
- private final ServerUrlConfig webGoatUrlConfig = ServerUrlConfig.webGoat();
- @Getter private final ServerUrlConfig webWolfUrlConfig = ServerUrlConfig.webWolf();
+ protected final ServerUrlConfig webGoatUrlConfig = ServerUrlConfig.webGoat();
+ protected final ServerUrlConfig webWolfUrlConfig = ServerUrlConfig.webWolf();
@Getter private String webGoatCookie;
@Getter private String webWolfCookie;
@Getter private final String user = "webgoat";
- protected String url(String url) {
- return webGoatUrlConfig.url(url);
- }
-
- protected class WebWolfUrlBuilder {
-
- private boolean attackMode = false;
- private String path = null;
-
- protected String build() {
- return webWolfUrlConfig.url(path != null ? path : "");
- }
-
- /**
- * In attack mode it means WebGoat calls WebWolf to perform an attack. In this case we need to
- * use port 9090 in a Docker environment.
- */
- protected WebWolfUrlBuilder attackMode() {
- attackMode = true;
- return this;
- }
-
- protected WebWolfUrlBuilder path(String path) {
- this.path = path;
- return this;
- }
-
- protected WebWolfUrlBuilder path(String path, String... uriVariables) {
- this.path = path.formatted(uriVariables);
- return this;
- }
- }
-
- /**
- * Debugging options: install TestContainers Desktop and map port 5005 to the host machine with
- * https://newsletter.testcontainers.com/announcements/set-fixed-ports-to-easily-debug-development-services
- *
- * Start the test and connect a remote debugger in IntelliJ to localhost:5005 and attach it.
- */
- // private static GenericContainer> webGoatContainer =
- // new GenericContainer(new ImageFromDockerfile("webgoat").withFileFromPath("/",
- // Paths.get(".")))
- // .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("webgoat")))
- // .withExposedPorts(8080, 9090, 5005)
- // .withEnv(
- // "_JAVA_OPTIONS",
- // "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005")
- // .waitingFor(Wait.forHealthcheck());
- //
- // static {
- // webGoatContainer.start();
- // }
-
@BeforeEach
public void login() {
login("webgoat");
@@ -92,7 +39,7 @@ public abstract class IntegrationTest {
.relaxedHTTPSValidation()
.formParam("username", user)
.formParam("password", "password")
- .post(url("login"))
+ .post(webGoatUrlConfig.url("login"))
.then()
.log()
.ifValidationFails(LogDetail.ALL) // Log the response details if validation fails
@@ -109,7 +56,7 @@ public abstract class IntegrationTest {
.formParam("password", "password")
.formParam("matchingPassword", "password")
.formParam("agree", "agree")
- .post(url("register.mvc"))
+ .post(webGoatUrlConfig.url("register.mvc"))
.then()
.cookie("JSESSIONID")
.statusCode(302)
@@ -122,7 +69,7 @@ public abstract class IntegrationTest {
.relaxedHTTPSValidation()
.formParam("username", user)
.formParam("password", "password")
- .post(url("login"))
+ .post(webGoatUrlConfig.url("login"))
.then()
.cookie("JSESSIONID")
.statusCode(302)
@@ -136,7 +83,7 @@ public abstract class IntegrationTest {
.relaxedHTTPSValidation()
.formParam("username", user)
.formParam("password", "password")
- .post(new WebWolfUrlBuilder().path("login").build())
+ .post(webWolfUrlConfig.url("login"))
.then()
.statusCode(302)
.cookie("WEBWOLFSESSION")
@@ -146,7 +93,12 @@ public abstract class IntegrationTest {
@AfterEach
public void logout() {
- RestAssured.given().when().relaxedHTTPSValidation().get(url("logout")).then().statusCode(200);
+ RestAssured.given()
+ .when()
+ .relaxedHTTPSValidation()
+ .get(webGoatUrlConfig.url("logout"))
+ .then()
+ .statusCode(200);
}
public void startLesson(String lessonName) {
@@ -158,7 +110,7 @@ public abstract class IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url(lessonName + ".lesson.lesson"))
+ .get(webGoatUrlConfig.url(lessonName + ".lesson.lesson"))
.then()
.statusCode(200);
@@ -167,7 +119,7 @@ public abstract class IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/restartlesson.mvc/%s.lesson".formatted(lessonName)))
+ .get(webGoatUrlConfig.url("service/restartlesson.mvc/%s.lesson".formatted(lessonName)))
.then()
.statusCode(200);
}
@@ -209,7 +161,7 @@ public abstract class IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/lessonoverview.mvc/%s.lesson".formatted(lesson)))
+ .get(webGoatUrlConfig.url("service/lessonoverview.mvc/%s.lesson".formatted(lesson)))
.andReturn();
MatcherAssert.assertThat(
@@ -223,7 +175,7 @@ public abstract class IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/lessonoverview.mvc"))
+ .get(webGoatUrlConfig.url("service/lessonoverview.mvc"))
.andReturn();
MatcherAssert.assertThat(
@@ -269,7 +221,7 @@ public abstract class IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
- .get(new WebWolfUrlBuilder().path("file-server-location").build())
+ .get(webWolfUrlConfig.url("file-server-location"))
.then()
.extract()
.response()
@@ -284,7 +236,7 @@ public abstract class IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("server-directory"))
+ .get(webGoatUrlConfig.url("server-directory"))
.then()
.extract()
.response()
@@ -297,7 +249,7 @@ public abstract class IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
- .delete(new WebWolfUrlBuilder().path("mail").build())
+ .delete(webWolfUrlConfig.url("mail"))
.then()
.statusCode(HttpStatus.ACCEPTED.value());
}
diff --git a/src/it/java/org/owasp/webgoat/integration/JWTLessonIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/JWTLessonIntegrationTest.java
index 162d87dda..e7c9d7bc1 100644
--- a/src/it/java/org/owasp/webgoat/integration/JWTLessonIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/JWTLessonIntegrationTest.java
@@ -90,7 +90,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.formParam("jwt-encode-user", "user")
- .post(url("JWT/decode"))
+ .post(webGoatUrlConfig.url("JWT/decode"))
.then()
.statusCode(200)
.extract()
@@ -105,7 +105,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("JWT/secret/gettoken"))
+ .get(webGoatUrlConfig.url("JWT/secret/gettoken"))
.then()
.extract()
.response()
@@ -119,7 +119,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.formParam("token", generateToken(secret))
- .post(url("JWT/secret"))
+ .post(webGoatUrlConfig.url("JWT/secret"))
.then()
.statusCode(200)
.extract()
@@ -133,7 +133,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("JWT/votings/login?user=Tom"))
+ .get(webGoatUrlConfig.url("JWT/votings/login?user=Tom"))
.then()
.extract()
.cookie("access_token");
@@ -166,7 +166,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.cookie("access_token", replacedToken)
- .post(url("JWT/votings"))
+ .post(webGoatUrlConfig.url("JWT/votings"))
.then()
.statusCode(200)
.extract()
@@ -207,7 +207,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.header("Authorization", "Bearer " + replacedToken)
- .post(url("JWT/refresh/checkout"))
+ .post(webGoatUrlConfig.url("JWT/refresh/checkout"))
.then()
.statusCode(200)
.extract()
@@ -240,7 +240,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .post(url("JWT/kid/delete?token=" + token))
+ .post(webGoatUrlConfig.url("JWT/kid/delete?token=" + token))
.then()
.statusCode(200)
.extract()
@@ -258,7 +258,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
.multiPart("file", "jwks.json", jwks.toJson().getBytes())
- .post(new WebWolfUrlBuilder().path("fileupload").build())
+ .post(webWolfUrlConfig.url("fileupload"))
.then()
.extract()
.response()
@@ -268,8 +268,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
Map header = new HashMap();
header.put(Header.TYPE, Header.JWT_TYPE);
header.put(
- JwsHeader.JWK_SET_URL,
- new WebWolfUrlBuilder().attackMode().path("files/%s/jwks.json", getUser()).build());
+ JwsHeader.JWK_SET_URL, webWolfUrlConfig.url("files/%s/jwks.json".formatted(getUser())));
String token =
Jwts.builder()
@@ -290,7 +289,7 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .post(url("JWT/jku/delete?token=" + token))
+ .post(webGoatUrlConfig.url("JWT/jku/delete?token=" + token))
.then()
.statusCode(200)
.extract()
@@ -303,6 +302,6 @@ public class JWTLessonIntegrationTest extends IntegrationTest {
params.put("question_0_solution", "Solution 1");
params.put("question_1_solution", "Solution 2");
- checkAssignment(url("JWT/quiz"), params, true);
+ checkAssignment(webGoatUrlConfig.url("JWT/quiz"), params, true);
}
}
diff --git a/src/it/java/org/owasp/webgoat/integration/LabelAndHintIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/LabelAndHintIntegrationTest.java
index f4c3b4419..dc39d38c1 100644
--- a/src/it/java/org/owasp/webgoat/integration/LabelAndHintIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/LabelAndHintIntegrationTest.java
@@ -21,14 +21,14 @@ public class LabelAndHintIntegrationTest extends IntegrationTest {
@Test
public void testSingleLabel() {
Assertions.assertTrue(true);
- JsonPath jsonPath =
+ JsonPath jsonPath =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.contentType(ContentType.JSON)
.header("Accept-Language", "en")
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/labels.mvc"))
+ .get(webGoatUrlConfig.url("service/labels.mvc"))
.then()
.statusCode(200)
.extract()
@@ -39,14 +39,14 @@ public class LabelAndHintIntegrationTest extends IntegrationTest {
jsonPath.getString(ESCAPE_JSON_PATH_CHAR + "http-basics.close" + ESCAPE_JSON_PATH_CHAR));
// check if lang parameter overrules Accept-Language parameter
- jsonPath =
+ jsonPath =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.contentType(ContentType.JSON)
.header("Accept-Language", "en")
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/labels.mvc?lang=nl"))
+ .get(webGoatUrlConfig.url("service/labels.mvc?lang=nl"))
.then()
.statusCode(200)
.extract()
@@ -55,14 +55,14 @@ public class LabelAndHintIntegrationTest extends IntegrationTest {
"Gebruikersnaam",
jsonPath.getString(ESCAPE_JSON_PATH_CHAR + "username" + ESCAPE_JSON_PATH_CHAR));
- jsonPath =
+ jsonPath =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.contentType(ContentType.JSON)
.header("Accept-Language", "en")
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/labels.mvc?lang=de"))
+ .get(webGoatUrlConfig.url("service/labels.mvc?lang=de"))
.then()
.statusCode(200)
.extract()
@@ -72,14 +72,14 @@ public class LabelAndHintIntegrationTest extends IntegrationTest {
jsonPath.getString(ESCAPE_JSON_PATH_CHAR + "username" + ESCAPE_JSON_PATH_CHAR));
// check if invalid language returns english
- jsonPath =
+ jsonPath =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.contentType(ContentType.JSON)
.header("Accept-Language", "nl")
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/labels.mvc?lang=xx"))
+ .get(webGoatUrlConfig.url("service/labels.mvc?lang=xx"))
.then()
.statusCode(200)
.extract()
@@ -88,14 +88,14 @@ public class LabelAndHintIntegrationTest extends IntegrationTest {
"Username", jsonPath.getString(ESCAPE_JSON_PATH_CHAR + "username" + ESCAPE_JSON_PATH_CHAR));
// check if invalid language returns english
- jsonPath =
+ jsonPath =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.contentType(ContentType.JSON)
.header("Accept-Language", "xx_YY")
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/labels.mvc"))
+ .get(webGoatUrlConfig.url("service/labels.mvc"))
.then()
.statusCode(200)
.extract()
@@ -200,14 +200,14 @@ public class LabelAndHintIntegrationTest extends IntegrationTest {
}
private JsonPath getLabels(String lang) {
- return RestAssured.given()
+ return RestAssured.given()
.when()
.relaxedHTTPSValidation()
.contentType(ContentType.JSON)
.header("Accept-Language", lang)
.cookie("JSESSIONID", getWebGoatCookie())
// .log().headers()
- .get(url("service/labels.mvc"))
+ .get(webGoatUrlConfig.url("service/labels.mvc"))
.then()
// .log().all()
.statusCode(200)
@@ -216,13 +216,13 @@ public class LabelAndHintIntegrationTest extends IntegrationTest {
}
private List getHints() {
- JsonPath jsonPath =
+ JsonPath jsonPath =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.contentType(ContentType.JSON)
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url("service/hint.mvc"))
+ .get(webGoatUrlConfig.url("service/hint.mvc"))
.then()
// .log().all()
.statusCode(200)
diff --git a/src/it/java/org/owasp/webgoat/integration/PasswordResetLessonIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/PasswordResetLessonIntegrationTest.java
index 61a2805d5..654aa3b4e 100644
--- a/src/it/java/org/owasp/webgoat/integration/PasswordResetLessonIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/PasswordResetLessonIntegrationTest.java
@@ -35,12 +35,12 @@ public class PasswordResetLessonIntegrationTest extends IntegrationTest {
}
public void assignment2() {
- checkAssignment(
- url("PasswordReset/simple-mail/reset"),
+ checkAssignment(
+ webGoatUrlConfig.url("PasswordReset/simple-mail/reset"),
Map.of("emailReset", this.getUser() + "@webgoat.org"),
false);
- checkAssignment(
- url("PasswordReset/simple-mail"),
+ checkAssignment(
+ webGoatUrlConfig.url("PasswordReset/simple-mail"),
Map.of(
"email",
this.getUser() + "@webgoat.org",
@@ -50,19 +50,19 @@ public class PasswordResetLessonIntegrationTest extends IntegrationTest {
}
public void assignment4() {
- checkAssignment(
- url("PasswordReset/questions"),
+ checkAssignment(
+ webGoatUrlConfig.url("PasswordReset/questions"),
Map.of("username", "tom", "securityQuestion", "purple"),
true);
}
public void assignment5() {
- checkAssignment(
- url("PasswordReset/SecurityQuestions"),
+ checkAssignment(
+ webGoatUrlConfig.url("PasswordReset/SecurityQuestions"),
Map.of("question", "What is your favorite animal?"),
false);
- checkAssignment(
- url("PasswordReset/SecurityQuestions"),
+ checkAssignment(
+ webGoatUrlConfig.url("PasswordReset/SecurityQuestions"),
Map.of("question", "What is your favorite color?"),
true);
}
@@ -75,8 +75,8 @@ public class PasswordResetLessonIntegrationTest extends IntegrationTest {
var link = getPasswordResetLinkFromLandingPage();
// WebGoat
changePassword(link);
- checkAssignment(
- url("PasswordReset/reset/login"),
+ checkAssignment(
+ webGoatUrlConfig.url("PasswordReset/reset/login"),
Map.of("email", "tom@webgoat-cloud.org", "password", "123456"),
true);
}
@@ -89,7 +89,7 @@ public class PasswordResetLessonIntegrationTest extends IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
- .get(new WebWolfUrlBuilder().path("mail").build())
+ .get(webWolfUrlConfig.url("mail"))
.then()
.extract()
.response()
@@ -107,12 +107,12 @@ public class PasswordResetLessonIntegrationTest extends IntegrationTest {
}
private void changePassword(String link) {
- RestAssured.given()
+ RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.formParams("resetLink", link, "password", "123456")
- .post(url("PasswordReset/reset/change-password"))
+ .post(webGoatUrlConfig.url("PasswordReset/reset/change-password"))
.then()
.statusCode(200);
}
@@ -123,7 +123,7 @@ public class PasswordResetLessonIntegrationTest extends IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
- .get(new WebWolfUrlBuilder().path("requests").build())
+ .get(webWolfUrlConfig.url("requests"))
.then()
.extract()
.response()
@@ -138,13 +138,13 @@ public class PasswordResetLessonIntegrationTest extends IntegrationTest {
}
private void clickForgotEmailLink(String user) {
- RestAssured.given()
+ RestAssured.given()
.when()
- .header(HttpHeaders.HOST, String.format("%s:%s", "127.0.0.1", getWebWolfUrlConfig().port()))
+ .header(HttpHeaders.HOST, String.format("%s:%s", "127.0.0.1", webWolfUrlConfig.port()))
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.formParams("email", user)
- .post(url("PasswordReset/ForgotPassword/create-password-reset-link"))
+ .post(webGoatUrlConfig.url("PasswordReset/ForgotPassword/create-password-reset-link"))
.then()
.statusCode(200);
}
diff --git a/src/it/java/org/owasp/webgoat/integration/PathTraversalIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/PathTraversalIntegrationTest.java
index f058506ea..0bb959e58 100644
--- a/src/it/java/org/owasp/webgoat/integration/PathTraversalIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/PathTraversalIntegrationTest.java
@@ -52,14 +52,14 @@ class PathTraversalIT extends IntegrationTest {
}
private void assignment1() throws IOException {
- MatcherAssert.assertThat(
+ MatcherAssert.assertThat(
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.multiPart("uploadedFile", "test.jpg", Files.readAllBytes(fileToUpload.toPath()))
.param("fullName", "../John Doe")
- .post(url("PathTraversal/profile-upload"))
+ .post(webGoatUrlConfig.url("PathTraversal/profile-upload"))
.then()
.statusCode(200)
.extract()
@@ -68,14 +68,14 @@ class PathTraversalIT extends IntegrationTest {
}
private void assignment2() throws IOException {
- MatcherAssert.assertThat(
+ MatcherAssert.assertThat(
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.multiPart("uploadedFileFix", "test.jpg", Files.readAllBytes(fileToUpload.toPath()))
.param("fullNameFix", "..././John Doe")
- .post(url("PathTraversal/profile-upload-fix"))
+ .post(webGoatUrlConfig.url("PathTraversal/profile-upload-fix"))
.then()
.statusCode(200)
.extract()
@@ -84,7 +84,7 @@ class PathTraversalIT extends IntegrationTest {
}
private void assignment3() throws IOException {
- MatcherAssert.assertThat(
+ MatcherAssert.assertThat(
RestAssured.given()
.when()
.relaxedHTTPSValidation()
@@ -93,7 +93,7 @@ class PathTraversalIT extends IntegrationTest {
"uploadedFileRemoveUserInput",
"../test.jpg",
Files.readAllBytes(fileToUpload.toPath()))
- .post(url("PathTraversal/profile-upload-remove-user-input"))
+ .post(webGoatUrlConfig.url("PathTraversal/profile-upload-remove-user-input"))
.then()
.statusCode(200)
.extract()
@@ -103,18 +103,18 @@ class PathTraversalIT extends IntegrationTest {
private void assignment4() throws IOException {
var uri = "PathTraversal/random-picture?id=%2E%2E%2F%2E%2E%2Fpath-traversal-secret";
- RestAssured.given()
+ RestAssured.given()
.urlEncodingEnabled(false)
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
- .get(url(uri))
+ .get(webGoatUrlConfig.url(uri))
.then()
.statusCode(200)
.body(CoreMatchers.is("You found it submit the SHA-512 hash of your username as answer"));
- checkAssignment(
- url("PathTraversal/random"),
+ checkAssignment(
+ webGoatUrlConfig.url("PathTraversal/random"),
Map.of("secret", Sha512DigestUtils.shaHex(this.getUser())),
true);
}
@@ -131,13 +131,13 @@ class PathTraversalIT extends IntegrationTest {
zos.putNextEntry(e);
zos.write("test".getBytes(StandardCharsets.UTF_8));
}
- MatcherAssert.assertThat(
+ MatcherAssert.assertThat(
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.multiPart("uploadedFileZipSlip", "upload.zip", Files.readAllBytes(zipFile.toPath()))
- .post(url("PathTraversal/zip-slip"))
+ .post(webGoatUrlConfig.url("PathTraversal/zip-slip"))
.then()
.log()
.all()
diff --git a/src/it/java/org/owasp/webgoat/integration/ProgressRaceConditionIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/ProgressRaceConditionIntegrationTest.java
index 285f08e2d..c779f31f6 100644
--- a/src/it/java/org/owasp/webgoat/integration/ProgressRaceConditionIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/ProgressRaceConditionIntegrationTest.java
@@ -28,12 +28,12 @@ public class ProgressRaceConditionIntegrationTest extends IntegrationTest {
Callable call =
() -> {
// System.out.println("thread "+Thread.currentThread().getName());
- return RestAssured.given()
+ return RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.formParams(Map.of("flag", "test"))
- .post(url("challenge/flag/1"));
+ .post(webGoatUrlConfig.url("challenge/flag/1"));
};
ExecutorService executorService = Executors.newFixedThreadPool(NUMBER_OF_PARALLEL_THREADS);
List extends Callable> flagCalls =
diff --git a/src/it/java/org/owasp/webgoat/integration/SSRFIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/SSRFIntegrationTest.java
index 16efd0cfa..2851a5dfd 100644
--- a/src/it/java/org/owasp/webgoat/integration/SSRFIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/SSRFIntegrationTest.java
@@ -18,11 +18,11 @@ public class SSRFIntegrationTest extends IntegrationTest {
params.clear();
params.put("url", "images/jerry.png");
- checkAssignment(url("SSRF/task1"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SSRF/task1"), params, true);
params.clear();
params.put("url", "http://ifconfig.pro");
- checkAssignment(url("SSRF/task2"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SSRF/task2"), params, true);
checkResults("SSRF");
}
diff --git a/src/it/java/org/owasp/webgoat/integration/SessionManagementIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/SessionManagementIntegrationTest.java
index 0722dedb9..dad80872e 100644
--- a/src/it/java/org/owasp/webgoat/integration/SessionManagementIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/SessionManagementIntegrationTest.java
@@ -18,8 +18,8 @@ class SessionManagementIT extends IntegrationTest {
void hijackSessionTest() {
startLesson("HijackSession");
- checkAssignment(
- url(HIJACK_LOGIN_CONTEXT_PATH),
+ checkAssignment(
+ webGoatUrlConfig.url(HIJACK_LOGIN_CONTEXT_PATH),
Map.of("username", "webgoat", "password", "webgoat"),
false);
}
diff --git a/src/it/java/org/owasp/webgoat/integration/SqlInjectionAdvancedIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/SqlInjectionAdvancedIntegrationTest.java
index 2bfb03406..820a9f6fa 100644
--- a/src/it/java/org/owasp/webgoat/integration/SqlInjectionAdvancedIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/SqlInjectionAdvancedIntegrationTest.java
@@ -20,27 +20,27 @@ public class SqlInjectionAdvancedIntegrationTest extends IntegrationTest {
params.put("password_reg", "password");
params.put("email_reg", "someone@microsoft.com");
params.put("confirm_password", "password");
- checkAssignmentWithPUT(url("SqlInjectionAdvanced/challenge"), params, true);
+ checkAssignmentWithPUT(webGoatUrlConfig.url("SqlInjectionAdvanced/challenge"), params, true);
params.clear();
params.put("username_login", "tom");
params.put("password_login", "thisisasecretfortomonly");
- checkAssignment(url("SqlInjectionAdvanced/challenge_Login"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionAdvanced/challenge_Login"), params, true);
params.clear();
params.put("userid_6a", "'; SELECT * FROM user_system_data;--");
- checkAssignment(url("SqlInjectionAdvanced/attack6a"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionAdvanced/attack6a"), params, true);
params.clear();
params.put(
"userid_6a",
"Smith' union select userid,user_name, user_name,user_name,password,cookie,userid from"
+ " user_system_data --");
- checkAssignment(url("SqlInjectionAdvanced/attack6a"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionAdvanced/attack6a"), params, true);
params.clear();
params.put("userid_6b", "passW0rD");
- checkAssignment(url("SqlInjectionAdvanced/attack6b"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionAdvanced/attack6b"), params, true);
params.clear();
params.put(
@@ -58,7 +58,7 @@ public class SqlInjectionAdvancedIntegrationTest extends IntegrationTest {
params.put(
"question_4_solution",
"Solution 4: The database registers 'Robert' ); DROP TABLE Students;--'.");
- checkAssignment(url("SqlInjectionAdvanced/quiz"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionAdvanced/quiz"), params, true);
checkResults("SqlInjectionAdvanced");
}
diff --git a/src/it/java/org/owasp/webgoat/integration/SqlInjectionLessonIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/SqlInjectionLessonIntegrationTest.java
index 7bea7afa8..b84fddefc 100644
--- a/src/it/java/org/owasp/webgoat/integration/SqlInjectionLessonIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/SqlInjectionLessonIntegrationTest.java
@@ -38,44 +38,44 @@ public class SqlInjectionLessonIntegrationTest extends IntegrationTest {
Map params = new HashMap<>();
params.clear();
params.put("query", sql_2);
- checkAssignment(url("SqlInjection/attack2"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/attack2"), params, true);
params.clear();
params.put("query", sql_3);
- checkAssignment(url("SqlInjection/attack3"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/attack3"), params, true);
params.clear();
params.put("query", sql_4_add);
- checkAssignment(url("SqlInjection/attack4"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/attack4"), params, true);
params.clear();
params.put("query", sql_5);
- checkAssignment(url("SqlInjection/attack5"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/attack5"), params, true);
params.clear();
params.put("operator", sql_9_operator);
params.put("account", sql_9_account);
params.put("injection", sql_9_injection);
- checkAssignment(url("SqlInjection/assignment5a"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/assignment5a"), params, true);
params.clear();
params.put("login_count", sql_10_login_count);
params.put("userid", sql_10_userid);
- checkAssignment(url("SqlInjection/assignment5b"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/assignment5b"), params, true);
params.clear();
params.put("name", sql_11_a);
params.put("auth_tan", sql_11_b);
- checkAssignment(url("SqlInjection/attack8"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/attack8"), params, true);
params.clear();
params.put("name", sql_12_a);
params.put("auth_tan", sql_12_b);
- checkAssignment(url("SqlInjection/attack9"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/attack9"), params, true);
params.clear();
params.put("action_string", sql_13);
- checkAssignment(url("SqlInjection/attack10"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjection/attack10"), params, true);
checkResults("SqlInjection");
}
diff --git a/src/it/java/org/owasp/webgoat/integration/SqlInjectionMitigationIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/SqlInjectionMitigationIntegrationTest.java
index 8151194e0..f9c8a0ec5 100644
--- a/src/it/java/org/owasp/webgoat/integration/SqlInjectionMitigationIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/SqlInjectionMitigationIntegrationTest.java
@@ -27,7 +27,7 @@ public class SqlInjectionMitigationIntegrationTest extends IntegrationTest {
params.put("field5", "?");
params.put("field6", "prep.setString(1,\"\")");
params.put("field7", "prep.setString(2,\\\"\\\")");
- checkAssignment(url("SqlInjectionMitigations/attack10a"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionMitigations/attack10a"), params, true);
params.put(
"editor",
@@ -41,37 +41,36 @@ public class SqlInjectionMitigationIntegrationTest extends IntegrationTest {
+ "} catch (Exception e) {\r\n"
+ " System.out.println(\"Oops. Something went wrong!\");\r\n"
+ "}");
- checkAssignment(url("SqlInjectionMitigations/attack10b"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionMitigations/attack10b"), params, true);
params.clear();
params.put(
"userid_sql_only_input_validation", "Smith';SELECT/**/*/**/from/**/user_system_data;--");
- checkAssignment(url("SqlOnlyInputValidation/attack"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlOnlyInputValidation/attack"), params, true);
params.clear();
params.put(
"userid_sql_only_input_validation_on_keywords",
"Smith';SESELECTLECT/**/*/**/FRFROMOM/**/user_system_data;--");
- checkAssignment(url("SqlOnlyInputValidationOnKeywords/attack"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlOnlyInputValidationOnKeywords/attack"), params, true);
- RestAssured.given()
+ RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.contentType(ContentType.JSON)
.get(
- url(
- "SqlInjectionMitigations/servers?column=(case when (true) then hostname"
- + " else id end)"))
+ webGoatUrlConfig.url("SqlInjectionMitigations/servers?column=(case when (true) then hostname"
+ + " else id end)"))
.then()
.statusCode(200);
- RestAssured.given()
+ RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.contentType(ContentType.JSON)
- .get(url("SqlInjectionMitigations/servers?column=unknown"))
+ .get(webGoatUrlConfig.url("SqlInjectionMitigations/servers?column=unknown"))
.then()
.statusCode(500)
.body(
@@ -82,7 +81,7 @@ public class SqlInjectionMitigationIntegrationTest extends IntegrationTest {
params.clear();
params.put("ip", "104.130.219.202");
- checkAssignment(url("SqlInjectionMitigations/attack12a"), params, true);
+ checkAssignment(webGoatUrlConfig.url("SqlInjectionMitigations/attack12a"), params, true);
checkResults("SqlInjectionMitigations");
}
diff --git a/src/it/java/org/owasp/webgoat/integration/WebWolfIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/WebWolfIntegrationTest.java
index 93f67f774..ba801493c 100644
--- a/src/it/java/org/owasp/webgoat/integration/WebWolfIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/WebWolfIntegrationTest.java
@@ -20,14 +20,14 @@ public class WebWolfIntegrationTest extends IntegrationTest {
// Assignment 3
Map params = new HashMap<>();
params.put("email", this.getUser() + "@webgoat.org");
- checkAssignment(url("WebWolf/mail/send"), params, false);
+ checkAssignment(webGoatUrlConfig.url("WebWolf/mail/send"), params, false);
String responseBody =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
- .get(new WebWolfUrlBuilder().path("mail").build())
+ .get(webWolfUrlConfig.url("mail"))
.then()
.extract()
.response()
@@ -41,15 +41,15 @@ public class WebWolfIntegrationTest extends IntegrationTest {
uniqueCode.lastIndexOf("your unique code is: ") + (21 + this.getUser().length()));
params.clear();
params.put("uniqueCode", uniqueCode);
- checkAssignment(url("WebWolf/mail"), params, true);
+ checkAssignment(webGoatUrlConfig.url("WebWolf/mail"), params, true);
// Assignment 4
- RestAssured.given()
+ RestAssured.given()
.when()
.relaxedHTTPSValidation()
.cookie("JSESSIONID", getWebGoatCookie())
.queryParams(params)
- .get(url("WebWolf/landing/password-reset"))
+ .get(webGoatUrlConfig.url("WebWolf/landing/password-reset"))
.then()
.statusCode(200);
RestAssured.given()
@@ -57,7 +57,7 @@ public class WebWolfIntegrationTest extends IntegrationTest {
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
.queryParams(params)
- .get(new WebWolfUrlBuilder().path("landing").build())
+ .get(webWolfUrlConfig.url("landing"))
.then()
.statusCode(200);
responseBody =
@@ -65,7 +65,7 @@ public class WebWolfIntegrationTest extends IntegrationTest {
.when()
.relaxedHTTPSValidation()
.cookie("WEBWOLFSESSION", getWebWolfCookie())
- .get(new WebWolfUrlBuilder().path("requests").build())
+ .get(webWolfUrlConfig.url("requests"))
.then()
.extract()
.response()
@@ -74,7 +74,7 @@ public class WebWolfIntegrationTest extends IntegrationTest {
assertTrue(responseBody.contains(uniqueCode));
params.clear();
params.put("uniqueCode", uniqueCode);
- checkAssignment(url("WebWolf/landing"), params, true);
+ checkAssignment(webGoatUrlConfig.url("WebWolf/landing"), params, true);
checkResults("WebWolfIntroduction");
}
diff --git a/src/it/java/org/owasp/webgoat/integration/XSSIntegrationTest.java b/src/it/java/org/owasp/webgoat/integration/XSSIntegrationTest.java
index fa06bb8f9..ed1cc12bf 100644
--- a/src/it/java/org/owasp/webgoat/integration/XSSIntegrationTest.java
+++ b/src/it/java/org/owasp/webgoat/integration/XSSIntegrationTest.java
@@ -18,7 +18,7 @@ public class XSSIntegrationTest extends IntegrationTest {
Map params = new HashMap<>();
params.clear();
params.put("checkboxAttack1", "value");
- checkAssignment(url("CrossSiteScripting/attack1"), params, true);
+ checkAssignment(webGoatUrlConfig.url("CrossSiteScripting/attack1"), params, true);
params.clear();
params.put("QTY1", "1");
@@ -27,17 +27,17 @@ public class XSSIntegrationTest extends IntegrationTest {
params.put("QTY4", "1");
params.put("field1", "");
params.put("field2", "111");
- checkAssignmentWithGet(url("CrossSiteScripting/attack5a"), params, true);
+ checkAssignmentWithGet(webGoatUrlConfig.url("CrossSiteScripting/attack5a"), params, true);
params.clear();
params.put("DOMTestRoute", "start.mvc#test");
- checkAssignment(url("CrossSiteScripting/attack6a"), params, true);
+ checkAssignment(webGoatUrlConfig.url("CrossSiteScripting/attack6a"), params, true);
params.clear();
params.put("param1", "42");
params.put("param2", "24");
- String result =
+ String result =
RestAssured.given()
.when()
.relaxedHTTPSValidation()
@@ -45,7 +45,7 @@ public class XSSIntegrationTest extends IntegrationTest {
.header("webgoat-requested-by", "dom-xss-vuln")
.header("X-Requested-With", "XMLHttpRequest")
.formParams(params)
- .post(url("CrossSiteScripting/phone-home-xss"))
+ .post(webGoatUrlConfig.url("CrossSiteScripting/phone-home-xss"))
.then()
.statusCode(200)
.extract()
@@ -54,7 +54,7 @@ public class XSSIntegrationTest extends IntegrationTest {
params.clear();
params.put("successMessage", secretNumber);
- checkAssignment(url("CrossSiteScripting/dom-follow-up"), params, true);
+ checkAssignment(webGoatUrlConfig.url("CrossSiteScripting/dom-follow-up"), params, true);
params.clear();
params.put(
@@ -77,7 +77,7 @@ public class XSSIntegrationTest extends IntegrationTest {
"question_4_solution",
"Solution 4: No there are many other ways. Like HTML, Flash or any other type of code that"
+ " the browser executes.");
- checkAssignment(url("CrossSiteScripting/quiz"), params, true);
+ checkAssignment(webGoatUrlConfig.url("CrossSiteScripting/quiz"), params, true);
params.clear();
params.put(
@@ -103,7 +103,7 @@ public class XSSIntegrationTest extends IntegrationTest {
+ ""
+ "