Skip to content

Commit

Permalink
add testcase to Sec-WebSocket-Key header verification
Browse files Browse the repository at this point in the history
  • Loading branch information
hirasawayuki committed Jan 3, 2022
1 parent 0c60ca5 commit 4a6464d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions util_test.go
Expand Up @@ -53,6 +53,25 @@ func TestTokenListContainsValue(t *testing.T) {
}
}

var isValidChallengeKeyTests = []struct {
key string
ok bool
}{
{"dGhlIHNhbXBsZSBub25jZQ==", true},
{"", false},
{"InvalidKey", false},
{"WHQ4eXhscUtKYjBvOGN3WEdtOEQ=", false},
}

func TestIsValidChallengeKey(t *testing.T) {
for _, tt := range isValidChallengeKeyTests {
ok := isValidChallengeKey(tt.key)
if ok != tt.ok {
t.Errorf("isValidChallengeKey returns %v, want %v", ok, tt.ok)
}
}
}

var parseExtensionTests = []struct {
value string
extensions []map[string]string
Expand Down

0 comments on commit 4a6464d

Please sign in to comment.