Skip to content

Commit

Permalink
Merge pull request WebGoat#166 from misfir3/master
Browse files Browse the repository at this point in the history
WebGoat#165 support for custom submitMethod
  • Loading branch information
nbaars committed Jan 15, 2016
2 parents 1a7535e + 07f0cea commit 8d87830
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ public Category getCategory() {
*/
protected abstract boolean getDefaultHidden();

/**
* <p>getSubmitMethod</p>
*/
public abstract String getSubmitMethod();


/**
* Gets the fileMethod attribute of the Lesson class
*
Expand Down Expand Up @@ -643,7 +649,7 @@ public String getLink() {
.append("/").append(getCategory().getRanking()).toString();
}

/**
/**
* Get the link to the target servlet.
*
* Unlike getLink() this method does not require rendering the output of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ protected List<String> getHints(WebSession s) {
return hints;
}

/**
* provide a default submitMethod of lesson does not implement
*/
public String getSubmitMethod() {
return "GET";
}

/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@
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;
private int numberHints;
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();
Expand All @@ -26,6 +21,7 @@ public LessonInfoModel(WebSession webSession) {
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;
Expand Down Expand Up @@ -60,16 +56,8 @@ public boolean isHasPlan() {
return hasPlan;
}

public String getSource() {
return source;
}

public String getSolution() {
return solution;
}

public String getPlan() {
return plan;
public String getSubmitMethod() {
return submitMethod;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

public class AbstractLessonTest {
Expand Down Expand Up @@ -41,6 +42,7 @@ public String getTitle() {
public String getCurrentAction(WebSession s) {
return "an action";
}
public String getSubmitMethod() { return "GET";}
public void restartLesson() {
}
public void setCurrentAction(WebSession s, String lessonScreen) {
Expand All @@ -56,6 +58,7 @@ public void testLinks() {
String srvLink = lesson.getServletLink();
assertThat(srvLink, CoreMatchers.startsWith("attack?Screen="));
assertThat(srvLink, CoreMatchers.endsWith("&menu=900"));
assertEquals(lesson.getSubmitMethod(),"GET");
}
}

Expand Down

0 comments on commit 8d87830

Please sign in to comment.