assume_role.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. Copyright © The ESO Authors
  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 aws
  14. import (
  15. "fmt"
  16. v1 "k8s.io/api/core/v1"
  17. "github.com/external-secrets/external-secrets-e2e/framework"
  18. esapi "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  19. )
  20. // This case creates secret with specific tags which are checked by the assumed IAM policy
  21. func SimpleSyncWithNamespaceTags(prov *Provider) func(f *framework.Framework) (string, func(*framework.TestCase)) {
  22. return func(f *framework.Framework) (string, func(*framework.TestCase)) {
  23. return "[common] should sync tagged simple secrets from .Data[]", func(tc *framework.TestCase) {
  24. secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
  25. secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "other")
  26. remoteRefKey1 := f.MakeRemoteRefKey(secretKey1)
  27. remoteRefKey2 := f.MakeRemoteRefKey(secretKey2)
  28. secretValue := "bar"
  29. tc.Secrets = map[string]framework.SecretEntry{
  30. // add specific tags to the secret resource. The assumed role only allows access to those
  31. remoteRefKey1: {Value: secretValue, Tags: map[string]string{"namespace": "e2e-test"}},
  32. remoteRefKey2: {Value: secretValue, Tags: map[string]string{"namespace": "e2e-test"}},
  33. }
  34. tc.ExpectedSecret = &v1.Secret{
  35. Type: v1.SecretTypeOpaque,
  36. Data: map[string][]byte{
  37. secretKey1: []byte(secretValue),
  38. secretKey2: []byte(secretValue),
  39. },
  40. }
  41. tc.ExternalSecret.Spec.Data = []esapi.ExternalSecretData{
  42. {
  43. SecretKey: secretKey1,
  44. RemoteRef: esapi.ExternalSecretDataRemoteRef{
  45. Key: remoteRefKey1,
  46. },
  47. },
  48. {
  49. SecretKey: secretKey2,
  50. RemoteRef: esapi.ExternalSecretDataRemoteRef{
  51. Key: remoteRefKey2,
  52. },
  53. },
  54. }
  55. }
  56. }
  57. }