From f5f17ee48933ecac04bd37113cbe7a2625eb2f7d Mon Sep 17 00:00:00 2001 From: Cori Avila <42420333+corico44@users.noreply.github.com> Date: Fri, 12 May 2023 10:06:44 +0200 Subject: [PATCH] [bitnami/harbor-registryctl] Add VIB tests (#30853) * [bitnami/harbor-registryctl] Add initial tests Signed-off-by: Cori Avila * [bitnami/harbor-registryctl] Fix registry binary check and add tests to check harbor_registryctl and registry binaries Signed-off-by: Cori Avila * [bitnami/harbor-registryctl] Add change in docker-compose file to trigger tests Signed-off-by: Cori Avila * [bitnami/harbor-registryctl] Fix check for /var/lib/registry and /storage directories Signed-off-by: Cori Avila * [bitnami/harbor-registryctl] Check if swagger binary exists Signed-off-by: Cori Avila * [bitnami/harbor-registryctl] Delete blank space Signed-off-by: corico44 <42420333+corico44@users.noreply.github.com> * [bitnami/harbor-registryctl] Fix check-app-version test Signed-off-by: Cori Avila * [bitnami/harbor-registryctl] Fix check for swagger binary Signed-off-by: Cori Avila * [bitnami/harbor-registryctl] Delete trigger in docker-compose file Signed-off-by: Cori Avila --------- Signed-off-by: Cori Avila Signed-off-by: corico44 <42420333+corico44@users.noreply.github.com> --- .vib/harbor-registryctl/goss/goss.yaml | 12 +++++++ .../goss/harbor-registryctl.yaml | 31 +++++++++++++++++++ .vib/harbor-registryctl/goss/vars.yaml | 12 +++++++ .vib/harbor-registryctl/vib-publish.json | 18 ++++++++++- .vib/harbor-registryctl/vib-verify.json | 18 ++++++++++- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 .vib/harbor-registryctl/goss/goss.yaml create mode 100644 .vib/harbor-registryctl/goss/harbor-registryctl.yaml create mode 100644 .vib/harbor-registryctl/goss/vars.yaml diff --git a/.vib/harbor-registryctl/goss/goss.yaml b/.vib/harbor-registryctl/goss/goss.yaml new file mode 100644 index 000000000000..80ad22c0e32c --- /dev/null +++ b/.vib/harbor-registryctl/goss/goss.yaml @@ -0,0 +1,12 @@ +gossfile: + # Goss tests exclusive to the current container + ../../harbor-registryctl/goss/harbor-registryctl.yaml: {} + # Load scripts from .vib/common/goss/templates + ../../common/goss/templates/check-app-version.yaml: {} + ../../common/goss/templates/check-binaries.yaml: {} + ../../common/goss/templates/check-broken-symlinks.yaml: {} + ../../common/goss/templates/check-ca-certs.yaml: {} + ../../common/goss/templates/check-directories.yaml: {} + ../../common/goss/templates/check-linked-libraries.yaml: {} + ../../common/goss/templates/check-sed-in-place.yaml: {} + ../../common/goss/templates/check-spdx.yaml: {} diff --git a/.vib/harbor-registryctl/goss/harbor-registryctl.yaml b/.vib/harbor-registryctl/goss/harbor-registryctl.yaml new file mode 100644 index 000000000000..432681697e5e --- /dev/null +++ b/.vib/harbor-registryctl/goss/harbor-registryctl.yaml @@ -0,0 +1,31 @@ +group: + harbor: + exists: true +user: + harbor: + exists: true +file: + /var/lib/registry: + exists: true + mode: "0775" + owner: harbor + filetype: directory + /storage: + exists: true + mode: "0775" + owner: harbor + filetype: directory + /opt/bitnami/harbor-registryctl/bin/swagger: + exists: false +command: + # Ensure a set of directories exist and the non-root user has write privileges to them + check-directories-exist-with-user: + exec: ls -dl /etc/ssl/certs /etc/pki/tls/certs/ 2>/dev/null | grep "drwxrwxr-x.*harbor" + exit-status: 0 + # Ensure permissions for Internal TLS + check-permissions-system-certs: + exec: ls -l /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.trust.crt /etc/ssl/certs/ca-certificates.crt 2>/dev/null | grep ".*-rw-rw-r--.*harbor" + exit-status: 0 + check-harbor-registryctl-binary: + exec: harbor_registryctl --help + exit-status: 0 \ No newline at end of file diff --git a/.vib/harbor-registryctl/goss/vars.yaml b/.vib/harbor-registryctl/goss/vars.yaml new file mode 100644 index 000000000000..3d040be705be --- /dev/null +++ b/.vib/harbor-registryctl/goss/vars.yaml @@ -0,0 +1,12 @@ +binaries: + - yq + - registry + - harbor_registryctl +directories: + - paths: + - /etc/registry + - /etc/registryctl +version: + bin_name: registry + flag: --version +root_dir: /opt/bitnami diff --git a/.vib/harbor-registryctl/vib-publish.json b/.vib/harbor-registryctl/vib-publish.json index 8b6fe8eab4e6..1ccdeb9a8a24 100644 --- a/.vib/harbor-registryctl/vib-publish.json +++ b/.vib/harbor-registryctl/vib-publish.json @@ -3,7 +3,8 @@ "resources": { "url": "{VIB_ENV_CONTAINER_URL}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -33,6 +34,21 @@ }, "verify": { "actions": [ + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "harbor-registryctl/goss/goss.yaml", + "vars_file": "harbor-registryctl/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-harbor-registryctl" + } + } + } + }, { "action_id": "trivy", "params": { diff --git a/.vib/harbor-registryctl/vib-verify.json b/.vib/harbor-registryctl/vib-verify.json index a34e8aee9161..7eef59bce6e7 100644 --- a/.vib/harbor-registryctl/vib-verify.json +++ b/.vib/harbor-registryctl/vib-verify.json @@ -3,7 +3,8 @@ "resources": { "url": "{SHA_ARCHIVE}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -29,6 +30,21 @@ }, "verify": { "actions": [ + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "harbor-registryctl/goss/goss.yaml", + "vars_file": "harbor-registryctl/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-harbor-registryctl" + } + } + } + }, { "action_id": "trivy", "params": {