mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 07:28:06 +00:00
Checking that all secrets are created before running tests
This commit is contained in:
@@ -26,15 +26,30 @@ var _ = Describe("Onepassword Operator e2e", Ordered, func() {
|
|||||||
operator.BuildOperatorImage()
|
operator.BuildOperatorImage()
|
||||||
kind.LoadImageToKind(operatorImageName)
|
kind.LoadImageToKind(operatorImageName)
|
||||||
|
|
||||||
By("Create Connect credentials secret")
|
By("Create Connect 'op-credentials' credentials secret")
|
||||||
kube.CreateOpCredentialsSecret()
|
kube.CreateOpCredentialsSecret()
|
||||||
|
|
||||||
By("Create onepassword-token secret")
|
By("Checking Connect 'op-credentials' secret is created")
|
||||||
|
Eventually(func() {
|
||||||
|
kube.CheckSecretExists("op-credentials")
|
||||||
|
}, defaultTimeout, defaultInterval).Should(Succeed())
|
||||||
|
|
||||||
|
By("Create 'onepassword-token' secret")
|
||||||
kube.CreateSecretFromEnvVar("OP_CONNECT_TOKEN", "onepassword-token")
|
kube.CreateSecretFromEnvVar("OP_CONNECT_TOKEN", "onepassword-token")
|
||||||
|
|
||||||
By("Create onepassword-service-account-token secret")
|
By("Checking 'onepassword-token' secret is created")
|
||||||
|
Eventually(func() {
|
||||||
|
kube.CheckSecretExists("onepassword-token")
|
||||||
|
}, defaultTimeout, defaultInterval).Should(Succeed())
|
||||||
|
|
||||||
|
By("Create 'onepassword-service-account-token' secret")
|
||||||
kube.CreateSecretFromEnvVar("OP_SERVICE_ACCOUNT_TOKEN", "onepassword-service-account-token")
|
kube.CreateSecretFromEnvVar("OP_SERVICE_ACCOUNT_TOKEN", "onepassword-service-account-token")
|
||||||
|
|
||||||
|
By("Checking 'onepassword-service-account-token' secret is created")
|
||||||
|
Eventually(func() {
|
||||||
|
kube.CheckSecretExists("onepassword-service-account-token")
|
||||||
|
}, defaultTimeout, defaultInterval).Should(Succeed())
|
||||||
|
|
||||||
operator.DeployOperator()
|
operator.DeployOperator()
|
||||||
operator.WaitingForOperatorPod()
|
operator.WaitingForOperatorPod()
|
||||||
})
|
})
|
||||||
@@ -64,14 +79,11 @@ func runCommonTestCases() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
yamlPath := filepath.Join(root, "test", "e2e", "manifests", "secret.yaml")
|
yamlPath := filepath.Join(root, "test", "e2e", "manifests", "secret.yaml")
|
||||||
_, err = system.Run("kubectl", "apply", "-f", yamlPath)
|
kube.Apply(yamlPath)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
|
|
||||||
By("Waiting for secret to be created")
|
By("Waiting for secret to be created")
|
||||||
Eventually(func(g Gomega) {
|
Eventually(func() {
|
||||||
output, err := system.Run("kubectl", "get", "secret", "login", "-o", "jsonpath={.metadata.name}")
|
kube.CheckSecretExists("login")
|
||||||
g.Expect(err).NotTo(HaveOccurred())
|
|
||||||
g.Expect(output).To(Equal("login"))
|
|
||||||
}, defaultTimeout, defaultInterval).Should(Succeed())
|
}, defaultTimeout, defaultInterval).Should(Succeed())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,17 @@ func DeleteSecret(name string) {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CheckSecretExists(name string) {
|
||||||
|
output, err := system.Run("kubectl", "get", "secret", name, "-o", "jsonpath={.metadata.name}")
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(output).To(Equal(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Apply(yamlPath string) {
|
||||||
|
_, err := system.Run("kubectl", "apply", "-f", yamlPath)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
func SetContextNamespace(namespace string) {
|
func SetContextNamespace(namespace string) {
|
||||||
By("Set namespace to " + namespace)
|
By("Set namespace to " + namespace)
|
||||||
_, err := system.Run("kubectl", "config", "set-context", "--current", "--namespace="+namespace)
|
_, err := system.Run("kubectl", "config", "set-context", "--current", "--namespace="+namespace)
|
||||||
|
Reference in New Issue
Block a user