Skip to content

Commit

Permalink
change new vault to use vault command and update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Esgrove committed Oct 30, 2024
1 parent c26b012 commit 4f54152
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 63 deletions.
141 changes: 79 additions & 62 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,10 @@ jobs:
run: python -m pip install .
working-directory: python

- name: Install Python PyO3 vault
run: python -m pip install .
working-directory: python-pyo3

- name: Add execute rights and run --version for all versions
run: |
chmod +x bin/go/vault bin/rust/vault nodejs/dist/cli/vault.js
vault --version
pvault --version
bin/go/vault --version
bin/rust/vault --version
nodejs/dist/cli/vault.js --version
Expand All @@ -119,10 +114,6 @@ jobs:
vault --help
echo "------------------------------------------------------------------------------"
echo "============================ Python-pyo3 Vault CLI ==========================="
pvault --help
echo "------------------------------------------------------------------------------"
echo "================================= Go Vault CLI ==============================="
bin/go/vault --help
echo "------------------------------------------------------------------------------"
Expand All @@ -137,9 +128,6 @@ jobs:
- name: Store secret with Python
run: vault -s 'secret-python' -v 'sha-${{github.sha}}' -w

- name: Store secret with Python-pyo3
run: pvault store 'secret-python-pyo3' -v 'sha-${{github.sha}}' -w

- name: Store secret with Go
run: bin/go/vault -s 'secret-go' -v 'sha-${{github.sha}}' -w

Expand All @@ -152,21 +140,12 @@ jobs:
- name: Validate storing worked Python
run: diff <(vault -l secret-python) <(echo -n sha-${{github.sha}})

- name: Validate storing worked Python-pyo3
run: diff <(pvault lookup secret-python-pyo3) <(echo -n sha-${{github.sha}})

- name: Validate Go and Rust secret equality with Python
run: diff <(vault -l secret-go) <(vault -l secret-rust)

- name: Validate Go and Rust secret equality with Python-pyo3
run: diff <(pvault lookup secret-go) <(pvault lookup secret-rust)

- name: Validate Python secret equality with Rust and Go
run: diff <(bin/rust/vault -l secret-python) <(bin/go/vault -l secret-python)

- name: Validate Python-pyo3 secret equality with Rust and Go
run: diff <(bin/rust/vault -l secret-python-pyo3) <(bin/go/vault -l secret-python-pyo3)

- name: Validate Rust and Python secret equality with Go and Nodejs
run: diff <(bin/go/vault -l secret-rust) <(nodejs/dist/cli/vault.js lookup secret-python)

Expand All @@ -179,15 +158,9 @@ jobs:
- name: Validate Rust and Go secret equality with Nodejs and Go
run: diff <(bin/rust/vault -l secret-rust) <(nodejs/dist/cli/vault.js lookup secret-nodejs)

- name: Validate Python and Python-pyo3 secret equality with Nodejs
run: diff <(nodejs/dist/cli/vault.js lookup secret-python) <(bin/go/vault -l secret-python-pyo3)

- name: Delete secret with Python
run: vault -d 'secret-python'

- name: Delete secret with Python-pyo3
run: pvault delete 'secret-python-pyo3'

- name: Delete secret with Go
run: bin/go/vault -d 'secret-go'

Expand All @@ -200,19 +173,10 @@ jobs:
- name: Verify that keys have been deleted using Rust
run: |
bin/rust/vault exists secret-python | grep -q "key 'secret-python' does not exist"
bin/rust/vault exists secret-python-pyo3 | grep -q "key 'secret-python-pyo3' does not exist"
bin/rust/vault exists secret-go | grep -q "key 'secret-go' does not exist"
bin/rust/vault exists secret-rust | grep -q "key 'secret-rust' does not exist"
bin/rust/vault exists secret-nodejs | grep -q "key 'secret-nodejs' does not exist"
- name: Verify that keys have been deleted using Python-pyo3
run: |
pvault exists secret-python | grep -q "key 'secret-python' does not exist"
pvault exists secret-python-pyo3 | grep -q "key 'secret-python-pyo3' does not exist"
pvault exists secret-go | grep -q "key 'secret-go' does not exist"
pvault exists secret-rust | grep -q "key 'secret-rust' does not exist"
pvault exists secret-nodejs | grep -q "key 'secret-nodejs' does not exist"
- name: Create dummy text file
run: echo "Vault test ${{ github.sha }} ${{ github.ref_name }}" > test.txt

Expand All @@ -237,27 +201,6 @@ jobs:
- name: Verify that key has been deleted with Rust
run: bin/rust/vault exists secret-${{github.sha}}.zip | grep -q "does not exist"

- name: Store zip file using Python-pyo3
run: pvault store --file "secret-${{github.sha}}.zip"

- name: Lookup the stored zip file and write to output
run: pvault lookup "secret-${{github.sha}}.zip" > output-python-pyo3.zip

- name: Extract the retrieved zip file
run: unzip output-python-pyo3.zip -d extracted-python-pyo3

- name: Verify the extracted file content
run: diff extracted-python-pyo3/test.txt test.txt

- name: Delete secret with Python-pyo3
run: pvault delete "secret-${{github.sha}}.zip"

- name: Verify that key has been deleted with Rust
run: bin/rust/vault exists secret-${{github.sha}}.zip | grep -q "does not exist"

- name: Verify that key has been deleted with Python-pyo3
run: pvault exists secret-${{github.sha}}.zip | grep -q "does not exist"

- name: Store zip file using Rust vault
run: bin/rust/vault --store --file "secret-${{github.sha}}.zip"

Expand All @@ -284,10 +227,84 @@ jobs:
bin/rust/vault exists secret-rust | grep -q "key 'secret-rust' does not exist"
bin/rust/vault exists secret-nodejs | grep -q "key 'secret-nodejs' does not exist"
- name: Install Python PyO3 vault
run: python -m pip install .
working-directory: python-pyo3

- name: Check version
run: vault --version

- name: Check help output
run: |
echo "============================ Python-pyo3 Vault CLI ==========================="
vault --help
echo "------------------------------------------------------------------------------"
echo "================================ Rust Vault CLI =============================="
bin/rust/vault -h
echo "------------------------------------------------------------------------------"
- name: Store secret with Python-pyo3
run: vault -s 'secret-python-pyo3' -v 'sha-${{github.sha}}' -w

- name: Validate storing worked Python-pyo3
run: diff <(vault -l secret-python-pyo3) <(echo -n sha-${{github.sha}})

- name: Store secret with Go
run: bin/go/vault -s 'secret-go' -v 'sha-${{github.sha}}' -w

- name: Store secret with Rust
run: bin/rust/vault -s 'secret-rust' -v 'sha-${{github.sha}}' -w

- name: Store secret with Nodejs
run: nodejs/dist/cli/vault.js s 'secret-nodejs' 'sha-${{github.sha}}' -w

- name: Validate Go and Rust secret equality with Python-pyo3
run: diff <(vault -l secret-go) <(vault -l secret-rust)

- name: Validate Python-pyo3 secret equality with Rust and Go
run: diff <(bin/rust/vault -l secret-python-pyo3) <(bin/go/vault -l secret-python-pyo3)

- name: Validate Nodejs and Python-pyo3 secret equality with Nodejs
run: diff <(nodejs/dist/cli/vault.js l secret-nodejs) <(vault -l secret-python-pyo3)

- name: Delete secret with Python-pyo3
run: vault -d 'secret-python-pyo3'

- name: Delete secret with Python-pyo3
run: vault -d 'secret-python-rust'

- name: Delete secret with Python-pyo3
run: vault -d 'secret-python-go'

- name: Delete secret with Python-pyo3
run: vault -d 'secret-python-nodejs'

- name: Verify that keys have been deleted using Python-pyo3
run: |
pvault exists secret-python | grep -q "key 'secret-python' does not exist"
pvault exists secret-python-pyo3 | grep -q "key 'secret-python-pyo3' does not exist"
pvault exists secret-go | grep -q "key 'secret-go' does not exist"
pvault exists secret-rust | grep -q "key 'secret-rust' does not exist"
pvault exists secret-nodejs | grep -q "key 'secret-nodejs' does not exist"
vault exists secret-python | grep -q "key 'secret-python' does not exist"
vault exists secret-python-pyo3 | grep -q "key 'secret-python-pyo3' does not exist"
vault exists secret-go | grep -q "key 'secret-go' does not exist"
vault exists secret-rust | grep -q "key 'secret-rust' does not exist"
vault exists secret-nodejs | grep -q "key 'secret-nodejs' does not exist"
- name: Store zip file using Python-pyo3
run: vault store --file "secret-${{github.sha}}.zip"

- name: Lookup the stored zip file and write to output
run: vault lookup "secret-${{github.sha}}.zip" > output-python-pyo3.zip

- name: Extract the retrieved zip file
run: unzip output-python-pyo3.zip -d extracted-python-pyo3

- name: Verify the extracted file content
run: diff extracted-python-pyo3/test.txt test.txt

- name: Delete secret with Python-pyo3
run: vault delete "secret-${{github.sha}}.zip"

- name: Verify that key has been deleted with Rust
run: bin/rust/vault exists secret-${{github.sha}}.zip | grep -q "does not exist"

- name: Verify that key has been deleted with Python-pyo3
run: vault exists secret-${{github.sha}}.zip | grep -q "does not exist"
2 changes: 1 addition & 1 deletion python-pyo3/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dev = ["ruff"]
Repository = "https://github.com/NitorCreations/vault"

[project.scripts]
pvault = "p_vault.vault:main"
vault = "p_vault.vault:main"

[build-system]
requires = ["maturin>=1.7,<2.0"]
Expand Down

0 comments on commit 4f54152

Please sign in to comment.