Skip to content

Commit

Permalink
test: call venom tests in github-action CI
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Henri Symoneaux <[email protected]>
  • Loading branch information
phsym committed Nov 19, 2024
1 parent 298e2f6 commit e1a9e96
Show file tree
Hide file tree
Showing 17 changed files with 314 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
name: build

on:
push:
branches: ["main"]
workflow_call: {}

jobs:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/main-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release

on:
push:
# run only against tags
branches:
- main

permissions:
contents: write
packages: write
# issues: write

jobs:
build:
uses: ./.github/workflows/build.yaml
secrets: inherit

integration-tests:
needs: build
uses: ./.github/workflows/test.yaml
secrets: inherit

5 changes: 5 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ jobs:
needs:
- commitlint
uses: ./.github/workflows/build.yaml
secrets: inherit

test:
needs: build
uses: ./.github/workflows/test.yaml
secrets: inherit
9 changes: 7 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ jobs:
build:
uses: ./.github/workflows/build.yaml
secrets: inherit

integration-tests:
needs: build
uses: ./.github/workflows/test.yaml
secrets: inherit

docker-build:
needs: build
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -37,7 +42,7 @@ jobs:
- run: KO_DOCKER_REPO=ghcr.io/ovh/okms-cli ko build --tags ${{ github.ref_name }},latest --push --bare --platform=linux/arm64,linux/amd64 ./cmd/okms

goreleaser:
needs: build
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: test

on:
workflow_call: {}


jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-build-env
- name: Build CLI
run: go build -cover ./cmd/okms
- name: Setup Venom
run: |
wget https://github.com/ovh/venom/releases/download/v1.2.0/venom.linux-amd64
mv venom.linux-amd64 venom
chmod +x venom
- name: Setup okms config file
run: |
echo "${{secrets.CERTIFICATE}}" > tls.crt
echo "${{secrets.PRIVATE_KEY}}" > tls.key
cat > okms.yaml <<-EOF
version: 1
profile: default
profiles:
default: # default profile
http:
endpoint: ${{secrets.KMS_HTTP_ENDPOINT}}
auth:
type: mtls
cert: $(pwd)/tls.crt
key: $(pwd)/tls.key
EOF
- name: Test connectivity to KMS dmain
run: ./okms keys ls -d -c okms.yaml
- name: Execute tests
run: make -C tests
- uses: actions/upload-artifact@v4
with:
name: test_results
path: |
./tests/out/test_results.html
./tests/out/venom.log
retention-days: 5
if: always()
- uses: actions/upload-artifact@v4
with:
name: coverage
path: |
./tests/out/coverage.txt
./tests/out/coverage.html
retention-days: 5

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# okms-cli
[![build](https://github.com/ovh/okms-cli/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/ovh/okms-cli/actions/workflows/build.yaml)
[![build](https://github.com/ovh/okms-cli/actions/workflows/main-branch.yaml/badge.svg?branch=main)](https://github.com/ovh/okms-cli/actions/workflows/main-branch.yaml)
[![license](https://img.shields.io/badge/license-Apache%202.0-red.svg?style=flat)](https://raw.githubusercontent.com/ovh/okms-sdk-go/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/ovh/okms-cli)](https://goreportcard.com/report/github.com/ovh/okms-cli)

The CLI to interact with your [OVHcloud KMS](https://help.ovhcloud.com/csm/en-ie-kms-quick-start?id=kb_article_view&sysparm_article=KB0063362) services.
Expand Down
6 changes: 6 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test:
rm -Rf out
../venom run --html-report --output-dir=out --var-from-file cfg/vars.yaml -v .
go tool covdata percent -i out/coverage
go tool covdata textfmt -i out/coverage -o out/coverage.txt
go tool cover -html out/coverage.txt -o out/coverage.html
104 changes: 102 additions & 2 deletions tests/keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,73 @@ testcases:
- result.code ShouldEqual 0
- result.systemoutjson.objects_list ShouldJSONContainWithKey id {{ .value.keyId }}

- name: Update key
steps:
- name: Check AES key current name
type: okms-cmd
args: keys get {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.name ShouldEqual "test-aes-1"
- name: Update AES key name
type: okms-cmd
args: keys update {{ .Create-Keys.aesKeyId }} --name test-aes-1-updated
- name: Check AES key new name
type: okms-cmd
args: keys get {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.name ShouldEqual "test-aes-1-updated"

- name: Activate and Deactivate
steps:
- name: Check AES key is active
type: okms-cmd
args: keys get {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.attributes.state ShouldEqual "active"
- name: Try activate AES key
type: okms-cmd
args: keys activate {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- name: Deactivate AES key
type: okms-cmd
args: keys deactivate {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- name: Check AES key is deactivated
type: okms-cmd
args: keys get {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.attributes.state ShouldEqual "deactivated"
- name: Compromise AES key
type: okms-cmd
args: keys deactivate {{ .Create-Keys.aesKeyId }} --reason key_compromise
assertions:
- result.code ShouldEqual 0
- name: Check AES key is compromised
type: okms-cmd
args: keys get {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.attributes.state ShouldEqual "compromised"
- result.systemoutjson.attributes.compromise_date ShouldNotBeNil
- name: Reactivate AES key
type: okms-cmd
args: keys activate {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- name: Check AES key is active
type: okms-cmd
args: keys get {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.attributes.state ShouldEqual "active"
- result.systemoutjson.attributes.compromise_date ShouldBeNil

- name: AES Encryption
steps:
- name: Encrypt data
Expand Down Expand Up @@ -281,6 +348,9 @@ testcases:
args: keys import --usage encrypt,decrypt --symmetric test-import-aes YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE=
assertions:
- result.code ShouldEqual 0
vars:
toDeleteAesKeyId:
from: result.systemoutjson.id
- name: Import RSA PKCS1 key
type: okms-cmd
args: keys import --usage sign,verify test-import-rsa-pkcs1 @testdata/rsa_pkcs1.priv.pem
Expand Down Expand Up @@ -315,15 +385,45 @@ testcases:

- name: Delete the keys
steps:
- name: Try delete active AES key
type: okms-cmd
args: keys delete {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 1
- name: Deactivate AES key
type: okms-cmd
args: keys deactivate {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- name: Delete deactivated AES key
type: okms-cmd
args: keys delete {{ .Create-Keys.aesKeyId }}
assertions:
- result.code ShouldEqual 0
- name: Force delete the {{ .value.kind }} key
type: okms-cmd
range:
- keyId: "{{ .Create-Keys.aesKeyId }}"
kind: AES
- keyId: "{{ .Create-Keys.rsaKeyId }}"
kind: RSA
- keyId: "{{ .Create-Keys.ecKeyId }}"
kind: ECDSA
args: keys delete {{ .value.keyId }} --force
assertions:
- result.code ShouldEqual 0

- name: Cleanup Domain
steps:
- name: List all keys
type: okms-cmd
args: keys ls
assertions:
- result.code ShouldEqual 0
vars:
allKeys:
from: result.systemoutjson.objects_list
- name: Force delete {{ .value.type }} key {{ .value.name }}
type: okms-cmd
range: "{{.allKeys}}"
args: keys delete {{ .value.id }} --force
assertions:
- result.code ShouldEqual 0
1 change: 0 additions & 1 deletion tests/lib/okms-cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ input:
format: json
steps:
- script: mkdir -p ./out/coverage && GOCOVERDIR=./out/coverage {{ .cmd_path }} -c {{ .cfg_path }} --output {{ .input.format }} {{ .input.args }}
# info: "{{ .cmd_path }} -c {{ .cfg_path }} --output {{ .input.format }} {{ .input.args }}"
vars:
code:
from: result.code
Expand Down
5 changes: 5 additions & 0 deletions tests/testdata/ecdsa_pkcs8.priv.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgKksp+sxRTdMBUnSK
KLCLQX28FV3zjUmrvs10gK1ZFnuhRANCAASmwId0fcOWQ6DnskzMDVquh5FEqLeV
6SW9kHs7FOW7t2u82fmkDl0z/X3L2D2IZ/aaGpOg3qQAKkvgYCO26HGm
-----END PRIVATE KEY-----
5 changes: 5 additions & 0 deletions tests/testdata/ecdsa_sec1.priv.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEICpLKfrMUU3TAVJ0iiiwi0F9vBVd841Jq77NdICtWRZ7oAoGCCqGSM49
AwEHoUQDQgAEpsCHdH3DlkOg57JMzA1aroeRRKi3leklvZB7OxTlu7drvNn5pA5d
M/19y9g9iGf2mhqToN6kACpL4GAjtuhxpg==
-----END EC PRIVATE KEY-----
9 changes: 9 additions & 0 deletions tests/testdata/ecdsa_ssh.priv.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS
1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQSlsnz7VFcaNPliN2lduCBW01hecfUL
zjqE83PaNl29sSQe08TZEa2C94Mw851NGvwSSmGWk5m6ky+nZnnoLoYMAAAAsHvkvOJ75L
ziAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKWyfPtUVxo0+WI3
aV24IFbTWF5x9QvOOoTzc9o2Xb2xJB7TxNkRrYL3gzDznU0a/BJKYZaTmbqTL6dmeeguhg
wAAAAgUDmUuoD7DVc+Dr70WqNZgPj++GDr5nnowfXzt7vpG7IAAAAVcHN5bW9uZWFAQzAy
RkwwOE5NTDdMAQID
-----END OPENSSH PRIVATE KEY-----
1 change: 1 addition & 0 deletions tests/testdata/ecdsa_ssh.pub.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKWyfPtUVxo0+WI3aV24IFbTWF5x9QvOOoTzc9o2Xb2xJB7TxNkRrYL3gzDznU0a/BJKYZaTmbqTL6dmeeguhgw= psymonea@C02FL08NML7L
27 changes: 27 additions & 0 deletions tests/testdata/rsa_pkcs1.priv.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAqDzr5t25wAd9qDnEEqwfLdGV5jTLbFRTQIP2rKIzqXGIqVnV
ZWZwj1LOpJGVnzCCHQi60uHScouT0wLuqBXF7iGcw+STb2fWNXNUzohF1Dewp2MP
rIK5OImF5TFzYwMdfK5W5EMSF4BpZ3P++yWsa4TPh5caN22fGBJpc8qYuDXqfB1C
I6E7Fsz7TK2dBBGi665szd6iUReqcTI+yJH+QRVvUrwDE2RoKcMTFahZsZ5Zv+W1
QaDcPq4lx4FEaWdBdVCp/qzZOfyNjjc9WNh5xTi/O4nXeLXFel66sTlnKp45dqmt
fhZx8ttvZv4WxHdajcEYj9EdPWDK4gUfasog5wIDAQABAoIBAEslUxV+6k4symLO
0paojRCxMexunoJXtAv4JcF8fejsjmdeeePd+t751N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Ok54TU6kaRegPGKH1+FF6HMn20lUjqtQpu2mV3vbvVMcyj7ubz+Mc3H
qE/XihloiUusYkcPi3+Ksrd/vatIBBFkTVH1TD16js7qK0GHzfo3
-----END RSA PRIVATE KEY-----
28 changes: 28 additions & 0 deletions tests/testdata/rsa_pkcs8.priv.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCxOpNU1lFtNH3s
3w1SUubV0s8bLJqYHX4NEGjJPmY8Htiy4aI2qmf2emM+mbUALyTY8vGajmnpcDH9
KcEAY2b/yV9F53Z5C8Z4FCyWiYXKutO9vP+xTX75IGjfzMrOAJAGqCaYvIA3j/3+
xpSy1FeEgrjGKiSt8i9SSYogbk2B4EqKQZJfzK9/bbPVTwJRbLqC9pqc0ZZLnp5a
mVSTIrlqmzHEMHdUB6zY1YUflEvGSvjhirUwrc8xBO4heqGb2ptUAND/6oVUwEfw
j7xKt2uG93yFMNyBNsAqz088dN+t1Ybsj4bRBhITKShlkzwl6BpsSAlx/NicjxMD
6E/x1GARAgMBAAECggEAAKuwEwoclMU2FMdjTYRyyyxZDElG7HxwFaySOPC7gk67
kzG3Y22RpyUfawU54h5LjWad82/GhtOd3M9jo5S8twsUCTevAxZAUgQBhzBOCU5b
rsQgU5Nvf5HX08D6o3ztDplkS/+qnIs28tfdiC+1hRLZkCZorR/VfgI5O5YvROaK
xCHVyZwGJb2cwVqd9Wbfo99/1CUejxAzXABzBA3lrBdXol2Mq/SAgKYm9xBnywIY
G/wOSqIgZSooN6SZib8M5IkAmw2eRyLld0DKPnMQA8qYn0gqo+U8zzo55eS/SnCk
ZWx0vBYFHyCgqafG3wgPXR8t7UDrHq0QCcr5xa3i4QKBgQDjDMVHXTqnrC3wAZLI
vuunq4YJOR4fE+OpndLAWy02GsTZe5D5tXIiRXVXSUJe4Ffr6BCf1fIyAeAyZTY1
JnLlcHCu3hpj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