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 11, 2024
1 parent 5b741bc commit 9ad2863
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/kbs-docker-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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: Build client
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path kbs/tools/client/Cargo.toml --no-default-features --features sample_only --release

- 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/release/
run: echo "$TEST_SECRET_CONTENT" > "$TEST_SECRET_FILENAME"

- name: Check Test Resource
working-directory: target/release/
run: cat "$TEST_SECRET_FILENAME"

- name: Check command
working-directory: target/release/
run: ./kbs-client -h

- name: Check Key
working-directory: target/release/
run: ls -l ../../kbs/config/

- name: Set Resource
working-directory: target/release/
run: |
ls -l
echo "$PWD"
cat /home/runner/work/kbs/target/release/test-secret
./kbs-client --url http://127.0.0.1:8080 config --auth-private-key ../../kbs/config/private.key set-resource --path blah/blah/blah --resource-file /home/runner/work/kbs/target/release/test-secret
- name: Get Resource (negative)
working-directory: target/release/
run: ./kbs-client --url http://127.0.0.1:8080 get-resource --path "$TEST_SECRET_PATH"

- name: Update policy
working-directory: target/release/
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/release/
run: ./kbs-client --url http://127.0.0.1:8080 get-resource --path "$TEST_SECRET_PATH"

0 comments on commit 9ad2863

Please sign in to comment.