diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-11-09 13:17:03 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-11-27 14:16:43 +0300 |
commit | 14cba74f46401020b15415ea0454c5081418677e (patch) | |
tree | 36a8ff9df8563b583b69fb87f5c901d0799f8ade /internal/helper/security_test.go | |
parent | 48512ae7537da17ca680710e9b7160633d9e9a14 (diff) |
Introduce a security func to scrub error messages
This helper was around already, so this is a duplication but now its
tested. Later we could move all other occurances to leverage this
helper.
Diffstat (limited to 'internal/helper/security_test.go')
-rw-r--r-- | internal/helper/security_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/helper/security_test.go b/internal/helper/security_test.go index cd31d9f73..9a8125dac 100644 --- a/internal/helper/security_test.go +++ b/internal/helper/security_test.go @@ -22,3 +22,21 @@ func TestContainsPathTraversal(t *testing.T) { assert.Equal(t, tc.containsTraversal, ContainsPathTraversal(tc.path)) } } + +func TestSanitizeString(t *testing.T) { + testCases := []struct { + input string + output string + }{ + {"https://foo_the_user@gitlab.com/foo/bar", "https://[FILTERED]@gitlab.com/foo/bar"}, + {"https://foo_the_user:hUntEr1@gitlab.com/foo/bar", "https://[FILTERED]@gitlab.com/foo/bar"}, + {"proto://user:password@gitlab.com", "proto://[FILTERED]@gitlab.com"}, + {"some message proto://user:password@gitlab.com", "some message proto://[FILTERED]@gitlab.com"}, + {"test", "test"}, + {"ssh://@gitlab.com", "ssh://@gitlab.com"}, + } + + for _, tc := range testCases { + assert.Equal(t, tc.output, SanitizeString(tc.input)) + } +} |