vault.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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"
  15. // nolint
  16. . "github.com/onsi/ginkgo/extensions/table"
  17. "github.com/external-secrets/external-secrets/e2e/framework"
  18. "github.com/external-secrets/external-secrets/e2e/suite/common"
  19. )
  20. var _ = Describe("[vault] ", func() {
  21. f := framework.New("eso-vault")
  22. DescribeTable("sync secrets",
  23. framework.TableFunc(f,
  24. newVaultProvider(f)),
  25. // uses token auth
  26. compose("with token auth", f, common.JSONDataFromSync, useTokenAuth),
  27. compose("with token auth", f, common.JSONDataWithProperty, useTokenAuth),
  28. compose("with token auth", f, common.JSONDataWithTemplate, useTokenAuth),
  29. compose("with token auth", f, common.DataPropertyDockerconfigJSON, useTokenAuth),
  30. // use cert auth
  31. compose("with cert auth", f, common.JSONDataFromSync, useCertAuth),
  32. compose("with cert auth", f, common.JSONDataWithProperty, useCertAuth),
  33. compose("with cert auth", f, common.JSONDataWithTemplate, useCertAuth),
  34. compose("with cert auth", f, common.DataPropertyDockerconfigJSON, useCertAuth),
  35. // use approle auth
  36. compose("with appRole auth", f, common.JSONDataFromSync, useApproleAuth),
  37. compose("with appRole auth", f, common.JSONDataWithProperty, useApproleAuth),
  38. compose("with appRole auth", f, common.JSONDataWithTemplate, useApproleAuth),
  39. compose("with appRole auth", f, common.DataPropertyDockerconfigJSON, useApproleAuth),
  40. // use v1 provider
  41. compose("with v1 kv provider", f, common.JSONDataFromSync, useV1Provider),
  42. compose("with v1 kv provider", f, common.JSONDataWithProperty, useV1Provider),
  43. compose("with v1 kv provider", f, common.JSONDataWithTemplate, useV1Provider),
  44. compose("with v1 kv provider", f, common.DataPropertyDockerconfigJSON, useV1Provider),
  45. // use jwt provider
  46. compose("with jwt provider", f, common.JSONDataFromSync, useJWTProvider),
  47. compose("with jwt provider", f, common.JSONDataWithProperty, useJWTProvider),
  48. compose("with jwt provider", f, common.JSONDataWithTemplate, useJWTProvider),
  49. compose("with jwt provider", f, common.DataPropertyDockerconfigJSON, useJWTProvider),
  50. // use kubernetes provider
  51. compose("with kubernetes provider", f, common.JSONDataFromSync, useKubernetesProvider),
  52. compose("with kubernetes provider", f, common.JSONDataWithProperty, useKubernetesProvider),
  53. compose("with kubernetes provider", f, common.JSONDataWithTemplate, useKubernetesProvider),
  54. compose("with kubernetes provider", f, common.DataPropertyDockerconfigJSON, useKubernetesProvider),
  55. )
  56. })
  57. func compose(descAppend string, f *framework.Framework, fn func(f *framework.Framework) (string, func(*framework.TestCase)), tweaks ...func(*framework.TestCase)) TableEntry {
  58. desc, tfn := fn(f)
  59. tweaks = append(tweaks, tfn)
  60. te := Entry(desc + " " + descAppend)
  61. // need to convert []func to []interface{}
  62. ifs := make([]interface{}, len(tweaks))
  63. for i := 0; i < len(tweaks); i++ {
  64. ifs[i] = tweaks[i]
  65. }
  66. te.Parameters = ifs
  67. return te
  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. }