forked from xmidt-org/scytale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basculeLogging_test.go
44 lines (38 loc) · 1.14 KB
/
basculeLogging_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-FileCopyrightText: 2019 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSanitizeHeaders(t *testing.T) {
testCases := []struct {
Description string
Input http.Header
Expected http.Header
}{
{
Description: "Filtered",
Input: http.Header{"Authorization": []string{"Basic xyz"}, "HeaderA": []string{"x"}},
Expected: http.Header{"HeaderA": []string{"x"}, "Authorization-Type": []string{"Basic"}},
},
{
Description: "Handled human error",
Input: http.Header{"Authorization": []string{"BasicXYZ"}, "HeaderB": []string{"y"}},
Expected: http.Header{"HeaderB": []string{"y"}},
},
{
Description: "Not a perfect system",
Input: http.Header{"Authorization": []string{"MySecret IWantToLeakIt"}},
Expected: http.Header{"Authorization-Type": []string{"MySecret"}},
},
}
for _, tc := range testCases {
t.Run(tc.Description, func(t *testing.T) {
assert := assert.New(t)
actual := sanitizeHeaders(tc.Input)
assert.Equal(tc.Expected, actual)
})
}
}