-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Sanitize user identity before injecting into task pod as K8s lab…
…el (#5023) * Fix: Sanitize user identity before injecting into task pod as K8s label Signed-off-by: Fabio Graetz <[email protected]> * Lint Signed-off-by: Fabio Graetz <[email protected]> --------- Signed-off-by: Fabio Graetz <[email protected]>
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,25 @@ func Test_newTaskExecutionMetadata(t *testing.T) { | |
assert.Equal(t, 2, len(actual.GetLabels())) | ||
assert.Equal(t, "test-exec-identity", actual.GetLabels()[executionIdentityVariable]) | ||
}) | ||
t.Run("Inject exec identity K8s label sanitation", func(t *testing.T) { | ||
|
||
existingMetadata := &mocks.TaskExecutionMetadata{} | ||
existingAnnotations := map[string]string{} | ||
existingMetadata.OnGetAnnotations().Return(existingAnnotations) | ||
|
||
existingMetadata.OnGetSecurityContext().Return(core.SecurityContext{RunAs: &core.Identity{ExecutionIdentity: "[email protected]"}}) | ||
|
||
existingLabels := map[string]string{ | ||
"existingLabel": "existingLabelValue", | ||
} | ||
existingMetadata.OnGetLabels().Return(existingLabels) | ||
|
||
actual, err := newTaskExecutionMetadata(existingMetadata, &core.TaskTemplate{}) | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, 2, len(actual.GetLabels())) | ||
assert.Equal(t, "name-company-com", actual.GetLabels()[executionIdentityVariable]) | ||
}) | ||
} | ||
|
||
func Test_newTaskExecutionContext(t *testing.T) { | ||
|