MCPcopy Create free account
hub / github.com/OWASP/SecurityShepherd / testGetFeedback

Method testGetFeedback

src/test/java/dbProcs/GetterTest.java:1020–1082  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1018 }
1019
1020 @Test
1021 public void testGetFeedback()
1022 {
1023 String userName = new String("userGetFeedback");
1024 String dataStorageLessonId = new String("53a53a66cb3bf3e4c665c442425ca90e29536edd");
1025 try
1026 {
1027 if(verifyTestUser(applicationRoot, userName, userName))
1028 {
1029 String userId = Getter.getUserIdFromName(applicationRoot, userName);
1030 //Open all Modules First so that the Module Can Be Opened
1031 if(Setter.openAllModules(applicationRoot))
1032 {
1033 //Simulate user Opening Level
1034 if(!Getter.getModuleAddress(applicationRoot, dataStorageLessonId, userId).isEmpty())
1035 {
1036 //Then, Mark the Challenge Complete for user (Insecure Data Storage Lesson)
1037 String feedbackSearchCode = "RwarUNiqueFeedbackCodeToSEARCHFor1182371723";
1038 String markLevelCompleteTest = Setter.updatePlayerResult(applicationRoot, dataStorageLessonId, userId, feedbackSearchCode, 1, 1, 1);
1039 if (markLevelCompleteTest != null)
1040 {
1041 String checkPlayerResultTest = Getter.checkPlayerResult(applicationRoot, dataStorageLessonId, userId);
1042 log.debug("checkPlayerResultTest" + checkPlayerResultTest);
1043 if(checkPlayerResultTest == null)
1044 {
1045 log.debug("Checking to see if the feedback is included in the getFeeback response for the module");
1046 String feedback = Getter.getFeedback(applicationRoot, dataStorageLessonId);
1047 if(feedback.indexOf(feedbackSearchCode) > -1)
1048 {
1049 log.debug("PASS: Detected the user's feedback");
1050 return;
1051 }
1052 else
1053 {
1054 log.fatal("User's Feedback '" + feedbackSearchCode + "' was not found in: " + feedback);
1055 fail("Could not find user's feedback");
1056 }
1057 }
1058 else
1059 {
1060 fail("Function says user has not completed module"); //Even though this test just marked it as Completed
1061 }
1062 }
1063 else
1064 fail("Could not mark data storage lesson as complete for user");
1065 }
1066 else
1067 fail("Could not Mark Data Storage Lesson as Opened by Default admin");
1068 }
1069 else
1070 fail("Could not Open All Modules");
1071 }
1072 else
1073 {
1074 fail("Could not verify user (No Exception Failure)");
1075 }
1076 }
1077 catch(Exception e)

Callers

nothing calls this directly

Calls 7

verifyTestUserMethod · 0.95
getUserIdFromNameMethod · 0.95
openAllModulesMethod · 0.95
getModuleAddressMethod · 0.95
updatePlayerResultMethod · 0.95
checkPlayerResultMethod · 0.95
getFeedbackMethod · 0.95

Tested by

no test coverage detected