diff --git a/pom.xml b/pom.xml index d9caf9678..66ff1c85b 100644 --- a/pom.xml +++ b/pom.xml @@ -293,7 +293,7 @@ start - + ${project.build.directory} java -jar @@ -582,7 +582,7 @@ ${basedir}/src/test/resources/logback-test.xml -Xmx512m -Dwebgoatport=${webgoat.port} -Dwebwolfport=${webwolf.port} - **/*IntegrationTest.java + org/owasp/webgoat/*Test @@ -609,6 +609,8 @@ **/*IntegrationTest.java + src/it/java + org/owasp/webgoat/*Test diff --git a/src/it/java/org/owasp/webgoat/LabelAndHintTest.java b/src/it/java/org/owasp/webgoat/LabelAndHintTest.java new file mode 100644 index 000000000..0724e9475 --- /dev/null +++ b/src/it/java/org/owasp/webgoat/LabelAndHintTest.java @@ -0,0 +1,89 @@ +package org.owasp.webgoat; + +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import io.restassured.path.json.JsonPath; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Properties; + +public class LabelAndHintTest extends IntegrationTest { + + + @Test + public void testSingleLabel() { + Assertions.assertTrue(true); + JsonPath jsonPath = RestAssured.given() + .when() + .relaxedHTTPSValidation() + .contentType(ContentType.JSON) + .header("Accept-Language","en") + .cookie("JSESSIONID", getWebGoatCookie()) + .get(url("service/labels.mvc")).then().statusCode(200).extract().jsonPath(); + + Assertions.assertEquals("Try again: but this time enter a value before hitting go.", jsonPath.getString("\'http-basics.close\'")); + } + + @Test + public void testLabels() { + + Properties propsDefault = getProperties(""); + System.out.println("Working Directory = " + System.getProperty("user.dir")); + checkLang(propsDefault,"nl"); + checkLang(propsDefault,"de"); + checkLang(propsDefault,"fr"); + checkLang(propsDefault,"ru"); + + } + + private Properties getProperties(String lang) { + Properties prop = null; + if (lang == null || lang.equals("")) { lang = ""; } else { lang = "_"+lang; } + try (InputStream input = new FileInputStream("src/main/resources/i18n/messages"+lang+".properties")) { + + prop = new Properties(); + // load a properties file + prop.load(input); + } catch (Exception e) { + e.printStackTrace(); + } + return prop; + } + + private void checkLang(Properties propsDefault, String lang) { + JsonPath jsonPath = getLabels(lang); + Properties propsLang = getProperties(lang); + + for (String key: propsLang.stringPropertyNames()) { + if (!propsDefault.containsKey(key)) { + System.err.println("key: " + key + " in (" +lang+") is missing from default properties"); + Assertions.fail(); + } + /*if (!jsonPath.getString("\'"+key+"\'").equals(propsLang.get(key))) { + System.out.println("key: " + key + " in (" +lang+") has incorrect translation in label service"); + System.out.println("actual:"+jsonPath.getString("\'"+key+"\'")); + System.out.println("expected: "+propsLang.getProperty(key)); + System.out.println(); + //Assertions.fail(); + }*/ + } + } + + private JsonPath getLabels(String lang) { + return RestAssured.given() + .when() + .relaxedHTTPSValidation() + .contentType(ContentType.JSON) + .header("Accept-Language",lang) + .cookie("JSESSIONID", getWebGoatCookie()) + //.log().headers() + .get(url("service/labels.mvc")) + .then() + //.log().all() + .statusCode(200).extract().jsonPath(); + } + +} diff --git a/src/main/resources/i18n/messages_de.properties b/src/main/resources/i18n/messages_de.properties index 152981238..3cb246153 100644 --- a/src/main/resources/i18n/messages_de.properties +++ b/src/main/resources/i18n/messages_de.properties @@ -24,7 +24,7 @@ # #General -LessonCompleted=Herzlichen Gl\u00fcckwunsch! Sie haben diese Lektion erfolgreich abgeschlossen. +lesson.completed=Herzlichen Gl\u00fcckwunsch! Sie haben diese Lektion erfolgreich abgeschlossen. RestartLesson=Lektion neu beginnen SolutionVideos=L\u00f6sungsvideos ErrorGenerating=Fehler beim Generieren von diff --git a/src/main/resources/i18n/messages_fr.properties b/src/main/resources/i18n/messages_fr.properties index 340a11bd7..737c207fc 100644 --- a/src/main/resources/i18n/messages_fr.properties +++ b/src/main/resources/i18n/messages_fr.properties @@ -24,9 +24,9 @@ # #General -LessonCompleted=F\u00e9licitations. Vous avez termin\u00e9 cette le\u00e7on avec succ\u00e9s. +lesson.completed=F\u00e9licitations. Vous avez termin\u00e9 cette le\u00e7on avec succ\u00e9s. RestartLesson=Recommencer cette le\u00e7on SolutionVideos=Solution vid\u00e9os ErrorGenerating=Error generating InvalidData=Donn\u00e9e invalide -Go!=Go! +Go!=Allez le faire! diff --git a/src/main/resources/i18n/messages_nl.properties b/src/main/resources/i18n/messages_nl.properties index 2370be9d4..065b566ff 100644 --- a/src/main/resources/i18n/messages_nl.properties +++ b/src/main/resources/i18n/messages_nl.properties @@ -22,12 +22,12 @@ # projects. #

# -LessonCompleted=Gefeliciteerd, je hebt de les succesvol afgerond. +lesson.completed=Gefeliciteerd, je hebt de les succesvol afgerond. RestartLesson=Herstart de les SolutionVideos=Video oplossingen ErrorGenerating=Fout opgetreden tijdens generatie InvalidData=Ongeldige invoer -Go!=Go! +Go!=Ga snel aan de slag! password=Wachtwoord username=Gebruikersnaam logged_out=Je bent succesvol uitgelogd. @@ -46,4 +46,4 @@ contact=Neem contact met ons op show.hints=Toon hints lesson.overview=Overzicht les reset.lesson=Herstart les -sign.in=Log in \ No newline at end of file +sign.in=Log in diff --git a/src/main/resources/i18n/messages_ru.properties b/src/main/resources/i18n/messages_ru.properties index 436a81ee5..e24c2b8f4 100644 --- a/src/main/resources/i18n/messages_ru.properties +++ b/src/main/resources/i18n/messages_ru.properties @@ -24,7 +24,7 @@ # #General -LessonCompleted=\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e. \u0412\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0448\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u0443\u0440\u043e\u043a. +lesson.completed=\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e. \u0412\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0448\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u0443\u0440\u043e\u043a. RestartLesson=\u041d\u0430\u0447\u0430\u043b\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 SolutionVideos=\u0412\u0438\u0434\u0435\u043e \u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c ErrorGenerating=\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 diff --git a/src/test/java/org/owasp/webgoat/container/service/LessonMenuServiceTest.java b/src/test/java/org/owasp/webgoat/container/service/LessonMenuServiceTest.java index d889e2665..5f7e1e751 100644 --- a/src/test/java/org/owasp/webgoat/container/service/LessonMenuServiceTest.java +++ b/src/test/java/org/owasp/webgoat/container/service/LessonMenuServiceTest.java @@ -98,7 +98,7 @@ public class LessonMenuServiceTest { when(userTrackerRepository.findByUser(any())).thenReturn(userTracker); mockMvc.perform(MockMvcRequestBuilders.get(URL_LESSONMENU_MVC)) - .andExpect(status().isOk()).andDo(print()) + .andExpect(status().isOk())//.andDo(print()) .andExpect(jsonPath("$[0].children[0].complete", CoreMatchers.is(true))); } } diff --git a/src/test/java/org/owasp/webgoat/lessons/path_traversal/ProfileUploadRetrievalTest.java b/src/test/java/org/owasp/webgoat/lessons/path_traversal/ProfileUploadRetrievalTest.java index da3e80194..77629dd5a 100644 --- a/src/test/java/org/owasp/webgoat/lessons/path_traversal/ProfileUploadRetrievalTest.java +++ b/src/test/java/org/owasp/webgoat/lessons/path_traversal/ProfileUploadRetrievalTest.java @@ -48,7 +48,7 @@ public class ProfileUploadRetrievalTest extends LessonTest { var uri = new URI("/PathTraversal/random-picture?id=%2E%2E%2F%2E%2E%2F"); mockMvc.perform(get(uri)) .andExpect(status().is(404)) - .andDo(MockMvcResultHandlers.print()) + //.andDo(MockMvcResultHandlers.print()) .andExpect(content().string(containsString("path-traversal-secret.jpg"))); //Retrieve the secret file (note: .jpg is added by the server) diff --git a/src/test/java/org/owasp/webgoat/lessons/xxe/ContentTypeAssignmentTest.java b/src/test/java/org/owasp/webgoat/lessons/xxe/ContentTypeAssignmentTest.java index 10d4d75cb..0e42b26e6 100644 --- a/src/test/java/org/owasp/webgoat/lessons/xxe/ContentTypeAssignmentTest.java +++ b/src/test/java/org/owasp/webgoat/lessons/xxe/ContentTypeAssignmentTest.java @@ -99,7 +99,7 @@ public class ContentTypeAssignmentTest extends LessonTest { mockMvc.perform(get("/xxe/comments").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) - .andDo(MockMvcResultHandlers.print()) + //.andDo(MockMvcResultHandlers.print()) .andExpect(jsonPath("$.[*]").value(Matchers.hasSize(numberOfComments))); }