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

Function Test_authenticateOrigin

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

Source from the content-addressed store, hash-verified

408}
409
410func Test_authenticateOrigin(t *testing.T) {
411 t.Parallel()
412
413 testCases := []struct {
414 name string
415 origin string
416 host string
417 originPatterns []string
418 success bool
419 }{
420 {
421 name: "none",
422 success: true,
423 host: "example.com",
424 },
425 {
426 name: "invalid",
427 origin: "$#)(*)$#@*$(#@*$)#@*%)#(@*%)#(@%#@$#@$#$#@$#@}{}{}",
428 host: "example.com",
429 success: false,
430 },
431 {
432 name: "unauthorized",
433 origin: "https://example.com",
434 host: "example1.com",
435 success: false,
436 },
437 {
438 name: "authorized",
439 origin: "https://example.com",
440 host: "example.com",
441 success: true,
442 },
443 {
444 name: "authorizedCaseInsensitive",
445 origin: "https://examplE.com",
446 host: "example.com",
447 success: true,
448 },
449 {
450 name: "originPatterns",
451 origin: "https://two.examplE.com",
452 host: "example.com",
453 originPatterns: []string{
454 "*.example.com",
455 "bar.com",
456 },
457 success: true,
458 },
459 {
460 name: "originPatternsUnauthorized",
461 origin: "https://two.examplE.com",
462 host: "example.com",
463 originPatterns: []string{
464 "exam3.com",
465 "bar.com",
466 },
467 success: false,

Callers

nothing calls this directly

Calls 3

SuccessFunction · 0.92
ErrorFunction · 0.92
authenticateOriginFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…