Skip to content

Commit

Permalink
fix: debug failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaars committed Mar 26, 2024
1 parent 4c88d86 commit 6abfdac
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/it/java/org/owasp/webgoat/ChallengeIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import io.restassured.RestAssured;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.assertj.core.api.Assertions;
Expand All @@ -28,11 +27,10 @@ void testChallenge1() {
.extract()
.asByteArray();

String pincode = new String(Arrays.copyOfRange(resultBytes, 81216, 81220));
Map<String, Object> params = new HashMap<>();
params.clear();
params.put("username", "admin");
params.put("password", "!!webgoat_admin_1234!!".replace("1234", pincode));
String pin = new String(Arrays.copyOfRange(resultBytes, 81216, 81220));
System.out.println("PIN" + pin);
Map<String, Object> params =
Map.of("username", "admin", "password", "!!webgoat_admin_%s!!".formatted(pin));

checkAssignment(url("challenge/1"), params, true);
String result =
Expand All @@ -48,12 +46,9 @@ void testChallenge1() {
.asString();

String flag = result.substring(result.indexOf("flag") + 6, result.indexOf("flag") + 42);
params.clear();
params.put("flag", flag);
checkAssignment(url("challenge/flag"), params, true);
checkAssignment(url("challenge/flag"), Map.of("flag", flag), true);

// TODO: fails on Ubuntu latest in GitHub Actions need to investigate
// checkResults("/challenge/1");
checkResults("/challenge/1");

List<String> capturefFlags =
RestAssured.given()
Expand All @@ -73,10 +68,8 @@ void testChallenge1() {
void testChallenge5() {
startLesson("Challenge5");

Map<String, Object> params = new HashMap<>();
params.clear();
params.put("username_login", "Larry");
params.put("password_login", "1' or '1'='1");
Map<String, Object> params =
Map.of("username_login", "Larry", "password_login", "1' or '1'='1");

String result =
RestAssured.given()
Expand All @@ -91,9 +84,7 @@ void testChallenge5() {
.asString();

String flag = result.substring(result.indexOf("flag") + 6, result.indexOf("flag") + 42);
params.clear();
params.put("flag", flag);
checkAssignment(url("challenge/flag"), params, true);
checkAssignment(url("challenge/flag"), Map.of("flag", flag), true);

checkResults("/challenge/5");

Expand Down

0 comments on commit 6abfdac

Please sign in to comment.