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 4, 2022
1 parent 3ae5d9c commit 187c686
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions util_test.go
Original file line number Diff line number Diff line change
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 187c686

Please sign in to comment.