Skip to content

Commit

Permalink
tests: add e2e test with docker compose
Browse files Browse the repository at this point in the history
Includes a negative test to make sure that policy
validation does something.

Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
  • Loading branch information
fitzthum committed Jan 10, 2024
1 parent ad41bd2 commit 2a11b50
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/kbs-docker-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: KBS End-to-End test with Docker Compose and Sample Attester

on:
pull_request:
branches:
- main

env:
TEST_SECRET_CONTENT: shhhhh
TEST_SECRET_PATH: test-org/test-repo/test-secret
TEST_SECRET_FILENAME: test-secret

jobs:
e2e-test:
runs-on: ubuntu-latest
steps:
- name: Checkout KBS
uses: actions/checkout@v4

- name: Install Rust (for client)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Install TPM dependencies (for client)
run: |
sudo apt-get update && sudo apt-get install -y libtss2-dev
- name: Build client
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path kbs/tools/client/Cargo.toml

- name: Setup Keys
run: |
openssl genpkey -algorithm ed25519 > kbs/config/private.key
openssl pkey -in kbs/config/private.key -pubout -out kbs/config/public.pub
- name: Build KBS Cluster
run: docker compose build

- name: Start KBS cluster
run: docker compose up -d

- name: Create Test Resource
working-directory: target/debug/
run: echo "$TEST_SECRET_CONTENT" > "$TEST_SECRET_FILENAME"

- name: Set Resource
working-directory: target/debug/
run: ./kbs-client --url http://127.0.0.1:8080 config --auth-private-key ../../kbs/config/private.key  set-resource --path $TEST_SECRET_PATH --resource-file $TEST_SECRET_FILENAME

- name: Get Resource (negative)
working-directory: target/debug/
run: ./kbs-client --url http://127.0.0.1:8080 get-resource --path $TEST_SECRET_PATH
if: ${{ failure() }}

- name: Update policy
run: ./kbs-client --url http://127.0.0.1:8080 config --auth-private-key ../../kbs/config/private.key set-resource-policy --policy-file $policy_path
env:
policy_path: ../../kbs/test/data/policy_2.rego

- name: Get Resource
working-directory: target/debug/
run: ./kbs-client --url http://127.0.0.1:8080 get-resource --path $TEST_SECRET_PATH

0 comments on commit 2a11b50

Please sign in to comment.