Merge pull request #166 from misfir3/master
#165 support for custom submitMethod
This commit is contained in:
commit
8d87830472
@ -233,6 +233,12 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
|
|||||||
*/
|
*/
|
||||||
protected abstract boolean getDefaultHidden();
|
protected abstract boolean getDefaultHidden();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>getSubmitMethod</p>
|
||||||
|
*/
|
||||||
|
public abstract String getSubmitMethod();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the fileMethod attribute of the Lesson class
|
* 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();
|
.append("/").append(getCategory().getRanking()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the link to the target servlet.
|
* Get the link to the target servlet.
|
||||||
*
|
*
|
||||||
* Unlike getLink() this method does not require rendering the output of
|
* Unlike getLink() this method does not require rendering the output of
|
||||||
|
@ -153,6 +153,13 @@ public abstract class LessonAdapter extends AbstractLesson {
|
|||||||
return hints;
|
return hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* provide a default submitMethod of lesson does not implement
|
||||||
|
*/
|
||||||
|
public String getSubmitMethod() {
|
||||||
|
return "GET";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -4,9 +4,6 @@ import org.owasp.webgoat.lessons.AbstractLesson;
|
|||||||
import org.owasp.webgoat.lessons.Category;
|
import org.owasp.webgoat.lessons.Category;
|
||||||
import org.owasp.webgoat.session.WebSession;
|
import org.owasp.webgoat.session.WebSession;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by jason on 9/18/15.
|
|
||||||
*/
|
|
||||||
public class LessonInfoModel {
|
public class LessonInfoModel {
|
||||||
|
|
||||||
private String lessonTitle;
|
private String lessonTitle;
|
||||||
@ -14,9 +11,7 @@ public class LessonInfoModel {
|
|||||||
private boolean hasSource;
|
private boolean hasSource;
|
||||||
private boolean hasSolution;
|
private boolean hasSolution;
|
||||||
private boolean hasPlan;
|
private boolean hasPlan;
|
||||||
private String source;
|
private String submitMethod;
|
||||||
private String solution;
|
|
||||||
private String plan;
|
|
||||||
|
|
||||||
public LessonInfoModel(WebSession webSession) {
|
public LessonInfoModel(WebSession webSession) {
|
||||||
AbstractLesson lesson = webSession.getCurrentLesson();
|
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.hasSolution = !lesson.getSolution(webSession).contains("Could not find the solution file or solution file does not exist");
|
||||||
this.lessonTitle = lesson.getTitle();
|
this.lessonTitle = lesson.getTitle();
|
||||||
this.numberHints = lesson.getHintCount(webSession);
|
this.numberHints = lesson.getHintCount(webSession);
|
||||||
|
this.submitMethod = lesson.getSubmitMethod();
|
||||||
|
|
||||||
if ( this.numberHints < 1 || lesson.getHint(webSession,0).equals("Hint: There are no hints defined.")) {
|
if ( this.numberHints < 1 || lesson.getHint(webSession,0).equals("Hint: There are no hints defined.")) {
|
||||||
this.numberHints = 0;
|
this.numberHints = 0;
|
||||||
@ -60,16 +56,8 @@ public class LessonInfoModel {
|
|||||||
return hasPlan;
|
return hasPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSource() {
|
public String getSubmitMethod() {
|
||||||
return source;
|
return submitMethod;
|
||||||
}
|
|
||||||
|
|
||||||
public String getSolution() {
|
|
||||||
return solution;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPlan() {
|
|
||||||
return plan;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.owasp.webgoat.session.WebSession;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class AbstractLessonTest {
|
public class AbstractLessonTest {
|
||||||
@ -41,6 +42,7 @@ public class AbstractLessonTest {
|
|||||||
public String getCurrentAction(WebSession s) {
|
public String getCurrentAction(WebSession s) {
|
||||||
return "an action";
|
return "an action";
|
||||||
}
|
}
|
||||||
|
public String getSubmitMethod() { return "GET";}
|
||||||
public void restartLesson() {
|
public void restartLesson() {
|
||||||
}
|
}
|
||||||
public void setCurrentAction(WebSession s, String lessonScreen) {
|
public void setCurrentAction(WebSession s, String lessonScreen) {
|
||||||
@ -56,6 +58,7 @@ public class AbstractLessonTest {
|
|||||||
String srvLink = lesson.getServletLink();
|
String srvLink = lesson.getServletLink();
|
||||||
assertThat(srvLink, CoreMatchers.startsWith("attack?Screen="));
|
assertThat(srvLink, CoreMatchers.startsWith("attack?Screen="));
|
||||||
assertThat(srvLink, CoreMatchers.endsWith("&menu=900"));
|
assertThat(srvLink, CoreMatchers.endsWith("&menu=900"));
|
||||||
|
assertEquals(lesson.getSubmitMethod(),"GET");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user