gcpmanaged.go 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. limitations under the License.
  10. */
  11. package gcpmanaged
  12. import (
  13. "os"
  14. // nolint
  15. . "github.com/onsi/ginkgo"
  16. // nolint
  17. . "github.com/onsi/ginkgo/extensions/table"
  18. // nolint
  19. // . "github.com/onsi/gomega"
  20. esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
  21. "github.com/external-secrets/external-secrets/e2e/framework"
  22. "github.com/external-secrets/external-secrets/e2e/suite/common"
  23. "github.com/external-secrets/external-secrets/e2e/suite/gcp"
  24. )
  25. const (
  26. withPodID = "sync secrets with pod identity"
  27. withSpecifcSA = "sync secrets with specificSA identity"
  28. )
  29. var _ = Describe("[gcpmanaged] ", func() {
  30. if os.Getenv("FOCUS") == "gcpmanaged" {
  31. f := framework.New("eso-gcp-managed")
  32. projectID := os.Getenv("GCP_PROJECT_ID")
  33. clusterLocation := "europe-west1-b"
  34. clusterName := "test-cluster"
  35. serviceAccountName := os.Getenv("GCP_KSA_NAME")
  36. serviceAccountNamespace := "default"
  37. prov := &gcp.GcpProvider{}
  38. if projectID != "" {
  39. prov = gcp.NewgcpProvider(f, "", projectID, clusterLocation, clusterName, serviceAccountName, serviceAccountNamespace)
  40. }
  41. DescribeTable("sync secrets",
  42. framework.TableFunc(f,
  43. prov),
  44. // uses pod id
  45. framework.Compose(withPodID, f, common.SimpleDataSync, usePodIDESReference),
  46. framework.Compose(withPodID, f, common.JSONDataWithProperty, usePodIDESReference),
  47. framework.Compose(withPodID, f, common.JSONDataFromSync, usePodIDESReference),
  48. framework.Compose(withPodID, f, common.NestedJSONWithGJSON, usePodIDESReference),
  49. framework.Compose(withPodID, f, common.JSONDataWithTemplate, usePodIDESReference),
  50. framework.Compose(withPodID, f, common.DockerJSONConfig, usePodIDESReference),
  51. framework.Compose(withPodID, f, common.DataPropertyDockerconfigJSON, usePodIDESReference),
  52. framework.Compose(withPodID, f, common.SSHKeySync, usePodIDESReference),
  53. framework.Compose(withPodID, f, common.SSHKeySyncDataProperty, usePodIDESReference),
  54. framework.Compose(withPodID, f, common.SyncWithoutTargetName, usePodIDESReference),
  55. framework.Compose(withPodID, f, common.JSONDataWithoutTargetName, usePodIDESReference),
  56. // uses specific sa
  57. framework.Compose(withSpecifcSA, f, common.JSONDataFromSync, useSpecifcSAESReference),
  58. framework.Compose(withSpecifcSA, f, common.JSONDataWithProperty, useSpecifcSAESReference),
  59. framework.Compose(withSpecifcSA, f, common.JSONDataFromSync, useSpecifcSAESReference),
  60. framework.Compose(withSpecifcSA, f, common.NestedJSONWithGJSON, useSpecifcSAESReference),
  61. framework.Compose(withSpecifcSA, f, common.JSONDataWithTemplate, useSpecifcSAESReference),
  62. framework.Compose(withSpecifcSA, f, common.DockerJSONConfig, useSpecifcSAESReference),
  63. framework.Compose(withSpecifcSA, f, common.DataPropertyDockerconfigJSON, useSpecifcSAESReference),
  64. framework.Compose(withSpecifcSA, f, common.SSHKeySync, useSpecifcSAESReference),
  65. framework.Compose(withSpecifcSA, f, common.SSHKeySyncDataProperty, useSpecifcSAESReference),
  66. framework.Compose(withSpecifcSA, f, common.SyncWithoutTargetName, useSpecifcSAESReference),
  67. framework.Compose(withSpecifcSA, f, common.JSONDataWithoutTargetName, useSpecifcSAESReference),
  68. )
  69. }
  70. })
  71. func usePodIDESReference(tc *framework.TestCase) {
  72. tc.ExternalSecret.Spec.SecretStoreRef.Name = gcp.PodIDSecretStoreName
  73. }
  74. func useSpecifcSAESReference(tc *framework.TestCase) {
  75. tc.ExternalSecret.Spec.SecretStoreRef.Kind = esv1alpha1.ClusterSecretStoreKind
  76. tc.ExternalSecret.Spec.SecretStoreRef.Name = gcp.SpecifcSASecretStoreName
  77. }