diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7c124b15..9c48b2831 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aff0eec91..ba7c9517b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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: diff --git a/README.md b/README.md index f95405e58..8a2bacefb 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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: diff --git a/src/test/e2e/cypress/README.md b/src/test/e2e/cypress/README.md index d2c65a5e8..2bc3cd50e 100644 --- a/src/test/e2e/cypress/README.md +++ b/src/test/e2e/cypress/README.md @@ -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.