From 3883563c7dc322c5c13602420f583f22db80aef1 Mon Sep 17 00:00:00 2001 From: Benedikt - Desktop Date: Sat, 22 Dec 2018 19:14:34 +0100 Subject: [PATCH] Fixed feedback-check in sql introduction tests. --- .../SqlInjectionLesson10Test.java | 10 +++---- .../SqlInjectionLesson5aTest.java | 2 +- .../SqlInjectionLesson6aTest.java | 2 +- .../introduction/SqlInjectionLesson8Test.java | 14 +++++----- .../introduction/SqlInjectionLesson9Test.java | 26 ++++++++----------- 5 files changed, 23 insertions(+), 31 deletions(-) diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson10Test.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson10Test.java index e3bf3ce6a..b25a5e8a6 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson10Test.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson10Test.java @@ -46,7 +46,7 @@ public class SqlInjectionLesson10Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.10.entries"))))); + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.10.entries"))))); } catch (AssertionError e) { if (!e.getMessage().contains(completedError)) throw e; @@ -55,7 +55,7 @@ public class SqlInjectionLesson10Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.10.success"))))); + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.10.success"))))); } } @@ -66,10 +66,6 @@ public class SqlInjectionLesson10Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.10.success"))))); - } - - private String modifySpan(String message) { - return message.replace("", "<\\/span>"); + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.10.success"))))); } } \ No newline at end of file diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson5aTest.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson5aTest.java index f5cbc55c4..58025726a 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson5aTest.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson5aTest.java @@ -65,7 +65,7 @@ public class SqlInjectionLesson5aTest extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(messages.getMessage("NoResultsMatched")))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("NoResultsMatched"))))) .andExpect(jsonPath("$.output").doesNotExist()); } diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java index 2eb75edf4..e0df7d83b 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java @@ -74,7 +74,7 @@ public class SqlInjectionLesson6aTest extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("$.lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(messages.getMessage("sql-injection.6a.no.results")))); + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.6a.no.results"))))); } @Test diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson8Test.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson8Test.java index 7b14e4a77..1a6a2b2df 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson8Test.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson8Test.java @@ -42,7 +42,7 @@ public class SqlInjectionLesson8Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.8.one"))))) + .andExpect(jsonPath("$.feedback", is(modifySpan(messages.getMessage("sql-injection.8.one"))))) .andExpect(jsonPath("$.output", containsString("
"))); } @@ -54,7 +54,7 @@ public class SqlInjectionLesson8Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.8.success"))))) + .andExpect(jsonPath("$.feedback", is(modifySpan(messages.getMessage("sql-injection.8.success"))))) .andExpect(jsonPath("$.output", containsString("
96134<\\/td>Bob<\\/td>Franco<\\/td>Marketing<\\/td>83700<\\/td>LO9S2V<\\/td><\\/tr>"))); } @@ -66,7 +66,7 @@ public class SqlInjectionLesson8Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.8.no.results"))))) + .andExpect(jsonPath("$.feedback", is(modifySpan(messages.getMessage("sql-injection.8.no.results"))))) .andExpect(jsonPath("$.output").doesNotExist()); } @@ -78,7 +78,7 @@ public class SqlInjectionLesson8Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.8.no.results"))))) + .andExpect(jsonPath("$.feedback", is(modifySpan(messages.getMessage("sql-injection.8.no.results"))))) .andExpect(jsonPath("$.output").doesNotExist()); } @@ -90,11 +90,11 @@ public class SqlInjectionLesson8Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.error"))))) + .andExpect(jsonPath("$.feedback", is(modifySpan(messages.getMessage("sql-injection.error"))))) .andExpect(jsonPath("$.output", containsString("feedback-negative"))); } - private String modifySpan(String message) { + public static String modifySpan(String message) { return message.replace("", "<\\/span>"); } -} +} \ No newline at end of file diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson9Test.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson9Test.java index 5e81a26b7..d39420dbd 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson9Test.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson9Test.java @@ -45,7 +45,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.9.one"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.9.one"))))) .andExpect(jsonPath("$.output", containsString("
"))); } catch (AssertionError e) { if (!e.getMessage().contains(completedError)) throw e; @@ -56,7 +56,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.9.success"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.9.success"))))) .andExpect(jsonPath("$.output", containsString("
"))); } } @@ -70,7 +70,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.9.one"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.9.one"))))) .andExpect(jsonPath("$.output", containsString("
96134<\\/td>Bob<\\/td>Franco<\\/td>Marketing<\\/td>83700<\\/td>LO9S2V<\\/td><\\/tr>"))); } catch (AssertionError e) { if (!e.getMessage().contains(completedError)) throw e; @@ -81,7 +81,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.9.success"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.9.success"))))) .andExpect(jsonPath("$.output", containsString("
96134<\\/td>Bob<\\/td>Franco<\\/td>Marketing<\\/td>83700<\\/td>LO9S2V<\\/td><\\/tr>"))); } } @@ -95,7 +95,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.8.no.results"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.8.no.results"))))) .andExpect(jsonPath("$.output").doesNotExist()); } catch (AssertionError e) { if (!e.getMessage().contains(completedError)) throw e; @@ -106,7 +106,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.8.no.success"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.8.no.success"))))) .andExpect(jsonPath("$.output").doesNotExist()); } } @@ -120,7 +120,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.8.no.results"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.8.no.results"))))) .andExpect(jsonPath("$.output").doesNotExist()); } catch (AssertionError e) { if (!e.getMessage().contains(completedError)) throw e; @@ -131,7 +131,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.9.success"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.9.success"))))) .andExpect(jsonPath("$.output").doesNotExist()); } } @@ -145,7 +145,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(false))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.error"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.error"))))) .andExpect(jsonPath("$.output", containsString("feedback-negative"))); } catch (AssertionError e) { if (!e.getMessage().contains(completedError)) throw e; @@ -156,7 +156,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.9.success"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.9.success"))))) .andExpect(jsonPath("$.output", containsString("feedback-negative"))); } } @@ -169,11 +169,7 @@ public class SqlInjectionLesson9Test extends LessonTest { .andExpect(status().isOk()) .andExpect(jsonPath("lessonCompleted", is(true))) - .andExpect(jsonPath("$.feedback", is(this.modifySpan(messages.getMessage("sql-injection.9.success"))))) + .andExpect(jsonPath("$.feedback", is(SqlInjectionLesson8Test.modifySpan(messages.getMessage("sql-injection.9.success"))))) .andExpect(jsonPath("$.output", containsString("300000"))); } - - private String modifySpan(String message) { - return message.replace("", "<\\/span>"); - } } \ No newline at end of file