Merge pull request #166 from misfir3/master

#165 support for custom submitMethod
This commit is contained in:
Nanne 2016-01-15 17:38:26 +01:00
commit 8d87830472
4 changed files with 21 additions and 17 deletions

View File

@ -233,6 +233,12 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
*/
protected abstract boolean getDefaultHidden();
/**
* <p>getSubmitMethod</p>
*/
public abstract String getSubmitMethod();
/**
* Gets the fileMethod attribute of the Lesson class
*
@ -643,7 +649,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
.append("/").append(getCategory().getRanking()).toString();
}
/**
/**
* Get the link to the target servlet.
*
* Unlike getLink() this method does not require rendering the output of

View File

@ -153,6 +153,13 @@ public abstract class LessonAdapter extends AbstractLesson {
return hints;
}
/**
* provide a default submitMethod of lesson does not implement
*/
public String getSubmitMethod() {
return "GET";
}
/**
* {@inheritDoc}
*

View File

@ -4,9 +4,6 @@ import org.owasp.webgoat.lessons.AbstractLesson;
import org.owasp.webgoat.lessons.Category;
import org.owasp.webgoat.session.WebSession;
/**
* Created by jason on 9/18/15.
*/
public class LessonInfoModel {
private String lessonTitle;
@ -14,9 +11,7 @@ public class LessonInfoModel {
private boolean hasSource;
private boolean hasSolution;
private boolean hasPlan;
private String source;
private String solution;
private String plan;
private String submitMethod;
public LessonInfoModel(WebSession webSession) {
AbstractLesson lesson = webSession.getCurrentLesson();
@ -26,6 +21,7 @@ public class LessonInfoModel {
this.hasSolution = !lesson.getSolution(webSession).contains("Could not find the solution file or solution file does not exist");
this.lessonTitle = lesson.getTitle();
this.numberHints = lesson.getHintCount(webSession);
this.submitMethod = lesson.getSubmitMethod();
if ( this.numberHints < 1 || lesson.getHint(webSession,0).equals("Hint: There are no hints defined.")) {
this.numberHints = 0;
@ -60,16 +56,8 @@ public class LessonInfoModel {
return hasPlan;
}
public String getSource() {
return source;
}
public String getSolution() {
return solution;
}
public String getPlan() {
return plan;
public String getSubmitMethod() {
return submitMethod;
}
}

View File

@ -9,6 +9,7 @@ import org.owasp.webgoat.session.WebSession;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
public class AbstractLessonTest {
@ -41,6 +42,7 @@ public class AbstractLessonTest {
public String getCurrentAction(WebSession s) {
return "an action";
}
public String getSubmitMethod() { return "GET";}
public void restartLesson() {
}
public void setCurrentAction(WebSession s, String lessonScreen) {
@ -56,6 +58,7 @@ public class AbstractLessonTest {
String srvLink = lesson.getServletLink();
assertThat(srvLink, CoreMatchers.startsWith("attack?Screen="));
assertThat(srvLink, CoreMatchers.endsWith("&menu=900"));
assertEquals(lesson.getSubmitMethod(),"GET");
}
}