Skip to content

Commit 187c686

Browse files
committed
add testcase to Sec-WebSocket-Key header verification
1 parent 3ae5d9c commit 187c686

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

util_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ func TestTokenListContainsValue(t *testing.T) {
5353
}
5454
}
5555

56+
var isValidChallengeKeyTests = []struct {
57+
key string
58+
ok bool
59+
}{
60+
{"dGhlIHNhbXBsZSBub25jZQ==", true},
61+
{"", false},
62+
{"InvalidKey", false},
63+
{"WHQ4eXhscUtKYjBvOGN3WEdtOEQ=", false},
64+
}
65+
66+
func TestIsValidChallengeKey(t *testing.T) {
67+
for _, tt := range isValidChallengeKeyTests {
68+
ok := isValidChallengeKey(tt.key)
69+
if ok != tt.ok {
70+
t.Errorf("isValidChallengeKey returns %v, want %v", ok, tt.ok)
71+
}
72+
}
73+
}
74+
5675
var parseExtensionTests = []struct {
5776
value string
5877
extensions []map[string]string

0 commit comments

Comments
 (0)