Skip to content

Commit 8852022

Browse files
Merge pull request #26 from siddhibhor-56/sbhor-eso-52
ESO-52: Adds e2e test case for the operator
2 parents 502e9c6 + 687f6fb commit 8852022

File tree

236 files changed

+96845
-1904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+96845
-1904
lines changed

go.mod

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/openshift/external-secrets-operator
33
go 1.23.6
44

55
require (
6+
github.com/aws/aws-sdk-go v1.55.7
67
github.com/cert-manager/cert-manager v1.16.4
78
github.com/elastic/crd-ref-docs v0.1.0
89
github.com/go-bindata/go-bindata v3.1.2+incompatible
@@ -11,15 +12,16 @@ require (
1112
github.com/maxbrunsfeld/counterfeiter/v6 v6.11.2
1213
github.com/onsi/ginkgo/v2 v2.22.0
1314
github.com/onsi/gomega v1.36.1
14-
github.com/openshift/build-machinery-go v0.0.0-20250414185254-3ce8e800ceda
15+
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
16+
github.com/stretchr/testify v1.10.0
1517
go.uber.org/zap v1.27.0
16-
k8s.io/api v0.32.1
18+
k8s.io/api v0.32.3
1719
k8s.io/apiextensions-apiserver v0.32.1
18-
k8s.io/apimachinery v0.32.1
20+
k8s.io/apimachinery v0.32.3
1921
k8s.io/client-go v0.32.1
2022
k8s.io/klog/v2 v2.130.1
2123
k8s.io/kubernetes v1.32.1
22-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
24+
k8s.io/utils v0.0.0-20241210054802-24370beab758
2325
sigs.k8s.io/controller-runtime v0.20.1
2426
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20250308055145-5fe7bb3edc86
2527
sigs.k8s.io/controller-tools v0.16.1
@@ -142,6 +144,7 @@ require (
142144
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
143145
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
144146
github.com/jjti/go-spancheck v0.6.1 // indirect
147+
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 // indirect
145148
github.com/josharian/intern v1.0.0 // indirect
146149
github.com/json-iterator/go v1.1.12 // indirect
147150
github.com/julz/importas v0.1.0 // indirect
@@ -221,7 +224,6 @@ require (
221224
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
222225
github.com/stoewer/go-strcase v1.3.0 // indirect
223226
github.com/stretchr/objx v0.5.2 // indirect
224-
github.com/stretchr/testify v1.10.0 // indirect
225227
github.com/subosito/gotenv v1.4.1 // indirect
226228
github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
227229
github.com/tdakkota/asciicheck v0.2.0 // indirect

go.sum

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8ger
5454
github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU=
5555
github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s=
5656
github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI=
57+
github.com/aws/aws-sdk-go v1.55.7 h1:UJrkFq7es5CShfBwlWAC8DA077vp8PyVbQd3lqLiztE=
58+
github.com/aws/aws-sdk-go v1.55.7/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
5759
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
5860
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
5961
github.com/bkielbasa/cyclop v1.2.1 h1:AeF71HZDob1P2/pRm1so9cd1alZnrpyc4q2uP2l0gJY=
@@ -284,6 +286,10 @@ github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af h1:KA9B
284286
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0=
285287
github.com/jjti/go-spancheck v0.6.1 h1:ZK/wE5Kyi1VX3PJpUO2oEgeoI4FWOUm7Shb2Gbv5obI=
286288
github.com/jjti/go-spancheck v0.6.1/go.mod h1:vF1QkOO159prdo6mHRxak2CpzDpHAfKiPUDP/NeRnX8=
289+
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 h1:liMMTbpW34dhU4az1GN0pTPADwNmvoRSeoZ6PItiqnY=
290+
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
291+
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
292+
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
287293
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
288294
github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc=
289295
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -393,8 +399,8 @@ github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
393399
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
394400
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
395401
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
396-
github.com/openshift/build-machinery-go v0.0.0-20250414185254-3ce8e800ceda h1:Yjnmq1n4zf1pTwao3EAgkG5o++6iOuxfxGVDwj2Kfrs=
397-
github.com/openshift/build-machinery-go v0.0.0-20250414185254-3ce8e800ceda/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
402+
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+Sp5GGnjHDhT/a/nQ1xdp43UscBMr7G5wxsYotyhzJ4=
403+
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
398404
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
399405
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
400406
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
@@ -766,19 +772,20 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
766772
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
767773
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
768774
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
775+
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
769776
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
770777
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
771778
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
772779
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
773780
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
774781
honnef.co/go/tools v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
775782
honnef.co/go/tools v0.4.7/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0=
776-
k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc=
777-
k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k=
783+
k8s.io/api v0.32.3 h1:Hw7KqxRusq+6QSplE3NYG4MBxZw1BZnq4aP4cJVINls=
784+
k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k=
778785
k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw=
779786
k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto=
780-
k8s.io/apimachinery v0.32.1 h1:683ENpaCBjma4CYqsmZyhEzrGz6cjn1MY/X2jB2hkZs=
781-
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
787+
k8s.io/apimachinery v0.32.3 h1:JmDuDarhDmA/Li7j3aPrwhpNBA94Nvk5zLeOge9HH1U=
788+
k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
782789
k8s.io/apiserver v0.32.1 h1:oo0OozRos66WFq87Zc5tclUX2r0mymoVHRq8JmR7Aak=
783790
k8s.io/apiserver v0.32.1/go.mod h1:UcB9tWjBY7aryeI5zAgzVJB/6k7E97bkr1RgqDz0jPw=
784791
k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU=
@@ -801,8 +808,8 @@ k8s.io/kubelet v0.32.1 h1:bB91GvMsZb+LfzBxnjPEr1Fal/sdxZtYphlfwAaRJGw=
801808
k8s.io/kubelet v0.32.1/go.mod h1:4sAEZ6PlewD0GroV3zscY7llym6kmNNTVmUI/Qshm6w=
802809
k8s.io/kubernetes v1.32.1 h1:46YPpIBCT9dkmeglstZ2Gg4LGaAdro1/3IQ+1AfbF1s=
803810
k8s.io/kubernetes v1.32.1/go.mod h1:tiIKO63GcdPRBHW2WiUFm3C0eoLczl3f7qi56Dm1W8I=
804-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro=
805-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
811+
k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0=
812+
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
806813
mvdan.cc/gofumpt v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
807814
mvdan.cc/gofumpt v0.6.0/go.mod h1:4L0wf+kgIPZtcCWXynNS2e6bhmj73umwnuXSZarixzA=
808815
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f h1:lMpcwN6GxNbWtbpI1+xzFLSW8XzX0u72NttUGVFjO3U=

test/e2e/e2e_suite_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,26 @@ import (
2020
"fmt"
2121
"testing"
2222

23+
"k8s.io/client-go/rest"
24+
"sigs.k8s.io/controller-runtime/pkg/client/config"
25+
2326
. "github.com/onsi/ginkgo/v2"
2427
. "github.com/onsi/gomega"
2528
)
2629

30+
var (
31+
cfg *rest.Config
32+
)
33+
34+
var _ = BeforeSuite(func() {
35+
var err error
36+
37+
By("Initializing Kubernetes config")
38+
39+
cfg, err = config.GetConfig()
40+
Expect(err).NotTo(HaveOccurred(), "failed to get kubeconfig")
41+
})
42+
2743
// Run e2e tests using the Ginkgo runner.
2844
func TestE2E(t *testing.T) {
2945
RegisterFailHandler(Fail)

test/e2e/e2e_test.go

Lines changed: 127 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/*
22
Copyright 2025.
3-
43
Licensed under the Apache License, Version 2.0 (the "License");
54
you may not use this file except in compliance with the License.
65
You may obtain a copy of the License at
76
8-
http://www.apache.org/licenses/LICENSE-2.0
7+
http://www.apache.org/licenses/LICENSE-2.0
98
109
Unless required by applicable law or agreed to in writing, software
1110
distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,66 +16,147 @@ limitations under the License.
1716
package e2e
1817

1918
import (
19+
"context"
20+
"embed"
21+
"encoding/base64"
2022
"fmt"
21-
"os/exec"
23+
"testing"
2224
"time"
2325

26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27+
"k8s.io/apimachinery/pkg/runtime/schema"
28+
"k8s.io/client-go/dynamic"
29+
"k8s.io/client-go/kubernetes"
30+
2431
. "github.com/onsi/ginkgo/v2"
2532
. "github.com/onsi/gomega"
2633

2734
"github.com/openshift/external-secrets-operator/test/utils"
2835
)
2936

30-
const namespace = "external-secrets-operator"
37+
//go:embed testdata/*
38+
var testassets embed.FS
39+
40+
const (
41+
operatorNamespace = "external-secrets-operator"
42+
operandNamespace = "external-secrets"
43+
secretStoreFile = "testdata/aws_secret_store.yaml"
44+
externalSecretFile = "testdata/aws_external_secret.yaml"
45+
pushSecretFile = "testdata/push_secret.yaml"
46+
externalSecrets = "testdata/external_secret.yaml"
47+
expectedSecretValueFile = "testdata/expected_value.yaml"
48+
awsSecretToPushFile = "testdata/aws_k8s_push_secret.yaml"
49+
awsSecretRegionName = "ap-south-1"
50+
)
51+
52+
var _ = Describe("External Secrets Operator End-to-End test scenarios", Ordered, func() {
53+
ctx := context.TODO()
54+
var (
55+
clientset *kubernetes.Clientset
56+
dynamicClient *dynamic.DynamicClient
57+
loader utils.DynamicResourceLoader
58+
awsSecretName string
59+
)
3160

32-
var _ = Describe("controller", Ordered, func() {
3361
BeforeAll(func() {
34-
//TODO: add any pre-reqs for the tests.
62+
var err error
63+
loader = utils.NewDynamicResourceLoader(ctx, &testing.T{})
64+
65+
clientset, err = kubernetes.NewForConfig(cfg)
66+
Expect(err).Should(BeNil())
67+
68+
dynamicClient, err = dynamic.NewForConfig(cfg)
69+
Expect(err).Should(BeNil())
70+
71+
awsSecretName = fmt.Sprintf("eso-e2e-secret-%s", utils.GetRandomString(5))
72+
73+
By("Waiting for external-secrets-operator controller-manager pod to be ready")
74+
Expect(utils.VerifyPodsReadyByPrefix(ctx, clientset, operatorNamespace, []string{
75+
"external-secrets-operator-controller-manager-",
76+
})).To(Succeed())
77+
78+
By("Creating the externalsecrets.openshift.operator.io/cluster CR")
79+
loader.CreateFromFile(testassets.ReadFile, externalSecrets, operatorNamespace)
3580
})
3681

3782
AfterAll(func() {
38-
//TODO: add any clean up required after the tests.
83+
By("Deleting the externalsecrets.openshift.operator.io/cluster CR")
84+
loader.DeleteFromFile(testassets.ReadFile, externalSecrets, operatorNamespace)
85+
86+
err := utils.DeleteAWSSecret(ctx, clientset, awsSecretName, awsSecretRegionName)
87+
Expect(err).NotTo(HaveOccurred(), "failed to delete AWS secret test/e2e")
3988
})
4089

41-
Context("Operator", func() {
42-
It("should run successfully", func() {
43-
var controllerPodName string
44-
45-
By("validating that the controller-manager pod is running as expected")
46-
verifyControllerUp := func() error {
47-
// Get pod name
48-
49-
cmd := exec.Command("oc", "get",
50-
"pods", "-l", "control-plane=controller-manager",
51-
"-o", "go-template={{ range .items }}"+
52-
"{{ if not .metadata.deletionTimestamp }}"+
53-
"{{ .metadata.name }}"+
54-
"{{ \"\\n\" }}{{ end }}{{ end }}",
55-
"-n", namespace,
56-
)
57-
58-
podOutput, err := utils.Run(cmd)
59-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
60-
podNames := utils.GetNonEmptyLines(string(podOutput))
61-
if len(podNames) != 1 {
62-
return fmt.Errorf("expect 1 controller pods running, but got %d", len(podNames))
63-
}
64-
controllerPodName = podNames[0]
65-
ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager"))
66-
67-
// Validate pod status
68-
cmd = exec.Command("oc", "get",
69-
"pods", controllerPodName, "-o", "jsonpath={.status.phase}",
70-
"-n", namespace,
71-
)
72-
status, err := utils.Run(cmd)
73-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
74-
if string(status) != "Running" {
75-
return fmt.Errorf("controller pod in %s status", status)
76-
}
77-
return nil
78-
}
79-
EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed())
80-
})
90+
BeforeEach(func() {
91+
By("Verifying ESO pods are running and ready")
92+
Expect(utils.VerifyPodsReadyByPrefix(ctx, clientset, operandNamespace, []string{
93+
"external-secrets-",
94+
"external-secrets-cert-controller-",
95+
"external-secrets-webhook-",
96+
})).To(Succeed())
97+
})
98+
99+
It("should create secrets mentioned in ExternalSecret using the referenced SecretStore", func() {
100+
expectedSecretValue, err := utils.ReadExpectedSecretValue(expectedSecretValueFile)
101+
Expect(err).To(Succeed())
102+
103+
By("Creating kubernetes secret to be used in PushSecret")
104+
secretsAssetFunc := utils.ReplacePatternInAsset("${SECRET_VALUE}", base64.StdEncoding.EncodeToString(expectedSecretValue))
105+
loader.CreateFromFile(secretsAssetFunc, awsSecretToPushFile, operandNamespace)
106+
defer loader.DeleteFromFile(testassets.ReadFile, awsSecretToPushFile, operandNamespace)
107+
108+
By("Creating SecretStore")
109+
loader.CreateFromFile(testassets.ReadFile, secretStoreFile, operandNamespace)
110+
defer loader.DeleteFromFile(testassets.ReadFile, secretStoreFile, operandNamespace)
111+
112+
By("Waiting for SecretStore to become Ready")
113+
Expect(utils.WaitForESOResourceReady(ctx, dynamicClient,
114+
schema.GroupVersionResource{
115+
Group: "external-secrets.io",
116+
Version: "v1beta1",
117+
Resource: "clustersecretstores",
118+
},
119+
"", "aws-secret-store", time.Minute,
120+
)).To(Succeed())
121+
122+
By("Creating PushSecret")
123+
assetFunc := utils.ReplacePatternInAsset("${AWS_SECRET_KEY_NAME}", awsSecretName)
124+
loader.CreateFromFile(assetFunc, pushSecretFile, operandNamespace)
125+
defer loader.DeleteFromFile(testassets.ReadFile, pushSecretFile, operandNamespace)
126+
127+
By("Waiting for PushSecret to become Ready")
128+
Expect(utils.WaitForESOResourceReady(ctx, dynamicClient,
129+
schema.GroupVersionResource{
130+
Group: "external-secrets.io",
131+
Version: "v1alpha1",
132+
Resource: "pushsecrets",
133+
},
134+
operandNamespace, "aws-push-secret", time.Minute,
135+
)).To(Succeed())
136+
137+
By("Creating ExternalSecret")
138+
loader.CreateFromFile(assetFunc, externalSecretFile, operandNamespace)
139+
defer loader.DeleteFromFile(testassets.ReadFile, externalSecretFile, operandNamespace)
140+
141+
By("Waiting for ExternalSecret to become Ready")
142+
Expect(utils.WaitForESOResourceReady(ctx, dynamicClient,
143+
schema.GroupVersionResource{
144+
Group: "external-secrets.io",
145+
Version: "v1beta1",
146+
Resource: "externalsecrets",
147+
},
148+
operandNamespace, "aws-external-secret", time.Minute,
149+
)).To(Succeed())
150+
151+
By("Waiting for target secret to be created with expected data")
152+
Eventually(func(g Gomega) {
153+
secret, err := loader.KubeClient.CoreV1().Secrets(operandNamespace).Get(ctx, "aws-secret", metav1.GetOptions{})
154+
g.Expect(err).NotTo(HaveOccurred(), "should get aws-secret from namespace %s", operandNamespace)
155+
156+
val, ok := secret.Data["aws_secret_access_key"]
157+
g.Expect(ok).To(BeTrue(), "aws_secret_access_key should be present in secret %s", secret.Name)
158+
159+
g.Expect(val).To(Equal(expectedSecretValue), "aws_secret_access_key does not match expected value")
160+
}, time.Minute, 10*time.Second).Should(Succeed())
81161
})
82162
})
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: external-secrets.io/v1beta1
2+
kind: ExternalSecret
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: cluster
6+
app.kubernetes.io/managed-by: external-secrets-operator-e2e
7+
name: aws-external-secret
8+
namespace: external-secrets
9+
spec:
10+
refreshInterval: 1h
11+
secretStoreRef:
12+
name: aws-secret-store
13+
kind: ClusterSecretStore
14+
target:
15+
name: aws-secret
16+
creationPolicy: Owner
17+
data:
18+
- secretKey: aws_secret_access_key # This is the key in the Kubernetes Secret
19+
remoteRef:
20+
key: "${AWS_SECRET_KEY_NAME}" # This is the name of the secret in AWS Secrets Manager
21+
property: aws_secret_access_key # This is the key inside the AWS secret JSON
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: aws-k8s-push-secret
6+
app.kubernetes.io/managed-by: external-secrets-operator-e2e
7+
name: aws-k8s-push-secret
8+
namespace: external-secrets
9+
data:
10+
aws_secret_access_key: ${SECRET_VALUE}
11+
type: Opaque

0 commit comments

Comments
 (0)