Skip to content

Commit

Permalink
Added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-gold-apolicy committed May 3, 2022
1 parent 3d5be9a commit e0099bf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ package nats
import (
"bytes"
"compress/flate"
"context"
"crypto/tls"
"encoding/binary"
"fmt"
"io"
"math/rand"
"net/http"
"reflect"
"runtime"
"strings"
Expand Down Expand Up @@ -1108,3 +1110,31 @@ func TestWSNoDeadlockOnAuthFailure(t *testing.T) {

tm.Stop()
}

func TestWSProxyPath(t *testing.T) {
const (
proxyPath = "proxy1"
proxyPort = "8080"
)

var proxyCalled bool

http.HandleFunc("/"+proxyPath, func(w http.ResponseWriter, r *http.Request) {
proxyCalled = true
})

httpServer := &http.Server{Addr: ":" + proxyPort}
defer httpServer.Shutdown(context.Background())
go httpServer.ListenAndServe()

opt := testWSGetDefaultOptions(t, false)
s := RunServerWithOptions(opt)
defer s.Shutdown()

url := fmt.Sprintf("ws://127.0.0.1:%s", proxyPort)
Connect(url, ProxyPath(proxyPath))

if !proxyCalled {
t.Fatal("Proxy didnt called")
}
}

0 comments on commit e0099bf

Please sign in to comment.