package e2e import ( "os" "path/filepath" "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/1Password/onepassword-operator/test/cmd" "github.com/1Password/onepassword-operator/test/testhelper/kind" "github.com/1Password/onepassword-operator/test/testhelper/kube" "github.com/1Password/onepassword-operator/test/testhelper/operator" ) const ( operatorImageName = "1password/onepassword-operator:latest" defaultInterval = 1 * time.Second defaultTimeout = 30 * time.Second ) var _ = Describe("Onepassword Operator e2e", Ordered, func() { BeforeAll(func() { operator.BuildOperatorImage() kind.LoadImageToKind(operatorImageName) By("create Connect credentials secret") kube.CreateOpCredentialsSecret() By("create onepassword-token secret") kube.CreateSecretFromEnvVar("OP_CONNECT_TOKEN", "onepassword-token") By("create onepassword-service-account-token secret") kube.CreateSecretFromEnvVar("OP_SERVICE_ACCOUNT_TOKEN", "onepassword-service-account-token") operator.DeployOperator() }) Context("Use the operator with Connect", func() { BeforeAll(func() { kube.PatchOperatorManageConnect() }) runCommonTestCases() }) Context("Use the operator with Service Account", func() { BeforeAll(func() { kube.PatchOperatorToUseServiceAccount() }) runCommonTestCases() }) }) func runCommonTestCases() { It("Should create secret from manifest file", func() { By("creating secret") wd, err := os.Getwd() Expect(err).NotTo(HaveOccurred()) yamlPath := filepath.Join(wd, "manifests", "secret.yaml") _, err = cmd.Run("kubectl", "apply", "-f", yamlPath) Expect(err).NotTo(HaveOccurred()) By("waiting for secret to be created") Eventually(func(g Gomega) { output, err := cmd.Run("kubectl", "get", "secret", "login", "-o", "jsonpath={.metadata.name}") g.Expect(err).NotTo(HaveOccurred()) g.Expect(output).To(Equal("login")) }, defaultTimeout, defaultInterval).Should(Succeed()) }) }