Label hint tests (#1293)
* label test * adjusted it test filter * label test added
This commit is contained in:
parent
16af4272a5
commit
4fc03381a8
6
pom.xml
6
pom.xml
@ -293,7 +293,7 @@
|
||||
<goal>start</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<workingDir></workingDir>
|
||||
<workingDir>${project.build.directory}</workingDir>
|
||||
<arguments>
|
||||
<argument>java</argument>
|
||||
<argument>-jar</argument>
|
||||
@ -582,7 +582,7 @@
|
||||
<logback.configurationFile>${basedir}/src/test/resources/logback-test.xml</logback.configurationFile>
|
||||
</systemPropertyVariables>
|
||||
<argLine>-Xmx512m -Dwebgoatport=${webgoat.port} -Dwebwolfport=${webwolf.port}</argLine>
|
||||
<includes>**/*IntegrationTest.java</includes>
|
||||
<includes>org/owasp/webgoat/*Test</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@ -609,6 +609,8 @@
|
||||
</argLine>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>src/it/java</exclude>
|
||||
<exclude>org/owasp/webgoat/*Test</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
89
src/it/java/org/owasp/webgoat/LabelAndHintTest.java
Normal file
89
src/it/java/org/owasp/webgoat/LabelAndHintTest.java
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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!
|
||||
|
@ -22,12 +22,12 @@
|
||||
# projects.
|
||||
# <p>
|
||||
#
|
||||
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
|
||||
sign.in=Log in
|
||||
|
@ -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
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user