Skip to content

Commit

Permalink
refs #239 Add e2e test case for decrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Jun 2, 2021
1 parent 8c82414 commit ea7a753
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ var _ = Describe("E2E", func() {
})
})
Context("Encrypted data using aws cli", func() {
const (
key = "PASSWORD"
value = "my_password"
var (
key string
value string
)
BeforeEach(func() {
keyID := os.Getenv("KMS_KEY_ID")
Expand All @@ -157,26 +157,43 @@ var _ = Describe("E2E", func() {
key: data,
})
})
It("Secret data should be decrepted", func() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
Expect(setupError).To(BeNil())
res := corev1.Secret{}
err := wait.Poll(1*time.Second, 5*time.Minute, func() (bool, error) {
err := k8sClient.Get(ctx, types.NamespacedName{Namespace: kmsSecret.Namespace, Name: kmsSecret.Name}, &res)
if err != nil {
if apierrors.IsNotFound(err) {
return false, nil
decrypt := func(key, value string) {
It("Secret data should be decrepted", func() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
Expect(setupError).To(BeNil())
res := corev1.Secret{}
err := wait.Poll(1*time.Second, 5*time.Minute, func() (bool, error) {
err := k8sClient.Get(ctx, types.NamespacedName{Namespace: kmsSecret.Namespace, Name: kmsSecret.Name}, &res)
if err != nil {
if apierrors.IsNotFound(err) {
return false, nil
}
klog.Error(err)
return false, err
}
klog.Error(err)
return false, err
}
return true, nil
return true, nil
})
Expect(err).To(BeNil())
val, ok := res.Data[key]
Expect(ok).To(BeTrue())
Expect(string(val)).To(Equal(value))
})
Expect(err).To(BeNil())
val, ok := res.Data[key]
Expect(ok).To(BeTrue())
Expect(string(val)).To(Equal(value))
}
Context("Value is plain text", func() {
key = "api_key"
value = "hogehoge"
decrypt(key, value)
})
Context("Value is yaml object", func() {
key = "api_key"
value = "hoge: fuga"
decrypt(key, value)
})
Context("Value is yaml formatted text", func() {
key = "api_key"
value = "--- hogehoge"
decrypt(key, value)
})
})
})
Expand Down

0 comments on commit ea7a753

Please sign in to comment.