vault.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 vault
  12. import (
  13. // nolint
  14. . "github.com/onsi/ginkgo/v2"
  15. "github.com/external-secrets/external-secrets/e2e/framework"
  16. "github.com/external-secrets/external-secrets/e2e/suite/common"
  17. )
  18. const (
  19. withTokenAuth = "with token auth"
  20. withCertAuth = "with cert auth"
  21. withApprole = "with approle auth"
  22. withV1 = "with v1 provider"
  23. withJWT = "with jwt provider"
  24. withK8s = "with kubernetes provider"
  25. )
  26. var _ = Describe("[vault]", Label("vault"), func() {
  27. f := framework.New("eso-vault")
  28. prov := newVaultProvider(f)
  29. DescribeTable("sync secrets",
  30. framework.TableFunc(f, prov),
  31. // uses token auth
  32. framework.Compose(withTokenAuth, f, common.JSONDataFromSync, useTokenAuth),
  33. framework.Compose(withTokenAuth, f, common.JSONDataWithProperty, useTokenAuth),
  34. framework.Compose(withTokenAuth, f, common.JSONDataWithTemplate, useTokenAuth),
  35. framework.Compose(withTokenAuth, f, common.DataPropertyDockerconfigJSON, useTokenAuth),
  36. framework.Compose(withTokenAuth, f, common.JSONDataWithoutTargetName, useTokenAuth),
  37. // use cert auth
  38. framework.Compose(withCertAuth, f, common.JSONDataFromSync, useCertAuth),
  39. framework.Compose(withCertAuth, f, common.JSONDataWithProperty, useCertAuth),
  40. framework.Compose(withCertAuth, f, common.JSONDataWithTemplate, useCertAuth),
  41. framework.Compose(withCertAuth, f, common.DataPropertyDockerconfigJSON, useCertAuth),
  42. framework.Compose(withCertAuth, f, common.JSONDataWithoutTargetName, useCertAuth),
  43. // use approle auth
  44. framework.Compose(withApprole, f, common.JSONDataFromSync, useApproleAuth),
  45. framework.Compose(withApprole, f, common.JSONDataWithProperty, useApproleAuth),
  46. framework.Compose(withApprole, f, common.JSONDataWithTemplate, useApproleAuth),
  47. framework.Compose(withApprole, f, common.DataPropertyDockerconfigJSON, useApproleAuth),
  48. framework.Compose(withApprole, f, common.JSONDataWithoutTargetName, useApproleAuth),
  49. // use v1 provider
  50. framework.Compose(withV1, f, common.JSONDataFromSync, useV1Provider),
  51. framework.Compose(withV1, f, common.JSONDataWithProperty, useV1Provider),
  52. framework.Compose(withV1, f, common.JSONDataWithTemplate, useV1Provider),
  53. framework.Compose(withV1, f, common.DataPropertyDockerconfigJSON, useV1Provider),
  54. framework.Compose(withV1, f, common.JSONDataWithoutTargetName, useV1Provider),
  55. // use jwt provider
  56. framework.Compose(withJWT, f, common.JSONDataFromSync, useJWTProvider),
  57. framework.Compose(withJWT, f, common.JSONDataWithProperty, useJWTProvider),
  58. framework.Compose(withJWT, f, common.JSONDataWithTemplate, useJWTProvider),
  59. framework.Compose(withJWT, f, common.DataPropertyDockerconfigJSON, useJWTProvider),
  60. framework.Compose(withJWT, f, common.JSONDataWithoutTargetName, useJWTProvider),
  61. // use kubernetes provider
  62. framework.Compose(withK8s, f, common.JSONDataFromSync, useKubernetesProvider),
  63. framework.Compose(withK8s, f, common.JSONDataWithProperty, useKubernetesProvider),
  64. framework.Compose(withK8s, f, common.JSONDataWithTemplate, useKubernetesProvider),
  65. framework.Compose(withK8s, f, common.DataPropertyDockerconfigJSON, useKubernetesProvider),
  66. framework.Compose(withK8s, f, common.JSONDataWithoutTargetName, useKubernetesProvider),
  67. )
  68. })
  69. func useTokenAuth(tc *framework.TestCase) {
  70. tc.ExternalSecret.Spec.SecretStoreRef.Name = tc.Framework.Namespace.Name
  71. }
  72. func useCertAuth(tc *framework.TestCase) {
  73. tc.ExternalSecret.Spec.SecretStoreRef.Name = certAuthProviderName
  74. }
  75. func useApproleAuth(tc *framework.TestCase) {
  76. tc.ExternalSecret.Spec.SecretStoreRef.Name = appRoleAuthProviderName
  77. }
  78. func useV1Provider(tc *framework.TestCase) {
  79. tc.ExternalSecret.Spec.SecretStoreRef.Name = kvv1ProviderName
  80. }
  81. func useJWTProvider(tc *framework.TestCase) {
  82. tc.ExternalSecret.Spec.SecretStoreRef.Name = jwtProviderName
  83. }
  84. func useKubernetesProvider(tc *framework.TestCase) {
  85. tc.ExternalSecret.Spec.SecretStoreRef.Name = kubernetesProviderName
  86. }