azure_cert.go 2.3 KB

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