Browse Source

Added SSHKey data property test that works with vault. Updated tests that run on all providers.

Kian 4 years ago
parent
commit
25d53fb805

+ 2 - 0
e2e/suite/aws/secretsmanager.go

@@ -122,6 +122,8 @@ var _ = Describe("[aws] ", func() {
 		Entry(common.JSONDataWithTemplate(f)),
 		Entry("should sync secrets with jwt auth", jwt),
 		Entry(common.DockerJSONConfig(f)),
+		Entry(common.DataPropertyDockerconfigJSON(f)),
 		Entry(common.SSHKeySync(f)),
+		Entry(common.SSHKeySyncDataProperty(f)),
 	)
 })

+ 2 - 0
e2e/suite/azure/azure.go

@@ -41,6 +41,8 @@ var _ = Describe("[azure] ", func() {
 		Entry(common.JSONDataWithProperty(f)),
 		Entry(common.JSONDataWithTemplate(f)),
 		Entry(common.DockerJSONConfig(f)),
+		Entry(common.DataPropertyDockerconfigJSON(f)),
 		Entry(common.SSHKeySync(f)),
+		Entry(common.SSHKeySyncDataProperty(f)),
 	)
 })

+ 42 - 5
e2e/suite/common/common.go

@@ -231,7 +231,7 @@ func NestedJSONWithGJSON(f *framework.Framework) (string, func(*framework.TestCa
 // The values from the nested data are extracted using gjson.
 // not supported by: vault.
 func DockerJSONConfig(f *framework.Framework) (string, func(*framework.TestCase)) {
-	return "[common] should sync docker configurated json secrets with template", func(tc *framework.TestCase) {
+	return "[common] should sync docker configurated json secrets with template simple", func(tc *framework.TestCase) {
 		cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
 		dockerconfig := `{"auths":{"https://index.docker.io/v1/": {"auth": "c3R...zE2"}}}`
 		cloudSecretValue := fmt.Sprintf(`{"dockerconfig": %s}`, dockerconfig)
@@ -266,8 +266,8 @@ func DockerJSONConfig(f *framework.Framework) (string, func(*framework.TestCase)
 
 // This case creates a secret with a Docker json configuration value.
 // The values from the nested data are extracted using gjson.
-// Supported by vault due to type specification.
-func DockerJSONConfigVault(f *framework.Framework) (string, func(*framework.TestCase)) {
+// Need to have a key holding dockerconfig to be supported by vault.
+func DataPropertyDockerconfigJSON(f *framework.Framework) (string, func(*framework.TestCase)) {
 	return "[common] should sync docker configurated json secrets with template", func(tc *framework.TestCase) {
 		cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
 		dockerconfigString := `"{\"auths\":{\"https://index.docker.io/v1/\": {\"auth\": \"c3R...zE2\"}}}"`
@@ -304,9 +304,9 @@ func DockerJSONConfigVault(f *framework.Framework) (string, func(*framework.Test
 }
 
 // This case adds an ssh private key secret and sybcs it.
-// CHECK THIS not supported by: vault. Json parsing error.
+// Not supported by: vault. Json parsing error.
 func SSHKeySync(f *framework.Framework) (string, func(*framework.TestCase)) {
-	return "[common] should sync docker configurated json secrets with template", func(tc *framework.TestCase) {
+	return "[common] should sync ssh key secret", func(tc *framework.TestCase) {
 		sshSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "ssh-priv-key-example")
 		sshSecretValue := `EY2NNWddRADTFdNvEojrCwo+DUxy6va2JltQAbxmhyvSZsL1eYsutunsKEwonGSru0Zd+m
 		z5DHJOOQdHEsH3AAAACmFub3RoZXJvbmU=
@@ -339,3 +339,40 @@ func SSHKeySync(f *framework.Framework) (string, func(*framework.TestCase)) {
 		}
 	}
 }
+
+// This case adds an ssh private key secret and syncs it.
+// Supported by vault. But does not work with any form of line breaks as standard ssh key.
+func SSHKeySyncDataProperty(f *framework.Framework) (string, func(*framework.TestCase)) {
+	return "[common] should sync ssh key with provider.", func(tc *framework.TestCase) {
+		cloudSecretName := fmt.Sprintf("%s-%s", f.Namespace.Name, "docker-config-example")
+		SSHKey := "EY2NNWddRADTFdNvEojrCwo+DUxy6va2JltQAbxmhyvSZsL1eYsutunsKEwonGSru0Zd+m z5DHJOOQdHEsH3AAAACmFub3RoZXJvbmU= -----END OPENSSH PRIVATE KEY-----"
+		cloudSecretValue := fmt.Sprintf(`{"ssh-auth": "%s"}`, SSHKey)
+		tc.Secrets = map[string]string{
+			cloudSecretName: cloudSecretValue,
+		}
+
+		tc.ExpectedSecret = &v1.Secret{
+			Type: v1.SecretTypeSSHAuth,
+			Data: map[string][]byte{
+				"ssh-privatekey": []byte(SSHKey),
+			},
+		}
+
+		tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
+			{
+				SecretKey: "mysecret",
+				RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
+					Key:      cloudSecretName,
+					Property: "ssh-auth",
+				},
+			},
+		}
+
+		tc.ExternalSecret.Spec.Target.Template = &esv1alpha1.ExternalSecretTemplate{
+			Type: v1.SecretTypeSSHAuth,
+			Data: map[string]string{
+				"ssh-privatekey": "{{ .mysecret | toString }}",
+			},
+		}
+	}
+}

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

@@ -37,6 +37,8 @@ var _ = Describe("[gcp] ", func() {
 		Entry(common.NestedJSONWithGJSON(f)),
 		Entry(common.JSONDataWithTemplate(f)),
 		Entry(common.DockerJSONConfig(f)),
+		Entry(common.DataPropertyDockerconfigJSON(f)),
 		Entry(common.SSHKeySync(f)),
+		Entry(common.SSHKeySyncDataProperty(f)),
 	)
 })

+ 2 - 1
e2e/suite/vault/vault.go

@@ -32,6 +32,7 @@ var _ = Describe("[vault] ", func() {
 		Entry(common.JSONDataFromSync(f)),
 		Entry(common.JSONDataWithProperty(f)),
 		Entry(common.JSONDataWithTemplate(f)),
-		Entry(common.DockerJSONConfigVault(f)),
+		Entry(common.DataPropertyDockerconfigJSON(f)),
+		Entry(common.SSHKeySyncDataProperty(f)),
 	)
 })