secretsmanager_managed.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package aws
  13. import (
  14. // nolint
  15. . "github.com/onsi/ginkgo/v2"
  16. esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
  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/suite/common"
  20. )
  21. const (
  22. withReferencedIRSA = "with referenced IRSA"
  23. withMountedIRSA = "with mounted IRSA"
  24. )
  25. // here we use the global eso instance
  26. // that uses the service account in the default namespace
  27. // which was created by terraform.
  28. var _ = Describe("[awsmanaged] IRSA via referenced service account", Label("aws", "secretsmanager", "managed"), func() {
  29. f := framework.New("eso-aws-managed")
  30. prov := NewFromEnv(f)
  31. DescribeTable("sync secrets",
  32. framework.TableFunc(f,
  33. prov),
  34. framework.Compose(withReferencedIRSA, f, common.SimpleDataSync, useClusterSecretStore(prov)),
  35. framework.Compose(withReferencedIRSA, f, common.NestedJSONWithGJSON, useClusterSecretStore(prov)),
  36. framework.Compose(withReferencedIRSA, f, common.JSONDataFromSync, useClusterSecretStore(prov)),
  37. framework.Compose(withReferencedIRSA, f, common.JSONDataWithProperty, useClusterSecretStore(prov)),
  38. framework.Compose(withReferencedIRSA, f, common.JSONDataWithTemplate, useClusterSecretStore(prov)),
  39. framework.Compose(withReferencedIRSA, f, common.DockerJSONConfig, useClusterSecretStore(prov)),
  40. framework.Compose(withReferencedIRSA, f, common.DataPropertyDockerconfigJSON, useClusterSecretStore(prov)),
  41. framework.Compose(withReferencedIRSA, f, common.SSHKeySync, useClusterSecretStore(prov)),
  42. framework.Compose(withReferencedIRSA, f, common.SSHKeySyncDataProperty, useClusterSecretStore(prov)),
  43. framework.Compose(withReferencedIRSA, f, common.SyncWithoutTargetName, useClusterSecretStore(prov)),
  44. framework.Compose(withReferencedIRSA, f, common.JSONDataWithoutTargetName, useClusterSecretStore(prov)),
  45. )
  46. })
  47. // here we create a central eso instance in the default namespace
  48. // that mounts the service account which was created by terraform.
  49. var _ = Describe("[awsmanaged] with mounted IRSA", Label("aws", "secretsmanager", "managed"), func() {
  50. f := framework.New("eso-aws-managed")
  51. prov := NewFromEnv(f)
  52. // each test case gets its own ESO instance
  53. BeforeEach(func() {
  54. f.Install(addon.NewESO(
  55. addon.WithControllerClass(f.BaseName),
  56. addon.WithServiceAccount(prov.ServiceAccountName),
  57. addon.WithReleaseName(f.Namespace.Name),
  58. addon.WithNamespace("default"),
  59. ))
  60. })
  61. DescribeTable("sync secrets",
  62. framework.TableFunc(f,
  63. prov),
  64. framework.Compose(withMountedIRSA, f, common.SimpleDataSync, useMountedIRSAStore(prov)),
  65. framework.Compose(withMountedIRSA, f, common.NestedJSONWithGJSON, useMountedIRSAStore(prov)),
  66. framework.Compose(withMountedIRSA, f, common.JSONDataFromSync, useMountedIRSAStore(prov)),
  67. framework.Compose(withMountedIRSA, f, common.JSONDataWithProperty, useMountedIRSAStore(prov)),
  68. framework.Compose(withMountedIRSA, f, common.JSONDataWithTemplate, useMountedIRSAStore(prov)),
  69. framework.Compose(withMountedIRSA, f, common.DockerJSONConfig, useMountedIRSAStore(prov)),
  70. framework.Compose(withMountedIRSA, f, common.DataPropertyDockerconfigJSON, useMountedIRSAStore(prov)),
  71. framework.Compose(withMountedIRSA, f, common.SSHKeySync, useMountedIRSAStore(prov)),
  72. framework.Compose(withMountedIRSA, f, common.SSHKeySyncDataProperty, useMountedIRSAStore(prov)),
  73. framework.Compose(withMountedIRSA, f, common.SyncWithoutTargetName, useMountedIRSAStore(prov)),
  74. framework.Compose(withMountedIRSA, f, common.JSONDataWithoutTargetName, useMountedIRSAStore(prov)),
  75. )
  76. })
  77. func useClusterSecretStore(prov *SMProvider) func(*framework.TestCase) {
  78. return func(tc *framework.TestCase) {
  79. tc.ExternalSecret.Spec.SecretStoreRef.Kind = esv1alpha1.ClusterSecretStoreKind
  80. tc.ExternalSecret.Spec.SecretStoreRef.Name = prov.ReferencedIRSAStoreName()
  81. }
  82. }
  83. func useMountedIRSAStore(prov *SMProvider) func(*framework.TestCase) {
  84. return func(tc *framework.TestCase) {
  85. tc.ExternalSecret.Spec.SecretStoreRef.Kind = esv1alpha1.SecretStoreKind
  86. tc.ExternalSecret.Spec.SecretStoreRef.Name = prov.MountedIRSAStoreName()
  87. }
  88. }