(t *testing.T)
| 734 | } |
| 735 | |
| 736 | func TestWSHeaders_StaticAppliedOnHandshake(t *testing.T) { |
| 737 | addr, got, closeLn := startHeaderCatcher(t) |
| 738 | defer closeLn() |
| 739 | |
| 740 | static := make(http.Header) |
| 741 | static.Set("Authorization", "Bearer Random Token") |
| 742 | static.Add("X-Multi", "v1") |
| 743 | static.Add("X-Multi", "v2") |
| 744 | |
| 745 | // Intentionally connect to our fake server; it won't complete the upgrade. |
| 746 | opts := GetDefaultOptions() |
| 747 | opts.WebSocketConnectionHeaders = static |
| 748 | opts.Url = "ws://" + addr |
| 749 | _, err := opts.Connect() |
| 750 | if err == nil { |
| 751 | t.Fatalf("expected connect to fail because server does not reply") |
| 752 | } |
| 753 | |
| 754 | var headers []string |
| 755 | select { |
| 756 | case headers = <-got: |
| 757 | case <-time.After(2 * time.Second): |
| 758 | t.Fatal("did not capture headers in time") |
| 759 | } |
| 760 | |
| 761 | if !hasHeaderValue(headers, "Authorization", "Bearer Random Token") { |
| 762 | t.Fatalf("Authorization header missing: %v", headers) |
| 763 | } |
| 764 | if !hasHeaderValue(headers, "X-Multi", "v1") || !hasHeaderValue(headers, "X-Multi", "v2") { |
| 765 | t.Fatalf("X-Multi headers missing/combined incorrectly: %v", headers) |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | func TestWSHeaders_HandlerAppliedOnHandshake(t *testing.T) { |
| 770 | addr, got, closeLn := startHeaderCatcher(t) |
nothing calls this directly
no test coverage detected