MCPcopy Index your code
hub / github.com/OWASP/SecurityShepherd / testGetChallenges

Method testGetChallenges

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

Source from the content-addressed store, hash-verified

676 }
677
678 @Test
679 public void testGetChallenges()
680 {
681 String userName = new String("testGetChallengesUser");
682 try
683 {
684 if(verifyTestUser(applicationRoot, userName, userName))
685 {
686 String userId = Getter.getUserIdFromName(applicationRoot, userName);
687 //Open all Modules First so that the GetAllModuleInfo method will return data
688 if(Setter.openAllModules(applicationRoot))
689 {
690 String modules = Getter.getChallenges(applicationRoot, userId, locale);
691 if(!modules.isEmpty()) //Some Modules were included in response
692 {
693 //Get number of Challenges returned by getChallenges method
694 int numberofChallengesReturned = (modules.length() - modules.replace("class='lesson'", "").length()) / "class='lesson'".length();
695 if(numberofChallengesReturned > totalNumberOfModulesInShepherd)
696 {
697 log.debug("PASS: Found " + numberofChallengesReturned + " modules");
698 return;
699 }
700 else
701 {
702 log.debug("Too Few Challenges Returned to pass: " + numberofChallengesReturned + " returned. Expected at least:" + totalNumberOfModulesInShepherd);
703 fail("Too Few Challenges Returned to Pass");
704 }
705 }
706 else
707 {
708 log.fatal("No Modules Found. Returned empty String");
709 fail("No Modules Found");
710 }
711 }
712 else
713 {
714 fail("Could Not Mark Modules as Open Before Test");
715 }
716 }
717 else
718 {
719 fail("Could not verify user (No Exception Failure)");
720 }
721 }
722 catch(Exception e)
723 {
724 log.fatal("Could not Verify User: " + e.toString());
725 fail("Could not Verify User " + userName);
726 }
727 }
728
729 @Test
730 public void testGetChallengesWhenModulesClosed()

Callers

nothing calls this directly

Calls 4

verifyTestUserMethod · 0.95
getUserIdFromNameMethod · 0.95
openAllModulesMethod · 0.95
getChallengesMethod · 0.95

Tested by

no test coverage detected