conjur.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 conjur
  14. import (
  15. // nolint
  16. . "github.com/onsi/ginkgo/v2"
  17. "github.com/external-secrets/external-secrets-e2e/framework"
  18. "github.com/external-secrets/external-secrets-e2e/framework/addon"
  19. "github.com/external-secrets/external-secrets-e2e/suites/provider/cases/common"
  20. )
  21. const (
  22. withTokenAuth = "with apikey auth"
  23. withJWTK8s = "with jwt k8s provider"
  24. withJWTK8sHostID = "with jwt k8s hostid provider"
  25. )
  26. var _ = Describe("[conjur]", Label("conjur"), Ordered, func() {
  27. f := framework.New("eso-conjur")
  28. conjur := addon.NewConjur()
  29. prov := newConjurProvider(f, conjur)
  30. BeforeAll(func() {
  31. addon.InstallGlobalAddon(conjur)
  32. })
  33. DescribeTable("sync secrets",
  34. framework.TableFuncWithExternalSecret(f, prov),
  35. // use api key auth
  36. framework.Compose(withTokenAuth, f, common.FindByName, useApiKeyAuth(prov)),
  37. framework.Compose(withTokenAuth, f, common.FindByNameAndRewrite, useApiKeyAuth(prov)),
  38. framework.Compose(withTokenAuth, f, common.FindByTag, useApiKeyAuth(prov)),
  39. framework.Compose(withTokenAuth, f, common.SimpleDataSync, useApiKeyAuth(prov)),
  40. framework.Compose(withTokenAuth, f, common.SyncWithoutTargetName, useApiKeyAuth(prov)),
  41. framework.Compose(withTokenAuth, f, common.JSONDataFromSync, useApiKeyAuth(prov)),
  42. framework.Compose(withTokenAuth, f, common.JSONDataFromRewrite, useApiKeyAuth(prov)),
  43. framework.Compose(withTokenAuth, f, common.JSONDataWithProperty, useApiKeyAuth(prov)),
  44. framework.Compose(withTokenAuth, f, common.JSONDataWithTemplate, useApiKeyAuth(prov)),
  45. framework.Compose(withTokenAuth, f, common.DataPropertyDockerconfigJSON, useApiKeyAuth(prov)),
  46. framework.Compose(withTokenAuth, f, common.JSONDataWithoutTargetName, useApiKeyAuth(prov)),
  47. framework.Compose(withTokenAuth, f, common.DecodingPolicySync, useApiKeyAuth(prov)),
  48. framework.Compose(withTokenAuth, f, common.JSONDataWithTemplateFromLiteral, useApiKeyAuth(prov)),
  49. framework.Compose(withTokenAuth, f, common.TemplateFromConfigmaps, useApiKeyAuth(prov)),
  50. framework.Compose(withTokenAuth, f, common.SSHKeySync, useApiKeyAuth(prov)),
  51. framework.Compose(withTokenAuth, f, common.SSHKeySyncDataProperty, useApiKeyAuth(prov)),
  52. framework.Compose(withTokenAuth, f, common.DockerJSONConfig, useApiKeyAuth(prov)),
  53. framework.Compose(withTokenAuth, f, common.NestedJSONWithGJSON, useApiKeyAuth(prov)),
  54. // use jwt k8s provider
  55. framework.Compose(withJWTK8s, f, common.FindByName, useJWTK8sProvider(prov)),
  56. framework.Compose(withJWTK8s, f, common.FindByNameAndRewrite, useJWTK8sProvider(prov)),
  57. framework.Compose(withJWTK8s, f, common.FindByTag, useJWTK8sProvider(prov)),
  58. framework.Compose(withJWTK8s, f, common.SimpleDataSync, useJWTK8sProvider(prov)),
  59. framework.Compose(withJWTK8s, f, common.SyncWithoutTargetName, useJWTK8sProvider(prov)),
  60. framework.Compose(withJWTK8s, f, common.JSONDataFromSync, useJWTK8sProvider(prov)),
  61. framework.Compose(withJWTK8s, f, common.JSONDataFromRewrite, useJWTK8sProvider(prov)),
  62. // use jwt k8s hostid provider
  63. framework.Compose(withJWTK8sHostID, f, common.FindByName, useJWTK8sHostIDProvider(prov)),
  64. framework.Compose(withJWTK8sHostID, f, common.FindByNameAndRewrite, useJWTK8sHostIDProvider(prov)),
  65. framework.Compose(withJWTK8sHostID, f, common.FindByTag, useJWTK8sHostIDProvider(prov)),
  66. framework.Compose(withJWTK8sHostID, f, common.SimpleDataSync, useJWTK8sHostIDProvider(prov)),
  67. framework.Compose(withJWTK8sHostID, f, common.SyncWithoutTargetName, useJWTK8sHostIDProvider(prov)),
  68. framework.Compose(withJWTK8sHostID, f, common.JSONDataFromSync, useJWTK8sHostIDProvider(prov)),
  69. framework.Compose(withJWTK8sHostID, f, common.JSONDataFromRewrite, useJWTK8sHostIDProvider(prov)),
  70. )
  71. })
  72. func useApiKeyAuth(prov *conjurProvider) func(tc *framework.TestCase) {
  73. return func(tc *framework.TestCase) {
  74. prov.CreateApiKeyStore()
  75. tc.ExternalSecret.Spec.SecretStoreRef.Name = defaultStoreName
  76. }
  77. }
  78. func useJWTK8sProvider(prov *conjurProvider) func(tc *framework.TestCase) {
  79. return func(tc *framework.TestCase) {
  80. prov.CreateJWTK8sStore()
  81. tc.ExternalSecret.Spec.SecretStoreRef.Name = jwtK8sProviderName
  82. }
  83. }
  84. func useJWTK8sHostIDProvider(prov *conjurProvider) func(tc *framework.TestCase) {
  85. return func(tc *framework.TestCase) {
  86. prov.CreateJWTK8sHostIDStore()
  87. tc.ExternalSecret.Spec.SecretStoreRef.Name = jwtK8sHostIDProviderName
  88. }
  89. }