Parcourir la source

common dockerjson config test

Kian Kordtomeikel il y a 4 ans
Parent
commit
c1ed066c45
2 fichiers modifiés avec 46 ajouts et 0 suppressions
  1. 45 0
      e2e/suite/common/common.go
  2. 1 0
      e2e/suite/gcp/gcp.go

+ 45 - 0
e2e/suite/common/common.go

@@ -228,3 +228,48 @@ func NestedJSONWithGJSON(f *framework.Framework) (string, func(*framework.TestCa
 		}
 	}
 }
+
+// This case creates a secret with a Docker json configuration value.
+// The values from the nested data are extracted using gjson.
+// not supported by: vault.
+func DockerJSONConfig(f *framework.Framework) (string, func(*framework.TestCase)) {
+	return "[specific] should do something I guess but not sure what!", func(tc *framework.TestCase) {
+		cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
+		cloudSecretValue := `{"auths":{"https://index.docker.io/v1/": {"auth": "c3R...zE2"}}}`
+
+		tc.Secrets = map[string]string{
+			cloudSecretName: cloudSecretValue,
+		}
+
+		tc.ExpectedSecret = &v1.Secret{
+			Type: v1.SecretTypeOpaque,
+			Data: map[string][]byte{
+				".dockerconfigjson": []byte(cloudSecretValue),
+			},
+		}
+
+		tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
+			{
+				SecretKey: "mysecret",
+				RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
+					Key: cloudSecretName,
+				},
+			},
+		}
+
+		tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
+			Metadata: esv1alpha1.ExternalSecretTemplateMetadata{
+				Annotations: map[string]string{
+					"example": "annotation",
+				},
+				Labels: map[string]string{
+					"example": "label",
+				},
+			},
+			Data: map[string]string{
+				".dockerconfigjson": "{{ .mysecret | toString }}",
+			},
+		}
+
+	}
+}

+ 1 - 0
e2e/suite/gcp/gcp.go

@@ -36,5 +36,6 @@ var _ = Describe("[gcp] ", func() {
 		Entry(common.JSONDataFromSync(f)),
 		Entry(common.NestedJSONWithGJSON(f)),
 		Entry(common.JSONDataWithTemplate(f)),
+		Entry(common.DockerJSONConfig(f)),
 	)
 })