Skip to content

Commit

Permalink
Fix the declarations for compareSecret.
Browse files Browse the repository at this point in the history
compareSecret in both its forms was declared as returning a String not a
Bool.

This fixes both of these.
  • Loading branch information
bigkevmcd authored and tekton-robot committed Jul 6, 2020
1 parent 50e82c1 commit 69e02ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion pkg/interceptors/cel/cel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,18 @@ func TestInterceptor_ExecuteTrigger(t *testing.T) {
payload: ioutil.NopCloser(bytes.NewBufferString(`{"count":1,"measure":1.7}`)),
want: []byte(`{"count":1,"measure":1.7}`),
},
{
name: "validating a secret",
CEL: &triggersv1.CELInterceptor{
Filter: "header.canonical('X-Secret-Token').compareSecret('token', 'test-secret', 'testing-ns') && body.count == 1.0",
},
payload: ioutil.NopCloser(bytes.NewBufferString(`{"count":1,"measure":1.7}`)),
want: []byte(`{"count":1,"measure":1.7}`),
},
{
name: "validating a secret in the default namespace",
CEL: &triggersv1.CELInterceptor{
Filter: "header.canonical('X-Secret-Token').compareSecret('token', 'test-secret')",
Filter: "header.canonical('X-Secret-Token').compareSecret('token', 'test-secret') && body.count == 1.0",
},
payload: ioutil.NopCloser(bytes.NewBufferString(`{"count":1,"measure":1.7}`)),
want: []byte(`{"count":1,"measure":1.7}`),
Expand Down
4 changes: 2 additions & 2 deletions pkg/interceptors/cel/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (triggersLib) CompileOptions() []cel.EnvOption {
[]*exprpb.Type{decls.String, decls.Int}, decls.String)),
decls.NewFunction("compareSecret",
decls.NewInstanceOverload("compareSecret_string_string_string",
[]*exprpb.Type{decls.String, decls.String, decls.String, decls.String}, decls.String)),
[]*exprpb.Type{decls.String, decls.String, decls.String, decls.String}, decls.Bool)),
decls.NewFunction("parseJSON",
decls.NewInstanceOverload("parseJSON_string",
[]*exprpb.Type{decls.String}, mapStrDyn)),
Expand All @@ -190,7 +190,7 @@ func (triggersLib) CompileOptions() []cel.EnvOption {
[]*exprpb.Type{decls.String}, mapStrDyn)),
decls.NewFunction("compareSecret",
decls.NewInstanceOverload("compareSecret_string_string",
[]*exprpb.Type{decls.String, decls.String, decls.String}, decls.String)))}
[]*exprpb.Type{decls.String, decls.String, decls.String}, decls.Bool)))}
}

func (t triggersLib) ProgramOptions() []cel.ProgramOption {
Expand Down

0 comments on commit 69e02ea

Please sign in to comment.