1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-15 17:51:01 +00:00

fix: edit proper func

This commit is contained in:
Mateus Oliveira Patrício 2021-09-23 14:22:27 -03:00
parent f4fa26e375
commit 4b1f974d90

View file

@ -126,34 +126,24 @@ func JSONDataWithProperty(f *framework.Framework) (string, func(*framework.TestC
// The data is extracted from the JSON key using ref.Property.
func JSONDataWithoutTargetName(f *framework.Framework) (string, func(*framework.TestCase)) {
return "[common] should sync with empty target name, using json.", func(tc *framework.TestCase) {
secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "two")
secretValue1 := "{\"foo1\":\"foo1-val\",\"bar1\":\"bar1-val\"}"
secretValue2 := "{\"foo2\":\"foo2-val\",\"bar2\":\"bar2-val\"}"
secretKey := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
secretValue := "{\"foo\":\"foo-val\",\"bar\":\"bar-val\"}"
tc.Secrets = map[string]string{
secretKey1: secretValue1,
secretKey2: secretValue2,
secretKey: secretValue,
}
tc.ExpectedSecret = &v1.Secret{
Type: v1.SecretTypeOpaque,
Data: map[string][]byte{
secretKey1: []byte("foo1-val"),
secretKey2: []byte("bar2-val"),
secretKey: []byte("foo-val"),
},
}
tc.ExternalSecret.Spec.Target.Name = ""
tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
{
SecretKey: secretKey1,
SecretKey: secretKey,
RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
Key: secretKey1,
Property: "foo1",
},
},
{
SecretKey: secretKey2,
RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
Key: secretKey2,
Property: "bar2",
Key: secretKey,
Property: "foo",
},
},
}
@ -165,9 +155,12 @@ func JSONDataWithoutTargetName(f *framework.Framework) (string, func(*framework.
func JSONDataWithTemplate(f *framework.Framework) (string, func(*framework.TestCase)) {
return "[common] should sync json secrets with template", func(tc *framework.TestCase) {
secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
secretKey2 := fmt.Sprintf("%s-%s", f.Namespace.Name, "other")
secretValue1 := "{\"foo1\":\"foo1-val\",\"bar1\":\"bar1-val\"}"
secretValue2 := "{\"foo2\":\"foo2-val\",\"bar2\":\"bar2-val\"}"
tc.Secrets = map[string]string{
secretKey1: secretValue1,
secretKey2: secretValue2,
}
tc.ExpectedSecret = &v1.Secret{
Type: v1.SecretTypeOpaque,
@ -180,10 +173,22 @@ func JSONDataWithTemplate(f *framework.Framework) (string, func(*framework.TestC
},
},
Data: map[string][]byte{
"my-data": []byte(`executed: foo1-val`),
"my-data": []byte(`executed: foo1-val|bar2-val`),
},
}
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{
"my-data": "executed: {{ .one | toString }}|{{ .two | toString }}",
},
}
tc.ExternalSecret.Spec.Target.Name = ""
tc.ExternalSecret.Spec.Data = []esv1alpha1.ExternalSecretData{
{
SecretKey: "one",
@ -192,6 +197,13 @@ func JSONDataWithTemplate(f *framework.Framework) (string, func(*framework.TestC
Property: "foo1",
},
},
{
SecretKey: "two",
RemoteRef: esv1alpha1.ExternalSecretDataRemoteRef{
Key: secretKey2,
Property: "bar2",
},
},
}
}
}