diff --git a/tests/auxiliary/webhook-server/Dockerfile b/tests/auxiliary/webhook-server/Dockerfile new file mode 100644 index 000000000..ed6858783 --- /dev/null +++ b/tests/auxiliary/webhook-server/Dockerfile @@ -0,0 +1,14 @@ +FROM docker.io/library/golang:1.20 as builder + +WORKDIR /go/src/github.com/adnanh/webhook +RUN git clone --depth 1 -b 2.8.1 https://github.com/adnanh/webhook.git ./ && \ + go build -o server github.com/adnanh/webhook + +FROM docker.io/library/ubuntu:22.04 + +WORKDIR /var/webhook +COPY hooks.yaml /var/webhook/hooks.yaml +COPY --from=builder /go/src/github.com/adnanh/webhook/server /var/webhook/server +RUN chmod +x /var/webhook/server + +CMD ["/var/webhook/server", "-hooks", "/var/webhook/hooks.yaml", "-verbose"] diff --git a/tests/auxiliary/webhook-server/README.md b/tests/auxiliary/webhook-server/README.md new file mode 100644 index 000000000..792525454 --- /dev/null +++ b/tests/auxiliary/webhook-server/README.md @@ -0,0 +1,19 @@ +# Webhook Server + +This directory contains source for webhook server used in argocd-operator testing. The server is built using [adnanh/webhook](https://github.com/adnanh/webhook). + +## Multiarch Container Image + +Use `docker-build-push.sh` shell script to build & push multiarch container image. It uses `docker buildx` to build image for amd64, arm64, ppc64le & s390x architecture. Before you run below script, ensure you have push access to the image registry referenced in script. + +```bash +./docker-build-push.sh +``` + +## Local Build (for development) + +Use build command to build image for debugging/testing changes to this image. + +```bash +docker build -t quay.io/svghadi/webhook-server:latest -f Dockerfile . +``` \ No newline at end of file diff --git a/tests/auxiliary/webhook-server/docker-build-push.sh b/tests/auxiliary/webhook-server/docker-build-push.sh new file mode 100755 index 000000000..639b44e8c --- /dev/null +++ b/tests/auxiliary/webhook-server/docker-build-push.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# https://docs.docker.com/build/building/multi-platform/#getting-started +# create builder instance to build multiarch image +BUIDLER=$(docker buildx create --use) + +# build & push multiarch image +docker buildx build \ + --push \ + --tag quay.io/svghadi/webhook-server:latest \ + --platform linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \ + -f Dockerfile . + +# remove builder instance +docker buildx rm -f $BUIDLER \ No newline at end of file diff --git a/tests/auxiliary/webhook-server/hooks.yaml b/tests/auxiliary/webhook-server/hooks.yaml new file mode 100644 index 000000000..9e57c17f0 --- /dev/null +++ b/tests/auxiliary/webhook-server/hooks.yaml @@ -0,0 +1,3 @@ +- id: example + execute-command: "/usr/bin/date" + command-working-directory: "/var/webhook" \ No newline at end of file diff --git a/tests/k8s/1-034_validate_webhook_notifications/00-assert.yaml b/tests/k8s/1-034_validate_webhook_notifications/00-assert.yaml new file mode 100644 index 000000000..da2b4a6b3 --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/00-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: webhook +status: + availableReplicas: 1 \ No newline at end of file diff --git a/tests/k8s/1-034_validate_webhook_notifications/00-setup-webhook-server.yaml b/tests/k8s/1-034_validate_webhook_notifications/00-setup-webhook-server.yaml new file mode 100644 index 000000000..90fe5d649 --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/00-setup-webhook-server.yaml @@ -0,0 +1,118 @@ +apiVersion: v1 +kind: Service +metadata: + name: webhook +spec: + selector: + app: webhook + ports: + - name: https + port: 443 + targetPort: 9000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: webhook + labels: + app: webhook +spec: + replicas: 1 + selector: + matchLabels: + app: webhook + template: + metadata: + labels: + app: webhook + spec: + containers: + - name: server + image: quay.io/svghadi/webhook-server:latest + command: ["/var/webhook/server"] + args: + - -hooks + - /var/webhook/hooks.yaml + - -cert + - /var/webhook/tls.crt + - -key + - /var/webhook/tls.key + - -secure + - -verbose + ports: + - containerPort: 9000 + volumeMounts: + - mountPath: "/var/webhook/tls.crt" + name: webhook-tls + subPath: tls.crt + - mountPath: "/var/webhook/tls.key" + name: webhook-tls + subPath: tls.key + - mountPath: "/var/webhook/hooks.yaml" + name: webhook-config + subPath: hooks.yaml + volumes: + - name: webhook-tls + secret: + secretName: webhook-tls + - name: webhook-config + configMap: + name: webhook-config +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: webhook-config +data: + hooks.yaml: | + - id: example + execute-command: "/usr/bin/date" + command-working-directory: "/var/webhook" + incoming-payload-content-type: "application/json" + pass-environment-to-command: + - source: entire-payload + envname: PAYLOAD +--- +kind: Secret +apiVersion: v1 +metadata: + name: webhook-tls +stringData: + # certificate is valid till 2123 + tls.crt: | + -----BEGIN CERTIFICATE----- + MIIFrjCCA5agAwIBAgIUbM9O0W6IdumLQodDCDqyckYDr2IwDQYJKoZIhvcNAQEL + BQAwTTELMAkGA1UEBhMCVVMxDTALBgNVBAgMBFRlc3QxDTALBgNVBAoMBFRlc3Qx + DTALBgNVBAsMBFRlc3QxETAPBgNVBAMMCHRlc3QuY29tMCAXDTIzMTEyNjIyMTg0 + N1oYDzIxMjMxMTI3MjIxODQ3WjBNMQswCQYDVQQGEwJVUzENMAsGA1UECAwEVGVz + dDENMAsGA1UECgwEVGVzdDENMAsGA1UECwwEVGVzdDERMA8GA1UEAwwIdGVzdC5j + b20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDbgAmnUjFux9u2Xzhi + mno5zjA/YsoXr3eFtK9XtByQMLLyT0hbXoa9gpTeafOs3IkCotPdN+omxm2tN9UA + ebAq+EamWyIF28EA3UbCWWULghveezrmAKSMcqQqby3knbcbGng+ZZjRdC3xc0uz + /sd4FqaLt0UHBDMlpxRskj/S3CDetfyIrKYQcZ5NQjx75aRN8At5OPC1NiWTmlsv + ppa4LLV0HR6AJzq+C6RAmJTcHQOFAq33wZEHHIpoQoGWHHPpT0ut54KIiVTRJ2o4 + MEV4KlBBgL3ux4+v7R0RfVmzgaMEDG1fC9tX8pIofv7wP7WX/5XHTjyAiv8gbpUW + nLiU8FoTDZWxZN+MiCkUvZl8KqotbcUPjhnRdnq4anFwywY1lKILnCIayqzI7mPW + 12h39fNwprFz9YFYbLLoQHek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Sk1QVEh2TApmRjFEWDd5NmFjejNKWHJHSllRc3FjclZvZFNmY0daSy9SSlFrZHZyU2RCUlpZZ1dxK0NCWVZpT3hrTjdjc2NyCnJ1US9EWkgvWkNJeFZja2J1VnNBTXFkQ3FBTzBnWDgzZUVwN2VsZkFWbG5MaHZ4UGx1eElTdVhhSm1oSk5hZnIKWHErTmluZnJxT0xKa0laL3UvUEp1NEtxTjNNPQotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0t" # notsecret + diff --git a/tests/k8s/1-034_validate_webhook_notifications/01-assert.yaml b/tests/k8s/1-034_validate_webhook_notifications/01-assert.yaml new file mode 100644 index 000000000..9caf46bc2 --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/01-assert.yaml @@ -0,0 +1,9 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ArgoCD +metadata: + name: argocd +status: + phase: Available + notificationsController: Running + applicationController: Running + server: Running \ No newline at end of file diff --git a/tests/k8s/1-034_validate_webhook_notifications/01-install-argocd.yaml b/tests/k8s/1-034_validate_webhook_notifications/01-install-argocd.yaml new file mode 100644 index 000000000..fbf2dd794 --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/01-install-argocd.yaml @@ -0,0 +1,44 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ArgoCD +metadata: + name: argocd +spec: + notifications: + enabled: true + tls: + initialCerts: + # value is copied from tls.crt key in setup-webhook-server.yaml + webhook: | + -----BEGIN CERTIFICATE----- + MIIFrjCCA5agAwIBAgIUbM9O0W6IdumLQodDCDqyckYDr2IwDQYJKoZIhvcNAQEL + BQAwTTELMAkGA1UEBhMCVVMxDTALBgNVBAgMBFRlc3QxDTALBgNVBAoMBFRlc3Qx + DTALBgNVBAsMBFRlc3QxETAPBgNVBAMMCHRlc3QuY29tMCAXDTIzMTEyNjIyMTg0 + N1oYDzIxMjMxMTI3MjIxODQ3WjBNMQswCQYDVQQGEwJVUzENMAsGA1UECAwEVGVz + dDENMAsGA1UECgwEVG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c9A28 + 5b1+PEynHcopNK41zF4n4FnIy9h8zJfaPYYCPPMT0v9LzuT5zyF5sXCz0o4KwQJ6 + zrggZme8udl9sWyDxZyFoFPLWtnQFY7vJ9LSM2Gt+XUIuYNwDkvGFs6RfBYJGarX + qq7YHYj0H2x/us3KQCXGX5GzSmM9ewHvaScRpFcCdVwszKwWF0vMvdnh+3P72/Yy + dQvZXyfNiwqaIdznJn/AjzR9K4dHfbY7wMm83WHwWyjzV6CybHbtWpoUIlZtW3TT + gz6MP2z+BhOdMiQA33aO38J2TX/CMkEvkagEiZdS9t3xtpF2LOb5bRIdlENtZU0i + LnhgWEpJmswxBtuJ0d/zcyUlvK7FYoJZB7pT3YX/321HXZVCKyw+xrinwQoI3RnX + 7u0TZ3MqtSKEwCyDWYRJDbs6XUX1G0q7jXBf1+3cd+lBdOZ4Kl5B4YSU9hcFxAuO + 4a1eFXBdmT8PnwoTizFvag3IgBXkf8PqcKNvSMU6UKcD5LYTwRGK3JVl1L79gkrb + LmWEfOXFHgSlMIZkEs41TiopXy8p/LSera8NR86Q3mTZ7rRdEveOb6ZLJksRqaqr + UVwpFuaKz5vTCD36Gmmy/u8y + -----END CERTIFICATE----- \ No newline at end of file diff --git a/tests/k8s/1-034_validate_webhook_notifications/02-update-notifications-cm.yaml b/tests/k8s/1-034_validate_webhook_notifications/02-update-notifications-cm.yaml new file mode 100644 index 000000000..39aea3253 --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/02-update-notifications-cm.yaml @@ -0,0 +1,19 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: argocd-notifications-cm +data: + service.webhook.test-webhook: | + url: https://webhook/hooks/example + template.test-app-created: | + webhook: + test-webhook: + method: POST + body: | + {"created":"{{.app.metadata.name}}"} + trigger.test-on-created: |- + - description: Application is created. + send: ["test-app-created"] + when: "true" + + diff --git a/tests/k8s/1-034_validate_webhook_notifications/03-sleep.yaml b/tests/k8s/1-034_validate_webhook_notifications/03-sleep.yaml new file mode 100644 index 000000000..60b2eebc9 --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/03-sleep.yaml @@ -0,0 +1,5 @@ +# let notifications controller pick up configmap changes. +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: sleep 20 \ No newline at end of file diff --git a/tests/k8s/1-034_validate_webhook_notifications/04-create-app.yaml b/tests/k8s/1-034_validate_webhook_notifications/04-create-app.yaml new file mode 100644 index 000000000..9ae4ff956 --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/04-create-app.yaml @@ -0,0 +1,25 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: | + set -e + + cat << EOF | kubectl apply -f - + apiVersion: argoproj.io/v1alpha1 + kind: Application + metadata: + name: my-app-3 + namespace: $NAMESPACE + annotations: + "notifications.argoproj.io/subscribe.test-on-created.test-webhook": "" + spec: + destination: + namespace: $NAMESPACE + server: https://kubernetes.default.svc + project: default + source: + repoURL: https://github.com/redhat-developer/gitops-operator + path: test/examples/nginx + targetRevision: HEAD + EOF +- script: sleep 5 \ No newline at end of file diff --git a/tests/k8s/1-034_validate_webhook_notifications/05-verify-webhook-notification.yaml b/tests/k8s/1-034_validate_webhook_notifications/05-verify-webhook-notification.yaml new file mode 100644 index 000000000..ab1d9436d --- /dev/null +++ b/tests/k8s/1-034_validate_webhook_notifications/05-verify-webhook-notification.yaml @@ -0,0 +1,25 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +# verify no x509 in notifications-controller logs +- script: | + #!/bin/bash + kubectl -n $NAMESPACE logs deployment.apps/argocd-notifications-controller | grep "x509" + + PREV_CMD=$? + if [ $PREV_CMD -eq 1 ]; then + exit 0 + else + exit 1 + fi +# verify notification delivery +- script: | + #!/bin/bash + kubectl -n $NAMESPACE logs deployment.apps/webhook | grep '{"created":"my-app-3"}' + + PREV_CMD=$? + if [ $PREV_CMD -eq 0 ]; then + exit 0 + else + exit 1 + fi