#165 provide default and ability to override in lesson
This commit is contained in:
parent
1a7535e3e2
commit
b3541231bc
@ -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,6 +649,22 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
|
||||
.append("/").append(getCategory().getRanking()).toString();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * *Get the method for to provide to the UI for the attack submit
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public String getSubmitMethod() {
|
||||
// System.out.println("### getting submitMethod");
|
||||
// if ("".equals(this.getLabelManager().get("submitMethod"))) {
|
||||
// System.out.println("*** submitMethod: GET");
|
||||
// return "GET";
|
||||
// } else {
|
||||
// System.out.println("*** submitMethod: " + this.getLabelManager().get("submitMethod"));
|
||||
// return this.getLabelManager().get("submitMethod");
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the link to the target servlet.
|
||||
*
|
||||
|
@ -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}
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user