Skip to content

Commit

Permalink
adding tests for check claims priority over defaults
Browse files Browse the repository at this point in the history
Signed-off-by: Javan lacerda <[email protected]>
  • Loading branch information
javanlacerda committed Aug 5, 2024
1 parent b3877fa commit 2e44e99
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/identity/ciprovider/principal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2e44e99

Please sign in to comment.