From 0e5f75d7009cfe8000b7af14a9b98d4a47e5320e Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 26 Mar 2024 19:35:25 +0200 Subject: [PATCH] Added testing --- deploy/sthome-webhook/Chart.yaml | 1 + deploy/sthome-webhook/values.yaml | 18 ++++++++++++++- tests/suite_test.go | 38 +++++++++++++++++++++++++++++++ tests/testdata/config.json | 10 ++++++++ tests/testdata/secret.yaml | 8 +++++++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 tests/suite_test.go create mode 100644 tests/testdata/config.json create mode 100644 tests/testdata/secret.yaml diff --git a/deploy/sthome-webhook/Chart.yaml b/deploy/sthome-webhook/Chart.yaml index eb2c2c2..e1107d5 100644 --- a/deploy/sthome-webhook/Chart.yaml +++ b/deploy/sthome-webhook/Chart.yaml @@ -3,3 +3,4 @@ appVersion: "v0.0.1" description: Cert-Manager webhook for sthome name: sthome-webhook version: 0.0.1 + diff --git a/deploy/sthome-webhook/values.yaml b/deploy/sthome-webhook/values.yaml index e3dd578..aef938f 100644 --- a/deploy/sthome-webhook/values.yaml +++ b/deploy/sthome-webhook/values.yaml @@ -8,9 +8,25 @@ # here is recommended. groupName: acme.sthome.net +labels: sthome-webhook + certManager: namespace: ix-cert-manager - serviceAccountName: cert-manager + serviceAccountName: cert-manager-certmanager + +#secrets: +# apiID: +# apiToken: + +clusterIssuer: + enabled: true + staging: false + #email: + + # https://cert-manager.io/docs/configuration/acme/#adding-multiple-solver-types + #selector: + # dnsZones: + # - 'sthome.net' image: repository: stuurmcp/cert-manager-webhook-sthome diff --git a/tests/suite_test.go b/tests/suite_test.go new file mode 100644 index 0000000..b9214b5 --- /dev/null +++ b/tests/suite_test.go @@ -0,0 +1,38 @@ +//go:build integration +// +build integration + +package tests + +import ( + "os" + "testing" + + "github.com/cert-manager/cert-manager/test/acme/dns" + + sthome "github.com/cert-manager/cert-manager-webhook-sthome/sthome" +) + +var ( + zone = os.Getenv("TEST_ZONE_NAME") +) + +func TestRunsSuite(t *testing.T) { + // The manifest path should contain a file named config.json that is a + // snippet of valid configuration that should be included on the + // ChallengeRequest passed as part of the test cases. + + currentDir, err := os.Getwd() + if err != nil { + t.Fatalf("error getting current working dir: %s", err.Error()) + } + + fixture := dns.NewFixture(&sthome.ProviderSolver{}, + dns.SetResolvedZone(zone), + dns.SetAllowAmbientCredentials(true), + dns.SetBinariesPath(currentDir+"/kubebuilder/bin"), + dns.SetManifestPath(currentDir+"/testdata"), + dns.SetStrict(true), + ) + + fixture.RunConformance(t) +} diff --git a/tests/testdata/config.json b/tests/testdata/config.json new file mode 100644 index 0000000..22ec4d2 --- /dev/null +++ b/tests/testdata/config.json @@ -0,0 +1,10 @@ +{ + "accessKeySecretRef": { + "name": "sthome-secret", + "key": "STHOME_ACCESS_KEY" + }, + "secretKeySecretRef": { + "name": "sthome-secret", + "key": "STHOME_SECRET_KEY" + } +} diff --git a/tests/testdata/secret.yaml b/tests/testdata/secret.yaml new file mode 100644 index 0000000..44b3259 --- /dev/null +++ b/tests/testdata/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +stringData: + STHOME_ACCESS_KEY: STHOMEXXXXXXXXXXXXXX + STHOME_SECRET_KEY: 66666666-7777-8888-9999-000000000000 +kind: Secret +metadata: + name: sthome-secret +type: Opaque