Created
March 13, 2017 09:28
-
-
Save streichsbaer/d1994672321af01bc1887012e931acd9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.continuumsecurity; | |
import net.continuumsecurity.Config; | |
import net.continuumsecurity.Credentials; | |
import net.continuumsecurity.UserPassCredentials; | |
import net.continuumsecurity.behaviour.ILogin; | |
import net.continuumsecurity.behaviour.ILogout; | |
import net.continuumsecurity.behaviour.INavigable; | |
import net.continuumsecurity.web.WebApplication; | |
import org.openqa.selenium.By; | |
public class WebGoatApplication extends WebApplication implements ILogin, | |
ILogout,INavigable { | |
public WebGoatApplication() { | |
super(); | |
} | |
@Override | |
public void openLoginPage() { | |
driver.get(Config.getInstance().getBaseUrl() + "login.mvc"); | |
findAndWaitForElement(By.id("exampleInputEmail1")); | |
} | |
@Override | |
public void login(Credentials credentials) { | |
UserPassCredentials creds = new UserPassCredentials(credentials); | |
driver.findElement(By.id("exampleInputEmail1")).clear(); | |
driver.findElement(By.id("exampleInputEmail1")).sendKeys(creds.getUsername()); | |
driver.findElement(By.id("exampleInputPassword1")).clear(); | |
driver.findElement(By.id("exampleInputPassword1")).sendKeys(creds.getPassword()); | |
driver.findElement(By.tagName("button")).click(); | |
} | |
@Override | |
public boolean isLoggedIn() { | |
driver.get(Config.getInstance().getBaseUrl()+"attack?Screen=1904549904&menu=2000"); | |
if (driver.getPageSource().contains("Results for: guest")) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
@Override | |
public void logout() { | |
driver.get(Config.getInstance().getBaseUrl()+"logout.mvc"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment