Compare commits
	
		
			1 Commits
		
	
	
		
			f2e2616a88
			...
			label-hint
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | dde1008eb8 | 
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -293,7 +293,7 @@ | |||||||
|                                     <goal>start</goal> |                                     <goal>start</goal> | ||||||
|                                 </goals> |                                 </goals> | ||||||
|                                 <configuration> |                                 <configuration> | ||||||
|                                     <workingDir></workingDir> |                                     <workingDir>${project.build.directory}</workingDir> | ||||||
|                                     <arguments> |                                     <arguments> | ||||||
|                                         <argument>java</argument> |                                         <argument>java</argument> | ||||||
|                                         <argument>-jar</argument> |                                         <argument>-jar</argument> | ||||||
|   | |||||||
							
								
								
									
										88
									
								
								src/it/java/org/owasp/webgoat/LabelAndHintTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								src/it/java/org/owasp/webgoat/LabelAndHintTest.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | |||||||
|  | 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.out.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 | #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 | RestartLesson=Lektion neu beginnen | ||||||
| SolutionVideos=L\u00f6sungsvideos | SolutionVideos=L\u00f6sungsvideos | ||||||
| ErrorGenerating=Fehler beim Generieren von | ErrorGenerating=Fehler beim Generieren von | ||||||
|   | |||||||
| @@ -24,9 +24,9 @@ | |||||||
| # | # | ||||||
|  |  | ||||||
| #General | #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 | RestartLesson=Recommencer cette le\u00e7on | ||||||
| SolutionVideos=Solution vid\u00e9os | SolutionVideos=Solution vid\u00e9os | ||||||
| ErrorGenerating=Error generating | ErrorGenerating=Error generating | ||||||
| InvalidData=Donn\u00e9e invalide | InvalidData=Donn\u00e9e invalide | ||||||
| Go!=Go! | Go!=Allez le faire! | ||||||
|   | |||||||
| @@ -22,12 +22,12 @@ | |||||||
| # projects. | # projects. | ||||||
| # <p> | # <p> | ||||||
| # | # | ||||||
| LessonCompleted=Gefeliciteerd, je hebt de les succesvol afgerond. | lesson.completed=Gefeliciteerd, je hebt de les succesvol afgerond. | ||||||
| RestartLesson=Herstart de les | RestartLesson=Herstart de les | ||||||
| SolutionVideos=Video oplossingen | SolutionVideos=Video oplossingen | ||||||
| ErrorGenerating=Fout opgetreden tijdens generatie | ErrorGenerating=Fout opgetreden tijdens generatie | ||||||
| InvalidData=Ongeldige invoer | InvalidData=Ongeldige invoer | ||||||
| Go!=Go! | Go!=Ga snel aan de slag! | ||||||
| password=Wachtwoord | password=Wachtwoord | ||||||
| username=Gebruikersnaam | username=Gebruikersnaam | ||||||
| logged_out=Je bent succesvol uitgelogd. | logged_out=Je bent succesvol uitgelogd. | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ | |||||||
| # | # | ||||||
|  |  | ||||||
| #General | #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 | 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 | 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 | ErrorGenerating=\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user