secretsmanager.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. "github.com/external-secrets/external-secrets-e2e/framework"
  17. awscommon "github.com/external-secrets/external-secrets-e2e/suites/provider/cases/aws"
  18. "github.com/external-secrets/external-secrets-e2e/suites/provider/cases/common"
  19. esapi "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
  20. )
  21. const (
  22. withStaticAuth = "with static auth"
  23. withExtID = "with externalID"
  24. withSessionTags = "with session tags"
  25. )
  26. var _ = Describe("[aws] ", Label("aws", "secretsmanager"), func() {
  27. f := framework.New("eso-aws-sm")
  28. prov := NewFromEnv(f)
  29. DescribeTable("sync secrets",
  30. framework.TableFuncWithExternalSecret(f,
  31. prov),
  32. framework.Compose(withStaticAuth, f, common.SimpleDataSync, useStaticAuth),
  33. framework.Compose(withStaticAuth, f, common.NestedJSONWithGJSON, useStaticAuth),
  34. framework.Compose(withStaticAuth, f, common.JSONDataFromSync, useStaticAuth),
  35. framework.Compose(withStaticAuth, f, common.JSONDataFromRewrite, useStaticAuth),
  36. framework.Compose(withStaticAuth, f, common.JSONDataWithProperty, useStaticAuth),
  37. framework.Compose(withStaticAuth, f, common.JSONDataWithTemplate, useStaticAuth),
  38. framework.Compose(withStaticAuth, f, common.DockerJSONConfig, useStaticAuth),
  39. framework.Compose(withStaticAuth, f, common.DataPropertyDockerconfigJSON, useStaticAuth),
  40. framework.Compose(withStaticAuth, f, common.SSHKeySync, useStaticAuth),
  41. framework.Compose(withStaticAuth, f, common.SSHKeySyncDataProperty, useStaticAuth),
  42. framework.Compose(withStaticAuth, f, common.SyncWithoutTargetName, useStaticAuth),
  43. framework.Compose(withStaticAuth, f, common.JSONDataWithoutTargetName, useStaticAuth),
  44. framework.Compose(withStaticAuth, f, common.FindByName, useStaticAuth),
  45. framework.Compose(withStaticAuth, f, common.FindByNameWithPath, useStaticAuth),
  46. framework.Compose(withStaticAuth, f, common.FindByTag, useStaticAuth),
  47. framework.Compose(withStaticAuth, f, common.FindByTagWithPath, useStaticAuth),
  48. framework.Compose(withStaticAuth, f, common.SyncV1Alpha1, useStaticAuth),
  49. framework.Compose(withStaticAuth, f, common.DeletionPolicyDelete, useStaticAuth),
  50. // referent auth
  51. framework.Compose(withStaticAuth, f, common.SimpleDataSync, useReferentStaticAuth),
  52. // test assume role with external-id and session tags
  53. framework.Compose(withExtID, f, SimpleSyncWithNamespaceTags(prov), useExtIDAuth),
  54. framework.Compose(withSessionTags, f, SimpleSyncWithNamespaceTags(prov), useSessionTagsAuth),
  55. )
  56. })
  57. func useStaticAuth(tc *framework.TestCase) {
  58. tc.ExternalSecret.Spec.SecretStoreRef.Name = awscommon.StaticStoreName
  59. if tc.ExternalSecretV1Alpha1 != nil {
  60. tc.ExternalSecretV1Alpha1.Spec.SecretStoreRef.Name = awscommon.StaticStoreName
  61. }
  62. }
  63. func useExtIDAuth(tc *framework.TestCase) {
  64. tc.ExternalSecret.Spec.SecretStoreRef.Name = awscommon.ExternalIDStoreName
  65. if tc.ExternalSecretV1Alpha1 != nil {
  66. tc.ExternalSecretV1Alpha1.Spec.SecretStoreRef.Name = awscommon.ExternalIDStoreName
  67. }
  68. }
  69. func useSessionTagsAuth(tc *framework.TestCase) {
  70. tc.ExternalSecret.Spec.SecretStoreRef.Name = awscommon.SessionTagsStoreName
  71. if tc.ExternalSecretV1Alpha1 != nil {
  72. tc.ExternalSecretV1Alpha1.Spec.SecretStoreRef.Name = awscommon.SessionTagsStoreName
  73. }
  74. }
  75. func useReferentStaticAuth(tc *framework.TestCase) {
  76. tc.ExternalSecret.Spec.SecretStoreRef.Name = awscommon.ReferentSecretStoreName(tc.Framework)
  77. tc.ExternalSecret.Spec.SecretStoreRef.Kind = esapi.ClusterSecretStoreKind
  78. }