Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add redirect test workflow / github action #3786

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/redirect_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: redirect_tests
on:
workflow_dispatch:
inputs:
search_path:
description: "Subpath to test, e.g. '/osw' (empty = all subpaths)"
default: '/*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v1

- name: Run apache docker
run: docker run -dit --name apache -e SEARCH_PATH=${{ github.event.inputs.search_path }} -v "$PWD":/usr/local/apache2/htdocs/ -v "$PWD"/.test/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf httpd:2.4

- name: Install curl
run: docker exec -i apache sh -c "apt-get update && apt-get install curl"

- name: Run tests
run: docker exec -i apache bash < .test/test.sh
32 changes: 32 additions & 0 deletions .test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Redirect test

Tests running directly on the source .htaccess files. It does only test the redirect, not the existance of the resource redirected to.
This is done by mounting the w3id.org repo in an apache docker and test the redirects with curl.

Test specifications are currently extracted from .htaccess file comments, e. g.
simontaurus marked this conversation as resolved.
Show resolved Hide resolved
```
##TESTv1 '/mypath --header "Accept: text/html"' "https://my-target-domain.com/test.html"
```

## Run the test as Github Action
1. Navigate to `https://github.com/<your fork>/w3id.org/actions/workflows/redirect_tests.yml` (example see [here](https://github.com/OpenSemanticWorld/w3id.org/actions/workflows/redirect_tests.yml))
1. Select 'Run workflow'
1. Keep the master branch or select your custom branch
1. Change the subpath to your subpath, e.g. `/mypath`
simontaurus marked this conversation as resolved.
Show resolved Hide resolved
1. Click 'Run workflow'
1. After completion, click on the run entry to view details (example see [here](https://github.com/OpenSemanticWorld/w3id.org/actions/runs/7224639650/job/19686349546))

## Run the test locally
Note: replace `/*` with your own trusted subpath, e.g. `/mypath`, otherwise all subpaths are tested which may create security issues
```bash
docker stop apache && docker rm apache
docker run -dit --name apache -e SEARCH_PATH='/*' -v "$PWD":/usr/local/apache2/htdocs/ -v "$PWD"/.test/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf httpd:2.4
docker exec -i apache sh -c "apt-get update && apt-get install curl"
docker exec -i apache bash < .test/test.sh
```

## Run a singe test
```bash
docker exec -i apache sh -c 'curl -sL -o /dev/null -w "%{url_effective}\n" --resolve www.w3id.org:80:127.0.0.1 www.w3id.org:80/subpath --header "Accept: application/rdf+xml"'
```

Loading