Skip to content

Commit

Permalink
fix secret test
Browse files Browse the repository at this point in the history
  • Loading branch information
TimHuynh committed Sep 25, 2023
1 parent 22925cc commit fd475a9
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions executor/linux/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,104 +1010,104 @@ func TestLinux_Secret_injectSecret(t *testing.T) {
name: "secret with matching push event ACL injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"push"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"FOO": "foo", "BUILD_EVENT": "push"},
Environment: map[string]string{"FOO": "foo", "VELA_BUILD_EVENT": "push"},
},
},
{
name: "secret with non-matching push event ACL not injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"deployment"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
},
},
{ // pull_request event checks
name: "secret with matching pull_request event ACL injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "pull_request"},
Environment: map[string]string{"VELA_BUILD_EVENT": "pull_request"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"pull_request"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"FOO": "foo", "BUILD_EVENT": "pull_request"},
Environment: map[string]string{"FOO": "foo", "VELA_BUILD_EVENT": "pull_request"},
},
},
{
name: "secret with non-matching pull_request event ACL not injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "pull_request"},
Environment: map[string]string{"VELA_BUILD_EVENT": "pull_request"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"deployment"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "pull_request"},
Environment: map[string]string{"VELA_BUILD_EVENT": "pull_request"},
},
},
{ // tag event checks
name: "secret with matching tag event ACL injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "tag"},
Environment: map[string]string{"VELA_BUILD_EVENT": "tag"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"tag"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"FOO": "foo", "BUILD_EVENT": "tag"},
Environment: map[string]string{"FOO": "foo", "VELA_BUILD_EVENT": "tag"},
},
},
{
name: "secret with non-matching tag event ACL not injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "tag"},
Environment: map[string]string{"VELA_BUILD_EVENT": "tag"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"deployment"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "tag"},
Environment: map[string]string{"VELA_BUILD_EVENT": "tag"},
},
},
{ // deployment event checks
name: "secret with matching deployment event ACL injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "deployment"},
Environment: map[string]string{"VELA_BUILD_EVENT": "deployment"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"deployment"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"FOO": "foo", "BUILD_EVENT": "deployment"},
Environment: map[string]string{"FOO": "foo", "VELA_BUILD_EVENT": "deployment"},
},
},
{
name: "secret with non-matching deployment event ACL not injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "deployment"},
Environment: map[string]string{"VELA_BUILD_EVENT": "deployment"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"tag"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "deployment"},
Environment: map[string]string{"VELA_BUILD_EVENT": "deployment"},
},
},

Expand All @@ -1116,39 +1116,39 @@ func TestLinux_Secret_injectSecret(t *testing.T) {
name: "secret with matching event ACL and non-matching image ACL not injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"push"}, Images: &[]string{"centos"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
},
},
{
name: "secret with non-matching event ACL and matching image ACL not injected",
step: &pipeline.Container{
Image: "centos:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"pull_request"}, Images: &[]string{"centos"}}},
want: &pipeline.Container{
Image: "centos:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
},
},
{
name: "secret with matching event ACL and matching image ACL injected",
step: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"BUILD_EVENT": "push"},
Environment: map[string]string{"VELA_BUILD_EVENT": "push"},
Secrets: pipeline.StepSecretSlice{{Source: "FOO", Target: "FOO"}},
},
msec: map[string]*library.Secret{"FOO": {Name: &v, Value: &v, Events: &[]string{"push"}, Images: &[]string{"alpine"}}},
want: &pipeline.Container{
Image: "alpine:latest",
Environment: map[string]string{"FOO": "foo", "BUILD_EVENT": "push"},
Environment: map[string]string{"FOO": "foo", "VELA_BUILD_EVENT": "push"},
},
},
}
Expand Down

0 comments on commit fd475a9

Please sign in to comment.