From 8c16038add9f7ed56ebc021e1ff474861290e41c Mon Sep 17 00:00:00 2001 From: Martin Malina Date: Thu, 10 Aug 2023 13:15:07 +0200 Subject: [PATCH] feat(HACBS-2405): add a setup script for tekton task testing The new tekton dir will be used for storing init scripts for tekton task testing in the release-service-bundles repo. This change is needed by https://github.com/redhat-appstudio/release-service-bundles/pull/159 Signed-off-by: Martin Malina --- Dockerfile | 3 ++- tekton/test-push-sbom-to-pyxis | 24 +++++++++++++++++++ tekton/test-push-sbom-to-pyxis-no-snapshot | 16 +++++++++++++ .../test-push-sbom-to-pyxis-urls-ids-mismatch | 16 +++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 tekton/test-push-sbom-to-pyxis create mode 100755 tekton/test-push-sbom-to-pyxis-no-snapshot create mode 100755 tekton/test-push-sbom-to-pyxis-urls-ids-mismatch diff --git a/Dockerfile b/Dockerfile index 10ba373..1710e59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,8 @@ RUN update-ca-trust COPY pyxis /home/pyxis COPY utils /home/utils +COPY tekton /home/tekton # Set HOME variable to something else than `/` to avoid 'permission denied' problems when writing files. ENV HOME=/tekton/home -ENV PATH="$PATH:/home/pyxis:/home/utils" +ENV PATH="$PATH:/home/pyxis:/home/utils:/home/tekton" diff --git a/tekton/test-push-sbom-to-pyxis b/tekton/test-push-sbom-to-pyxis new file mode 100755 index 0000000..b618c96 --- /dev/null +++ b/tekton/test-push-sbom-to-pyxis @@ -0,0 +1,24 @@ +# Description: This script is meant to set up mocks at the beginning +# of each step of the push-sbom-to-pyxis task. + +function cosign() { + echo Mock cosign called with: $* + + if [[ "$*" != "download sbom --output-file myImageID"[12]".json imageurl"[12] ]] + then + echo Error: Unexpected call + exit 1 + fi + + touch /workdir/sboms/${4} +} + +function upload_sbom() { + echo Mock upload_sbom called with: $* + + if [[ "$*" != "--retry --sbom-path "*".json" ]] + then + echo Error: Unexpected call + exit 1 + fi +} diff --git a/tekton/test-push-sbom-to-pyxis-no-snapshot b/tekton/test-push-sbom-to-pyxis-no-snapshot new file mode 100755 index 0000000..13dcd0b --- /dev/null +++ b/tekton/test-push-sbom-to-pyxis-no-snapshot @@ -0,0 +1,16 @@ +# Description: This script is meant to set up mocks at the beginning +# of each step of the push-sbom-to-pyxis task. + +function cosign() { + echo Mock cosign called with: $* + + echo Error: cosign should not be called + exit 1 +} + +function upload_sbom() { + echo Mock upload_sbom called with: $* + + echo Error: upload_sbom should not be called + exit 1 +} diff --git a/tekton/test-push-sbom-to-pyxis-urls-ids-mismatch b/tekton/test-push-sbom-to-pyxis-urls-ids-mismatch new file mode 100755 index 0000000..13dcd0b --- /dev/null +++ b/tekton/test-push-sbom-to-pyxis-urls-ids-mismatch @@ -0,0 +1,16 @@ +# Description: This script is meant to set up mocks at the beginning +# of each step of the push-sbom-to-pyxis task. + +function cosign() { + echo Mock cosign called with: $* + + echo Error: cosign should not be called + exit 1 +} + +function upload_sbom() { + echo Mock upload_sbom called with: $* + + echo Error: upload_sbom should not be called + exit 1 +}