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

Integration tests (#5) #15

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5411a18
Error handling when OpenID Body is empty
antonengelhardt Nov 5, 2023
5ded415
Set up Integration Tests
antonengelhardt Nov 5, 2023
2ca5864
Apk instead of Apt
antonengelhardt Nov 5, 2023
4c0bb68
Install Chromedriver from apk
antonengelhardt Nov 5, 2023
348c1e9
Install pip
antonengelhardt Nov 5, 2023
7781d2f
Apk for Python
antonengelhardt Nov 5, 2023
0ec7ba1
Pip using APK
antonengelhardt Nov 5, 2023
6ced23a
Install Docker and Docker-Compose
antonengelhardt Nov 5, 2023
692caf2
Own Envoy.yaml
antonengelhardt Nov 5, 2023
f2c43c8
Modify sed command
antonengelhardt Nov 5, 2023
eaf6845
Debug
antonengelhardt Nov 5, 2023
5130140
Quotes for Sed
antonengelhardt Nov 5, 2023
f3eedf7
Debug with ls
antonengelhardt Nov 5, 2023
a5597bf
Add exclude paths and urls for OIDC plugin, update
antonengelhardt Nov 12, 2023
16ec7fb
Try with services
antonengelhardt Nov 16, 2023
830f7e6
Change image
antonengelhardt Nov 16, 2023
050e003
Mount
antonengelhardt Nov 16, 2023
4912717
WIP
antonengelhardt Nov 17, 2023
f7400bd
Update test.yml and Dockerfile for integration tests
antonengelhardt Feb 21, 2024
47af27e
Remove Networks
antonengelhardt Feb 21, 2024
0321190
Get AES Key from Secret
antonengelhardt Feb 21, 2024
0b1312c
Add curl test and get envoy container gateway
antonengelhardt Feb 21, 2024
31689ec
Without curl
antonengelhardt Feb 21, 2024
bfe9ab2
Yay
antonengelhardt Feb 21, 2024
eb160a8
Add environment variables for integration tests
antonengelhardt Feb 21, 2024
8a8c407
Update instructions for running integration tests
antonengelhardt Feb 21, 2024
f01e330
Add sleep to test_success function
antonengelhardt Feb 21, 2024
c2894b5
Update test.yml and remove Dockerfile for integration tests
antonengelhardt Feb 21, 2024
fccc376
Update Docker image references
antonengelhardt Feb 21, 2024
526eec4
Update Readme and sleep even longer
antonengelhardt Feb 21, 2024
de9977a
Commented out sensitive environment variables in test.yml
antonengelhardt Feb 21, 2024
919fd65
Is the cookie there?
antonengelhardt Feb 21, 2024
5ea26ec
Fix integration test configuration
antonengelhardt Feb 21, 2024
7c6fd46
Update python-dotenv version in requirements.txt
antonengelhardt Feb 21, 2024
71f72e5
Show public httpbin.org for integration tests
antonengelhardt Feb 22, 2024
b2dac66
Debug Logs at the end of job
antonengelhardt Feb 22, 2024
c4944c2
Log Level
antonengelhardt Feb 22, 2024
9d4335b
Add integration tests and fix test cases
antonengelhardt Feb 22, 2024
1fe2324
Update dependencies and fix method calls in integration tests
antonengelhardt Feb 22, 2024
093fb72
Change test.py
antonengelhardt Feb 22, 2024
6b78a5a
ci: separate jobs for testing to tell errors more detailed
antonengelhardt Mar 28, 2024
2eb47ed
caching, new client, build workflow refactored
antonengelhardt Mar 30, 2024
fcc404b
change title in test cases
antonengelhardt Mar 30, 2024
f49d119
check for cookie
antonengelhardt Mar 30, 2024
e3b43d5
check nonce
antonengelhardt Mar 30, 2024
6243096
debug
antonengelhardt Mar 30, 2024
bf5d9e6
curl localhost
antonengelhardt Mar 30, 2024
4672129
ports 10000
antonengelhardt Mar 30, 2024
275fb03
port 10001
antonengelhardt Mar 30, 2024
dda94ee
dom
antonengelhardt Mar 30, 2024
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
107 changes: 92 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,126 @@ env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
cargo-deny:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Rust version
run: rustc --version && cargo --version

- name: Cargo Deny
uses: EmbarkStudios/cargo-deny-action@v1

clippy:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rust version
run: rustc --version && cargo --version

- name: Clippy
run: cargo clippy --release --all-targets --target=wasm32-wasi
run: |
rustc --version && cargo --version
cargo clippy

fmt:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rust version
run: rustc --version && cargo --version

- name: Fmt
run: cargo fmt -- --check

test:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rust version
run: rustc --version && cargo --version

- name: Test
run: cargo test --workspace

- name: Build
run: cargo build --release --target wasm32-wasi

build:
name: Build Plugin and publish artifact
needs: test
needs: [cargo-deny, clippy, fmt, test]
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
image: ghcr.io/antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Build
run: |
cargo build --target wasm32-wasi --release
Expand All @@ -64,7 +141,7 @@ jobs:

docker-image:
name: Build and push Docker image
needs: test
needs: [build, test]
runs-on: ubuntu-latest

steps:
Expand All @@ -87,7 +164,7 @@ jobs:
ghcr-image:
name: Build and push GHCR image
runs-on: ubuntu-latest
needs: test
needs: [build, test, docker-image]
permissions:
contents: read
packages: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Build and upload artifacts
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
image: ghcr.io/antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
184 changes: 173 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,197 @@ on:
pull_request:

jobs:
test:
name: Test
cargo-deny:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Rust version
run: rustc --version && cargo --version

- name: Cargo Deny
uses: EmbarkStudios/cargo-deny-action@v1

clippy:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rust version
run: rustc --version && cargo --version

- name: Clippy
run: cargo clippy --release --all-targets --target=wasm32-wasi
run: |
rustc --version && cargo --version
cargo clippy

fmt:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rust version
run: rustc --version && cargo --version

- name: Fmt
run: cargo fmt -- --check

test:
runs-on: ubuntu-latest
container:
image: antonengelhardt/rust-docker-tools
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rust version
run: rustc --version && cargo --version

- name: Test
run: cargo test --workspace

- name: Build
run: cargo build --release --target wasm32-wasi
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/antonengelhardt/rust-docker-tools
# needs: [test]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Build WASM OIDC Plugin
run: |
cargo build --target wasm32-wasi --release

- name: Upload plugin as artifact
uses: actions/upload-artifact@v2
with:
name: plugin
path: target/wasm32-wasi/release/wasm_oidc_plugin.wasm

integration-tests:
runs-on: ubuntu-latest
container:
image: ghcr.io/antonengelhardt/rust-docker-tools
ports:
- 10000
needs: [build]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download plugin from build job
uses: actions/download-artifact@v2
with:
name: plugin
path: target/wasm32-wasi/release/wasm_oidc_plugin.wasm

- name: Install apks
run: |
apk update
apk add chromium chromium-chromedriver python3 py3-pip curl docker

- name: Install Python dependencies
run: pip install -r integration-tests/requirements.txt --break-system-packages

- name: Create .env for Integration tests
run: |
echo "CI=true" >> integration-tests/.env
echo "WASM_OIDC_PLUGIN_TEST_EMAIL=${{ secrets.WASM_OIDC_PLUGIN_TEST_EMAIL }}" >> integration-tests/.env
echo "WASM_OIDC_PLUGIN_TEST_PASSWORD=${{ secrets.WASM_OIDC_PLUGIN_TEST_PASSWORD }}" >> integration-tests/.env
sed -i 's/client_secret: \"redacted\"/client_secret: \"${{ secrets.WASM_OIDC_PLUGIN_TEST_CLIENT_SECRET }}\"/g' integration-tests/envoy.yaml
sed -i 's/aes_key: \"redacted\"/aes_key: \"${{ secrets.WASM_OIDC_PLUGIN_TEST_AES_KEY }}\"/g' integration-tests/envoy.yaml

- name: Start Containers & Run Integration tests
run: |
cd integration-tests

echo "Creating Envoy container"
docker container create --name envoy -p 10000:10000 docker.io/envoyproxy/envoy:v1.29-latest envoy -c /etc/envoy/envoy.yaml --concurrency 1 --component-log-level wasm:debug

echo "Copying files to Envoy container because Alpine doesn't like mounting files to files"
docker cp ../target/wasm32-wasi/release/wasm_oidc_plugin.wasm envoy:/etc/envoy/proxy-wasm-plugins
docker cp envoy.yaml envoy:/etc/envoy/envoy.yaml

echo "Starting Envoy container"
docker start envoy

sleep 5
docker ps
docker logs envoy

# Get the gateway of the envoy container
export GATEWAY=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' envoy)

echo "Running Integration Tests"
export WASM_OIDC_PLUGIN_TEST_EMAIL=${{ secrets.WASM_OIDC_PLUGIN_TEST_EMAIL }}
export WASM_OIDC_PLUGIN_TEST_PASSWORD=${{ secrets.WASM_OIDC_PLUGIN_TEST_PASSWORD }}
pytest test.py

- name: Finally show the envoy logs in case something failed
run: |
docker logs envoy
if: always()
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ simulate:
docker-compose up
clean:
docker-compose rm --force
integration-test:
cargo build --target wasm32-wasi --release
docker-compose -f integration-tests/docker-compose.yaml up -d
pytest integration-tests/test.py
docker-compose -f integration-tests/docker-compose.yaml down
5 changes: 5 additions & 0 deletions demo/configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ metadata:
namespace: wasm-oidc-plugin
data:
envoy.yaml: |
admin:
address:
socket_address:
address: 0.0.0.0
port_value: 9901
Comment on lines +10 to +14
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
admin:
address:
socket_address:
address: 0.0.0.0
port_value: 9901

static_resources:
listeners:
address:
Expand Down
Loading
Loading