azure_cert.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. limitations under the License.
  10. */
  11. package azure
  12. import (
  13. "fmt"
  14. // nolint
  15. . "github.com/onsi/ginkgo/v2"
  16. v1 "k8s.io/api/core/v1"
  17. // nolint
  18. esv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
  19. "github.com/external-secrets/external-secrets/e2e/framework"
  20. )
  21. // azure keyvault type=cert should get a certificate from the api.
  22. var _ = Describe("[azure]", Label("azure", "keyvault", "cert"), func() {
  23. f := framework.New("eso-azure-certtype")
  24. prov := newFromEnv(f)
  25. var certBytes []byte
  26. var certName string
  27. BeforeEach(func() {
  28. certName = fmt.Sprintf("%s-%s", f.Namespace.Name, "certtest")
  29. prov.CreateCertificate(certName)
  30. certBytes = prov.GetCertificate(certName)
  31. })
  32. AfterEach(func() {
  33. prov.DeleteCertificate(certName)
  34. })
  35. ff := framework.TableFunc(f, prov)
  36. It("should sync keyvault objects with type=cert", func() {
  37. ff(func(tc *framework.TestCase) {
  38. secretKey := "azkv-cert"
  39. tc.ExpectedSecret = &v1.Secret{
  40. Type: v1.SecretTypeOpaque,
  41. Data: map[string][]byte{
  42. secretKey: certBytes,
  43. },
  44. }
  45. tc.ExternalSecret.Spec.Data = []esv1beta1.ExternalSecretData{
  46. {
  47. SecretKey: secretKey,
  48. RemoteRef: esv1beta1.ExternalSecretDataRemoteRef{
  49. Key: "cert/" + certName,
  50. },
  51. },
  52. }
  53. })
  54. })
  55. })