Skip to content

Commit

Permalink
Merge pull request #1168 from OWASP/feature-e2e-precommit
Browse files Browse the repository at this point in the history
Fix cypress related docs
  • Loading branch information
commjoen authored Dec 24, 2023
2 parents c6655f6 + 493c6f1 commit 2fec114
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
53 changes: 22 additions & 31 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,6 @@ permissions:
contents: read
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
name: test with java
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
- name: Test with Maven
run: ./mvnw --no-transfer-progress test
ui-test:
name: UI test with Cypress
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
lint:
name: lint javacode
runs-on: ubuntu-latest
Expand All @@ -73,3 +42,25 @@ jobs:
distribution: "corretto"
- name: spotbugs with Maven
run: ./mvnw --no-transfer-progress package -DskipTests spotbugs:check
test:
name: test with java
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
- name: Test with Maven
run: ./mvnw --no-transfer-progress test
- name: Publish Test Report
if: success() || failure()
uses: scacap/action-surefire-report@v1
- uses: actions/upload-artifact@v4
with:
name: e2e results
path: target/test-classes/e2e/cypress/reports/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
exclude: ^(src/test/resources/yourkey.txt|src/test/resources/secondkey.txt)
- id: trailing-whitespace
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.83.6
rev: v1.86.0
hooks:
- id: terraform_fmt
- id: terraform_tflint
Expand Down Expand Up @@ -47,7 +47,7 @@ repos:
args: [ 'clean compile' ]
- id: maven-spotless-apply
- repo: https://github.com/eslint/eslint
rev: v8.55.0
rev: v8.56.0
hooks:
- id: eslint
args:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Want to play the other challenges? Read the instructions on how to set them up b
- [Automatic reload during development](#automatic-reload-during-development)
- [How to add a Challenge](#how-to-add-a-challenge)
- [Local testing](#local-testing)
- [Local Automated testing](#Local-automated-testing)
- [Want to play, but are not allowed to install the tools?](#want-to-play-but-are-not-allowed-to-install-the-tools)
- [Further reading on secrets management](#further-reading-on-secrets-management)

Expand Down Expand Up @@ -500,6 +501,14 @@ If you have made some changes to the codebase or added a new challenge and would
- to run it on your minikube: use the container `jeroenwillemsen/wrongsecrets:local-test-k8s-vault` in your deployment definition.
- to run it with Vault on your minikube: use the container `jeroenwillemsen/wrongsecrets:local-test-local-vault` in your deployment definition.

### Local Automated testing

We currently have 2 different test-suites, both fired with `./mvnw test`.
- A normal junit test suite of unit and integration tests, located at the [`test/java` folder](src/test/java) with output stored at the default target directory.
- A cypress test suite, integrated by means of a junit test, located at [`test/e2e` folder](src/test/e2e) with output stored at [`target/test-classes/e2e/cypress/reports/`](target/test-classes/e2e/cypress/reports/). See the [cypress readme](src/test/e2e/cypress/README.md) for more details.

Note: You can do a full roundtrip of cleaning, building, and testing with `./mvnw clean install`.

## Want to play, but are not allowed to install the tools?

If you want to play the challenges, but cannot install tools like keepass, Radare, etc. But are allowed to run Docker containers, try the following:
Expand Down
4 changes: 4 additions & 0 deletions src/test/e2e/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Go to `CypressIntegrationTest` and run it as a normal unit test in IntelliJ. Thi
a `SpringBootTest` which uses Testcontainers to start running the Cypress tests.
The test then gathers all the output from the Cypress tests and displays them as normal unit test output in IntelliJ.

The reporting of the tests themselves will be located in `target/test-classes/e2e/cypress/reports`.

Please note that cypress requires the templates to have been build first.

## How to interact with elements

- To select an element in the UI, add a `data-cy` attribute to the HTML element and give it a unique value.
Expand Down

0 comments on commit 2fec114

Please sign in to comment.