Skip to content

Commit

Permalink
Include more integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alvneiayu committed Sep 22, 2022
1 parent 6678614 commit 7bcc914
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion integration/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ var _ = Describe("create", func() {
}, Timeout, PollingInterval).Should(WithTransform(getFirstOwnerName, Equal(ss.GetName())))
})
})
})

Context("With secret being deleted", func() {
Describe("Secret Recreation", func() {
Context("With owned secret", func() {
JustBeforeEach(func() {
Eventually(func() (*v1.Secret, error) {
return c.Secrets(ns).Get(ctx, secretName, metav1.GetOptions{})
Expand All @@ -293,6 +295,53 @@ var _ = Describe("create", func() {
}, Timeout, PollingInterval).Should(WithTransform(getFirstOwnerName, Equal(ss.GetName())))
})
})

Context("With unowned secret with managed annotation", func() {
BeforeEach(func() {
s.Annotations = map[string]string{
ssv1alpha1.SealedSecretManagedAnnotation: "true",
}
c.Secrets(ns).Create(ctx, s, metav1.CreateOptions{})
})
JustBeforeEach(func() {
err:= c.Secrets(ns).Delete(ctx, secretName, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
})
It("should recreate the secret", func() {
expected := map[string][]byte{
"foo": []byte("bar"),
}
Eventually(func() (*v1.Secret, error) {
return c.Secrets(ns).Get(ctx, secretName, metav1.GetOptions{})
}, Timeout, PollingInterval).Should(WithTransform(getData, Equal(expected)))
Eventually(func() (*v1.EventList, error) {
return c.Events(ns).Search(scheme.Scheme, ss)
}, Timeout, PollingInterval).Should(
containEventWithReason(Equal("Unsealed")),
)
Eventually(func() (*v1.Secret, error) {
return c.Secrets(ns).Get(ctx, secretName, metav1.GetOptions{})
}, Timeout, PollingInterval).Should(WithTransform(getFirstOwnerName, Equal(ss.GetName())))
})
})

Context("With unowned secret without managed annotation", func() {
BeforeEach(func() {
s.Annotations = map[string]string{
}
c.Secrets(ns).Create(ctx, s, metav1.CreateOptions{})
})
JustBeforeEach(func() {
err:= c.Secrets(ns).Delete(ctx, secretName, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
})
It("should not recreate the secret", func() {
Consistently(func() error {
_, err := c.Secrets(ns).Get(ctx, secretName, metav1.GetOptions{})
return err
}).Should(WithTransform(errors.IsNotFound, Equal(true)))
})
})
})

Describe("Same name, wrong key", func() {
Expand Down

0 comments on commit 7bcc914

Please sign in to comment.