From 2e44e993646a2e2c6cb555f21ae9093993020902 Mon Sep 17 00:00:00 2001 From: Javan lacerda Date: Mon, 5 Aug 2024 19:39:20 +0000 Subject: [PATCH] adding tests for check claims priority over defaults Signed-off-by: Javan lacerda --- pkg/identity/ciprovider/principal_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/identity/ciprovider/principal_test.go b/pkg/identity/ciprovider/principal_test.go index 62d00f2d2..4e51d06dc 100644 --- a/pkg/identity/ciprovider/principal_test.go +++ b/pkg/identity/ciprovider/principal_test.go @@ -233,9 +233,12 @@ func TestApplyTemplateOrReplace(t *testing.T) { "ref_gitlab": "main", "ref_type_tag": "tag", "ref_tag": "1.0.0", + "claim_foo": "bar", } issuerMetadata := map[string]string{ - "url": "https://github.com", + "url": "https://github.com", + "claim_foo": "default", + "default_foo": "default_bar", } tests := map[string]struct { @@ -288,6 +291,16 @@ func TestApplyTemplateOrReplace(t *testing.T) { ExpectedResult: "", ExpectErr: true, }, + `Should use default when claim doesn't exist`: { + Template: "default_foo", + ExpectedResult: "default_bar", + ExpectErr: false, + }, + `Should prior claims over defaults when they has the same name`: { + Template: "claim_foo", + ExpectedResult: "bar", + ExpectErr: false, + }, } for name, test := range tests {