Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added Robot framework UI tests * added Robot framework UI tests workflow * Update test.yml wait in workflow * remove obsolete selenium java libs and test * Update test.yml push result to commit as comment * Update test.yml push comment does not seem to work on WebGoat PR * clean up unrequired robot options * update readme
- Loading branch information
Showing
5 changed files
with
185 additions
and
121 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: "UI-Test" | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
- '.txt' | ||
- '*.MD' | ||
- '*.md' | ||
- 'LICENSE' | ||
- 'docs/**' | ||
push: | ||
tags-ignore: | ||
- '*' | ||
paths-ignore: | ||
- '.txt' | ||
- '*.MD' | ||
- '*.md' | ||
- 'LICENSE' | ||
- 'docs/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
# display name of the job | ||
name: "Robot framework test" | ||
steps: | ||
# Uses an default action to checkout the code | ||
- uses: actions/checkout@v3 | ||
# Uses an action to add Python to the VM | ||
- name: Setup Pyton | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.7' | ||
architecture: x64 | ||
# Uses an action to add JDK 17 to the VM (and mvn?) | ||
- name: set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
architecture: x64 | ||
#Uses an action to set up a cache using a certain key based on the hash of the dependencies | ||
- name: Cache Maven packages | ||
uses: actions/cache@v3.0.5 | ||
with: | ||
path: ~/.m2 | ||
key: ubuntu-latest-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ubuntu-latest-m2- | ||
- uses: BSFishy/pip-action@v1 | ||
with: | ||
packages: | | ||
robotframework | ||
robotframework-SeleniumLibrary | ||
webdriver-manager | ||
- name: Run with Maven | ||
run: mvn --no-transfer-progress spring-boot:run & | ||
- name: Wait to start | ||
uses: ifaxity/wait-on-action@v1 | ||
with: | ||
resource: http://127.0.0.1:8080/WebGoat | ||
- name: Test with Robotframework | ||
run: python3 -m robot --variable HEADLESS:"1" --outputdir robotreport robot/goat.robot | ||
#- name: Send report to commit | ||
# uses: joonvena/robotframework-reporter-action@v2.1 | ||
# with: | ||
# gh_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
# report_path: 'robotreport' |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Install and use Robotframework | ||
|
||
## Install Chromedriver on Mac OS | ||
|
||
brew install cask chromedriver | ||
chromedriver --version | ||
|
||
Then see security settings and allow the file to run | ||
|
||
## Install | ||
|
||
pip3 install virtualenv --user | ||
python3 -m virtualenv .venv | ||
source .venv/bin/activate | ||
pip install robotframework | ||
pip install robotframework-SeleniumLibrary | ||
pip install webdriver-manager | ||
robot --variable HEADLESS:"0" --variable ENDPOINT:"http://127.0.0.1:8080/WebGoat" goat.robot |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
*** Settings *** | ||
Documentation Setup WebGoat Robotframework tests | ||
Library SeleniumLibrary timeout=100 run_on_failure=Capture Page Screenshot | ||
Library String | ||
|
||
Suite Setup Initial_Page ${ENDPOINT} ${BROWSER} | ||
Suite Teardown Close_Page | ||
|
||
*** Variables *** | ||
${BROWSER} chrome | ||
${SLEEP} 100 | ||
${DELAY} 0.25 | ||
${ENDPOINT} http://127.0.0.1:8080/WebGoat | ||
${ENDPOINT_WOLF} http://127.0.0.1:9090 | ||
${USERNAME} robotuser | ||
${PASSWORD} password | ||
${HEADLESS} ${FALSE} | ||
|
||
*** Keywords *** | ||
Initial_Page | ||
[Documentation] Check the inital page | ||
[Arguments] ${ENDPOINT} ${BROWSER} | ||
Log To Console Start WebGoat UI Testing | ||
IF ${HEADLESS} | ||
Open Browser ${ENDPOINT} ${BROWSER} options=add_argument("-headless");add_argument("--start-maximized");add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'}) alias=webgoat | ||
ELSE | ||
Open Browser ${ENDPOINT} ${BROWSER} options=add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'}) alias=webgoat | ||
END | ||
IF ${HEADLESS} | ||
Open Browser ${ENDPOINT_WOLF}/WebWolf ${BROWSER} options=add_argument("-headless");add_argument("--start-maximized");add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'}) alias=webwolf | ||
ELSE | ||
Open Browser ${ENDPOINT_WOLF}/WebWolf ${BROWSER} options=add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'}) alias=webwolf | ||
END | ||
Switch Browser webgoat | ||
Maximize Browser Window | ||
Set Window Size ${1400} ${1000} | ||
Switch Browser webwolf | ||
Maximize Browser Window | ||
Set Window Size ${1400} ${1000} | ||
Set Window Position ${400} ${200} | ||
Set Selenium Speed ${DELAY} | ||
|
||
Close_Page | ||
[Documentation] Closing the browser | ||
Log To Console ==> Stop WebGoat UI Testing | ||
IF ${HEADLESS} | ||
Switch Browser webgoat | ||
Close Browser | ||
Switch Browser webwolf | ||
Close Browser | ||
END | ||
|
||
*** Test Cases *** | ||
|
||
Check_Initial_Page | ||
Switch Browser webgoat | ||
Page Should Contain Username | ||
Click Button Sign in | ||
Page Should Contain Invalid username | ||
Click Link /WebGoat/registration | ||
|
||
Check_Registration_Page | ||
Page Should Contain Username | ||
Input Text username ${USERNAME} | ||
Input Text password ${PASSWORD} | ||
Input Text matchingPassword ${PASSWORD} | ||
Click Element agree | ||
Click Button Sign up | ||
|
||
Check_Welcome_Page | ||
Page Should Contain WebGoat | ||
Go To ${ENDPOINT}/login | ||
Page Should Contain Username | ||
Input Text username ${USERNAME} | ||
Input Text password ${PASSWORD} | ||
Click Button Sign in | ||
Page Should Contain WebGoat | ||
|
||
Check_Menu_Page | ||
Click Element css=a[category='Introduction'] | ||
Click Element Introduction-WebGoat | ||
CLick Element Introduction-WebWolf | ||
Click Element css=a[category='General'] | ||
CLick Element General-HTTPBasics | ||
Click Element xpath=//*[.='2'] | ||
Input Text person ${USERNAME} | ||
Click Button Go! | ||
${OUT_VALUE} Get Text xpath=//div[contains(@class, 'attack-feedback')] | ||
${OUT_RESULT} Evaluate "resutobor" in """${OUT_VALUE}""" | ||
IF not ${OUT_RESULT} | ||
Fail "not ok" | ||
END | ||
|
||
Check_WebWolf | ||
Switch Browser webwolf | ||
location should be ${ENDPOINT_WOLF}/WebWolf | ||
Go To ${ENDPOINT_WOLF}/mail | ||
Input Text username ${USERNAME} | ||
Input Text password ${PASSWORD} | ||
Click Button Sign In | ||
|
111 changes: 0 additions & 111 deletions
111
src/it/java/org/owasp/webgoat/SeleniumIntegrationTest.java
This file was deleted.
Oops, something went wrong.