Initial push of testing work

This commit is contained in:
Doug Morato 2015-08-22 13:39:42 -04:00
parent cc9ae0a6a9
commit 2212bd0805
2 changed files with 157 additions and 2 deletions

View File

@ -96,10 +96,10 @@
<plugin> <plugin>
<groupId>org.apache.tomcat.maven</groupId> <groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId> <artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version> <version>2.2</version>
<configuration> <configuration>
<server>local_tomcat</server> <server>local_tomcat</server>
<url>http://localhost:8080/manager/text</url> <url>http://localhost:8080/manager</url>
<path>/WebGoat</path> <path>/WebGoat</path>
<attachArtifactClassifier>exec</attachArtifactClassifier> <attachArtifactClassifier>exec</attachArtifactClassifier>
<contextReloadable>true</contextReloadable> <contextReloadable>true</contextReloadable>
@ -135,6 +135,98 @@
</extraDependencies> </extraDependencies>
</configuration> </configuration>
</execution> </execution>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war-only</goal>
</goals>
<configuration>
<port>8080</port>
<fork>true</fork>
<extraDependencies>
<extraDependency>
<groupId>org.owasp.webgoat</groupId>
<artifactId>webgoat-classloader</artifactId>
<version>${project.version}</version>
</extraDependency>
</extraDependencies>
</configuration>
</execution>
<!-- At post-integration-test phase, stop the embedded Tomcat server. -->
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
<!--<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.9.7</version>
</configuration>
</plugin>
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>2.0-beta-02</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
<webDriverCapabilities>
<phantomjs.binary.path>${phantomjs.binary}</phantomjs.binary.path>
</webDriverCapabilities>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<systemPropertyVariables>
<phantomjs.binary>${phantomjs.binary}</phantomjs.binary>
</systemPropertyVariables>
</configuration>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
@ -388,6 +480,16 @@
<version>1.7.7</version> <version>1.7.7</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.6</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>
</dependencies> </dependencies>

View File

@ -0,0 +1,53 @@
package org.owasp.webgoat.plugins;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import org.junit.experimental.categories.Category;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
/**
* Created by dm on 8/21/15.
*/
public class WebGoatIT {
/*@Test
public void shouldHavePhantomJsBinary() {
String binary = System.getProperty("phantomjs.binary");
assertNotNull(binary);
assertTrue(new File(binary).exists());
}*/
@Test
public void testTomcatDeployment() {
WebDriver driver = new FirefoxDriver();
driver.get("http://localhost:8080/WebGoat");
WebElement usernameElement = driver.findElement(By.name("username"));
WebElement passwordElement = driver.findElement(By.name("password"));
assertNotNull(usernameElement);
assertNotNull(passwordElement);
}
@Test
public void testLogin() {
WebDriver driver = new FirefoxDriver();
driver.get("http://localhost:8080/WebGoat");
WebElement usernameElement = driver.findElement(By.name("username"));
WebElement passwordElement = driver.findElement(By.name("password"));
assertNotNull(usernameElement);
assertNotNull(passwordElement);
usernameElement.sendKeys("webgoat");
passwordElement.sendKeys("webgoat");
passwordElement.submit();
WebElement cookieParameters = driver.findElement(By.id("cookies-and-params"));
assertNotNull(cookieParameters);
}
}