diff --git a/internal/tasks/update-fbc-catalog-task/tests/mocks.sh b/internal/tasks/update-fbc-catalog-task/tests/mocks.sh index 04cd1b17a..0f347ec0a 100755 --- a/internal/tasks/update-fbc-catalog-task/tests/mocks.sh +++ b/internal/tasks/update-fbc-catalog-task/tests/mocks.sh @@ -1,9 +1,32 @@ #!/bin/bash set -eux +# need a seed +SEED=' +--- +id: 1 +distribution_scope: "stage" +fbc_fragment: "registry.io/image0@sha256:0000" +internal_index_image_copy: "registry-proxy-stage.engineering.redhat.com/rh-osbs-stage/iib:1" +logs: +url: "https://fakeiib.host/api/v1/builds/1/logs" +request_type: "fbc-operations" +state: "complete" +state_reason: "" +state_history: + - state: "in_progress" + state_reason: "The request was initiated" +user: "iib@kerberos"' + success_state_reason="The FBC fragment was successfully added in the index image" -seed="build-seed.yaml" function curl() { - echo $@ - # yq "$seed" -o json | jq --argjson progress '{ "state": "completed", "state_reason": "cabo"}' '.state_history += [$progress] + yq -o json <<< $SEED | jq --argjson progress '{ "state": "completed", "state_reason": "The FBC fragment was successfully added in the index image"}' '.state_history += [$progress]' +} + +function base64() { + echo "decrypted-keytab" +} + +function kinit() { + echo "Ok" } diff --git a/internal/tasks/update-fbc-catalog-task/tests/pre-apply-task-hook.sh b/internal/tasks/update-fbc-catalog-task/tests/pre-apply-task-hook.sh index 86cd86800..f8f35dd0c 100755 --- a/internal/tasks/update-fbc-catalog-task/tests/pre-apply-task-hook.sh +++ b/internal/tasks/update-fbc-catalog-task/tests/pre-apply-task-hook.sh @@ -6,6 +6,17 @@ # Add RBAC so that the SA executing the tests can retrieve CRs kubectl apply -f .github/resources/crd_rbac.yaml +# create required secrets +kubectl create secret generic iib-service-account-secret \ + --from-literal=principal="iib@kerberos" \ + --from-literal=keytab="something" +kubectl create secret generic iib-services-config \ + --from-literal=krb5.conf="" \ + --from-literal=url="https://fakeiib.host" + +kubectl create secret generic iib-overwrite-fromimage-credentials \ + --from-literal=username="bot+user" \ + --from-literal=token="token" # Add mocks to the beginning of task step script TASK_PATH="$1" SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) diff --git a/internal/tasks/update-fbc-catalog-task/tests/test-update-fbc-catalog-default.yaml b/internal/tasks/update-fbc-catalog-task/tests/test-update-fbc-catalog-default.yaml index b86812605..c6bebfc58 100644 --- a/internal/tasks/update-fbc-catalog-task/tests/test-update-fbc-catalog-default.yaml +++ b/internal/tasks/update-fbc-catalog-task/tests/test-update-fbc-catalog-default.yaml @@ -4,7 +4,7 @@ kind: Pipeline metadata: name: test-update-fbc-catalog-default spec: - description: Test + description: Test tasks: - name: run-task taskRef: @@ -14,12 +14,12 @@ spec: value: "registry.io/image0@sha256:0000" - name: fromIndex value: "quay.io/scoheb/fbc-index-testing:latest" - - name: buildTags + - name: buildTags value: "[]" - name: addArches value: "[]" - name: iibServiceAccountSecret - value: "iib-account-secret" + value: "iib-service-account-secret" - name: check-result taskSpec: steps: diff --git a/internal/tasks/update-fbc-catalog-task/update-fbc-catalog-task.yaml b/internal/tasks/update-fbc-catalog-task/update-fbc-catalog-task.yaml index 25622676d..13e3042fd 100644 --- a/internal/tasks/update-fbc-catalog-task/update-fbc-catalog-task.yaml +++ b/internal/tasks/update-fbc-catalog-task/update-fbc-catalog-task.yaml @@ -124,7 +124,7 @@ spec: export KRB5_CONFIG="${KRB5_TEMP_CONF}" export KRB5_TRACE=/dev/stderr - /usr/bin/kinit -V "${KRB5_PRINCIPAL}" -k -t /tmp/keytab + kinit -V "${KRB5_PRINCIPAL}" -k -t /tmp/keytab set -x # check if this fbc fragment is opt-in