MCPcopy
hub / github.com/coder/websocket / Test_verifyClientHandshake

Function Test_verifyClientHandshake

accept_test.go:210–353  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

208}
209
210func Test_verifyClientHandshake(t *testing.T) {
211 t.Parallel()
212
213 testCases := []struct {
214 name string
215 method string
216 http1 bool
217 h map[string]string
218 success bool
219 }{
220 {
221 name: "badConnection",
222 h: map[string]string{
223 "Connection": "notUpgrade",
224 },
225 },
226 {
227 name: "badUpgrade",
228 h: map[string]string{
229 "Connection": "Upgrade",
230 "Upgrade": "notWebSocket",
231 },
232 },
233 {
234 name: "badMethod",
235 method: "POST",
236 h: map[string]string{
237 "Connection": "Upgrade",
238 "Upgrade": "websocket",
239 },
240 },
241 {
242 name: "badWebSocketVersion",
243 h: map[string]string{
244 "Connection": "Upgrade",
245 "Upgrade": "websocket",
246 "Sec-WebSocket-Version": "14",
247 },
248 },
249 {
250 name: "missingWebSocketKey",
251 h: map[string]string{
252 "Connection": "Upgrade",
253 "Upgrade": "websocket",
254 "Sec-WebSocket-Version": "13",
255 },
256 },
257 {
258 name: "emptyWebSocketKey",
259 h: map[string]string{
260 "Connection": "Upgrade",
261 "Upgrade": "websocket",
262 "Sec-WebSocket-Version": "13",
263 "Sec-WebSocket-Key": "",
264 },
265 },
266 {
267 name: "shortWebSocketKey",

Callers

nothing calls this directly

Calls 4

Base64Function · 0.92
SuccessFunction · 0.92
ErrorFunction · 0.92
verifyClientRequestFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…