MCPcopy Index your code
hub / github.com/koding/kite / TestWebSocketProxy

Function TestWebSocketProxy

reverseproxy/reverseproxy_test.go:20–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestWebSocketProxy(t *testing.T) {
21 color.Blue("====> Starting WebSocket test")
22 conf := config.New()
23 conf.Username = "testuser"
24 conf.KontrolURL = "http://localhost:5555/kite"
25 conf.KontrolKey = testkeys.Public
26 conf.KontrolUser = "testuser"
27 conf.KiteKey = testutil.NewKiteKey().Raw
28 conf.ReadEnvironmentVariables()
29
30 // start kontrol
31 color.Green("Starting kontrol")
32 kontrol.DefaultPort = 5555
33 kon := kontrol.New(conf.Copy(), "0.1.0")
34
35 switch os.Getenv("KONTROL_STORAGE") {
36 case "etcd":
37 kon.SetStorage(kontrol.NewEtcd(nil, kon.Kite.Log))
38 case "postgres":
39 p := kontrol.NewPostgres(nil, kon.Kite.Log)
40 kon.SetStorage(p)
41 kon.SetKeyPairStorage(p)
42 default:
43 kon.SetStorage(kontrol.NewEtcd(nil, kon.Kite.Log))
44 }
45
46 kon.AddKeyPair("", testkeys.Public, testkeys.Private)
47
48 go kon.Run()
49 <-kon.Kite.ServerReadyNotify()
50
51 // start proxy
52 proxyRegistered := make(chan struct{})
53
54 color.Green("Starting Proxy and registering to Kontrol")
55 proxyConf := conf.Copy()
56 proxyConf.Port = 4999
57 proxy := New(proxyConf)
58 proxy.PublicHost = "localhost"
59 proxy.PublicPort = proxyConf.Port
60 proxy.Scheme = "http"
61 proxy.Kite.OnRegister(func(*protocol.RegisterResult) { close(proxyRegistered) })
62
63 go proxy.Run()
64
65 select {
66 case <-proxy.ReadyNotify():
67 case <-time.After(10 * time.Second):
68 t.Fatalf("timed out waiting for proxy to start up")
69 }
70
71 proxyRegisterURL := &url.URL{
72 Scheme: proxy.Scheme,
73 Host: proxy.PublicHost + ":" + strconv.Itoa(proxy.PublicPort),
74 Path: "/kite",
75 }
76
77 _, err := proxy.Kite.Register(proxyRegisterURL)

Callers

nothing calls this directly

Calls 15

CopyMethod · 0.80
SetStorageMethod · 0.80
SetKeyPairStorageMethod · 0.80
AddKeyPairMethod · 0.80
ServerReadyNotifyMethod · 0.80
OnRegisterMethod · 0.80
HandleFuncMethod · 0.80
GetKitesMethod · 0.80
FatalMethod · 0.80
DialMethod · 0.80
TellWithTimeoutMethod · 0.80

Tested by

no test coverage detected