add celformer unit test demonstrating string regexp in CEL expressions
This commit is contained in:
parent
c52ed93bf8
commit
2cecc17ef0
@ -234,6 +234,26 @@ func TestTransformer(t *testing.T) {
|
|||||||
wantUsername: "ryan",
|
wantUsername: "ryan",
|
||||||
wantGroups: []string{"admins", "developers", "other"},
|
wantGroups: []string{"admins", "developers", "other"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "can use regex on strings: when the regex matches",
|
||||||
|
username: "ryan",
|
||||||
|
groups: []string{"admins", "developers", "other"},
|
||||||
|
transforms: []CELTransformation{
|
||||||
|
&UsernameTransformation{Expression: `username.matches("^r[abcy].n$") ? "ryan-modified" : username`},
|
||||||
|
},
|
||||||
|
wantUsername: "ryan-modified",
|
||||||
|
wantGroups: []string{"admins", "developers", "other"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "can use regex on strings: when the regex does not match",
|
||||||
|
username: "olive",
|
||||||
|
groups: []string{"admins", "developers", "other"},
|
||||||
|
transforms: []CELTransformation{
|
||||||
|
&UsernameTransformation{Expression: `username.matches("^r[abcy].n$") ? "ryan-modified" : username`},
|
||||||
|
},
|
||||||
|
wantUsername: "olive",
|
||||||
|
wantGroups: []string{"admins", "developers", "other"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "can filter groups based on an allow list",
|
name: "can filter groups based on an allow list",
|
||||||
username: "ryan",
|
username: "ryan",
|
||||||
|
Loading…
Reference in New Issue
Block a user