secretsmanager.go 4.0 KB

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