Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
added test cases for cronjob generated secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudnautique committed Jun 23, 2022
1 parent dca85d3 commit 4f95914
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
28 changes: 16 additions & 12 deletions integration/secrets/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ func TestText(t *testing.T) {
return obj.Status.Namespace != ""
})

secret := helper.Wait(t, client.Watch, &corev1.SecretList{}, func(obj *corev1.Secret) bool {
return obj.Namespace == appInstance.Status.Namespace &&
obj.Name == "gen" && len(obj.Data) > 0
})
assert.Equal(t, "static", string(secret.Data["content"]))
for _, secretName := range []string{"gen", "gen2"} {
secret := helper.Wait(t, client.Watch, &corev1.SecretList{}, func(obj *corev1.Secret) bool {
return obj.Namespace == appInstance.Status.Namespace &&
obj.Name == secretName && len(obj.Data) > 0
})
assert.Equal(t, "static", string(secret.Data["content"]))
}
}

func TestJSON(t *testing.T) {
Expand Down Expand Up @@ -87,11 +89,13 @@ func TestJSON(t *testing.T) {
return obj.Status.Namespace != ""
})

secret := helper.Wait(t, client.Watch, &corev1.SecretList{}, func(obj *corev1.Secret) bool {
return obj.Namespace == appInstance.Status.Namespace &&
obj.Name == "gen" && len(obj.Data) > 0
})
assert.Equal(t, corev1.SecretType("other"), secret.Type)
assert.Equal(t, "value", string(secret.Data["key"]))
assert.Equal(t, "static", string(secret.Data["pass"]))
for _, secretName := range []string{"gen", "gen2"} {
secret := helper.Wait(t, client.Watch, &corev1.SecretList{}, func(obj *corev1.Secret) bool {
return obj.Namespace == appInstance.Status.Namespace &&
obj.Name == secretName && len(obj.Data) > 0
})
assert.Equal(t, corev1.SecretType("other"), secret.Type)
assert.Equal(t, "value", string(secret.Data["key"]))
assert.Equal(t, "static", string(secret.Data["pass"]))
}
}
8 changes: 8 additions & 0 deletions integration/secrets/testdata/generated-json/acorn.cue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs: {
"""
cmd: ["sh", "/run.sh"]
}
cronpass: {schedule: "* * * * *"} & pass
}

secrets: {
Expand All @@ -34,4 +35,11 @@ secrets: {
job: "pass"
}
}
gen2: {
type: "generated"
params: {
format: "json"
job: "cronpass"
}
}
}
5 changes: 5 additions & 0 deletions integration/secrets/testdata/generated/acorn.cue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jobs: {
image: "busybox"
cmd: ["sh", "-c", "echo -n $PASS > /run/secrets/output"]
}
cronpass: {schedule: "* * * * * "} & pass
}

secrets: {
Expand All @@ -21,4 +22,8 @@ secrets: {
job: "pass"
}
}
gen2: {
type: "generated"
params: job: "cronpass"
}
}

0 comments on commit 4f95914

Please sign in to comment.