-
Notifications
You must be signed in to change notification settings - Fork 597
add e2e test for pkcs11 token signing #3495
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3495 +/- ##
=======================================
Coverage 40.10% 40.10%
=======================================
Files 155 155
Lines 10044 10044
=======================================
Hits 4028 4028
Misses 5530 5530
Partials 486 486 ☔ View full report in Codecov by Sentry. |
test/e2e_test_pkcs11.sh
Outdated
@@ -0,0 +1,32 @@ | |||
#!/bin/bash | |||
|
|||
# Copyright 2021 The Sigstore Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also update the line 1 to #!/usr/bin/env bash
thanks
test/e2e_test_pkcs11.sh
Outdated
# add git | ||
apk add git | ||
# clone cosign | ||
git clone https://github.com/sigstore/cosign.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would test Cosign at HEAD rather than on the PR.
test/e2e_test.sh
Outdated
# Test pkcs11 token signing | ||
echo "testing pkcs11 token signing" | ||
CONTAINER_ID=$(sudo docker run -dit --name softhsm -p 2345:2345 vegardit/softhsm2-pkcs11-proxy) | ||
sudo docker exec -i $CONTAINER_ID /bin/bash < ./test/e2e_test_pkcs11.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be run without sudo? I'd prefer that the tests could be run locally without needed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure.
test/e2e_test.sh
Outdated
@@ -79,6 +79,11 @@ docker run -d -p 5000:5000 --restart always -e REGISTRY_STORAGE_DELETE_ENABLED=t | |||
export COSIGN_TEST_REPO=localhost:5000 | |||
go test -tags=e2e -v ./test/... -run TestSignVerifyClean | |||
|
|||
# Test pkcs11 token signing | |||
echo "testing pkcs11 token signing" | |||
CONTAINER_ID=$(sudo docker run -dit --name softhsm -p 2345:2345 vegardit/softhsm2-pkcs11-proxy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to cleanup container after the test completed
test/e2e_test.sh
Outdated
@@ -79,6 +79,15 @@ docker run -d -p 5000:5000 --restart always -e REGISTRY_STORAGE_DELETE_ENABLED=t | |||
export COSIGN_TEST_REPO=localhost:5000 | |||
go test -tags=e2e -v ./test/... -run TestSignVerifyClean | |||
|
|||
# Test pkcs11 token signing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this in its own shell script and workflow, following the pattern of other e2e tests, so it runs in parallel?
test/e2e_test.sh
Outdated
@@ -79,6 +79,15 @@ docker run -d -p 5000:5000 --restart always -e REGISTRY_STORAGE_DELETE_ENABLED=t | |||
export COSIGN_TEST_REPO=localhost:5000 | |||
go test -tags=e2e -v ./test/... -run TestSignVerifyClean | |||
|
|||
# Test pkcs11 token signing | |||
echo "testing pkcs11 token signing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove testing line
test/e2e_test.sh
Outdated
@@ -79,6 +79,15 @@ docker run -d -p 5000:5000 --restart always -e REGISTRY_STORAGE_DELETE_ENABLED=t | |||
export COSIGN_TEST_REPO=localhost:5000 | |||
go test -tags=e2e -v ./test/... -run TestSignVerifyClean | |||
|
|||
# Test pkcs11 token signing | |||
echo "testing pkcs11 token signing" | |||
CONTAINER_ID=$(docker run -dit --name softhsm -v $(pwd):/root/cosign -p 2345:2345 vegardit/softhsm2-pkcs11-proxy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pin the docker container by hash?
35352ee
to
1b311d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small thing, moving the test to a different GHA. Thanks!
cc @cpanato if you any other comments
.github/workflows/tests.yaml
Outdated
@@ -119,6 +119,9 @@ jobs: | |||
- name: Run end-to-end tests | |||
run: ./test/e2e_test.sh | |||
|
|||
- name: Run pkcs11 end-to-end tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this as a dedicated job in https://github.com/sigstore/cosign/blob/main/.github/workflows/e2e-tests.yml?
test/e2e_test_pkcs11.sh
Outdated
# Test pkcs11 token signing | ||
CONTAINER_ID=$(docker run -dit --name softhsm -v $(pwd):/root/cosign -p 2345:2345 vegardit/softhsm2-pkcs11-proxy@sha256:557a65d2a14e3986f2389d36ddce75609cbd8fb7ee6cf08a78adcc8236c2a80e) | ||
|
||
docker exec -i $CONTAINER_ID /bin/bash << 'EOF' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker exec -i $CONTAINER_ID /bin/bash << 'EOF' | |
docker exec -i $CONTAINER_ID /bin/bash << 'EOF' |
86b4fdf
to
4f20f72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this pr a few changes
test/e2e_test_pkcs11.sh
Outdated
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -ex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this explicit?
like
set -o errexit
set -o nounset
set -o pipefail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just need to update this
.github/workflows/e2e-tests.yml
Outdated
@@ -73,3 +76,17 @@ jobs: | |||
- name: Run e2e_signblob_tsa_mtls.sh | |||
shell: bash | |||
run: make && PATH="$PWD:$PATH" ./test/e2e_signblob_tsa_mtls.sh | |||
|
|||
e2e-test-pkcs11: | |||
name: Run pkcs11 e2e tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can drop this
go-version: ${{ env.GO_VERSION }} | ||
check-latest: true | ||
|
||
- name: Run pkcs11 end-to-end tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set the shell to bash like the others
Signed-off-by: Vivek Kumar Sahu <[email protected]> add license Signed-off-by: Vivek Kumar Sahu <[email protected]> small fix Signed-off-by: Vivek Kumar Sahu <[email protected]> update shebang portable with cross platform Signed-off-by: Vivek Kumar Sahu <[email protected]> enable exit on error and xtrace mode Signed-off-by: Vivek Kumar Sahu <[email protected]> cleanup container Signed-off-by: Vivek Kumar Sahu <[email protected]> pkcs11 test with upcoming changes Signed-off-by: Vivek Kumar Sahu <[email protected]> run pkcs11 e2e test in a separate workflow Signed-off-by: Vivek Kumar Sahu <[email protected]> add pkcs11 test in separate workflow Signed-off-by: Vivek Kumar Sahu <[email protected]>
Signed-off-by: Vivek Kumar Sahu <[email protected]>
4f20f72
to
5ed1fab
Compare
Signed-off-by: Vivek Kumar Sahu <[email protected]>
@cpanato PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will do any adjust in a followup
thanks for this pr! |
Summary
closes #3343
Earlier e2e test doesn't have facility to test PKCS11, but this PR has the support for end-to-end pkcs11 token signing
Following commands being run to automate the e2e test for PKCS11:
Release Note
Documentation