GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — host-api/main_test.go at main · PastureStack/host-api Expand file tree/ Copy pathmain_test.goMore file actions 48 lines (43 loc) · 1.64 KB / Copy pathmain_test.goFile metadata and controls48 lines (43 loc) · 1.64 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 package main import ( "net/url" "regexp" "strings" "testing" "github.com/PastureStack/host-api/platformapi" ) func TestTraditionalChineseOperatorMessage(t *testing.T) { if got := operatorMessage("zh-TW", "start"); got != "PastureStack 主機 API 已準備連線" { t.Fatalf("unexpected zh-TW message: %q", got) } } func TestProxyConnectionURLValidatesAndEscapesToken(t *testing.T) { result, err := proxyConnectionURL(&platformapi.HostAPIProxyToken{ URL: "wss://proxy.example.test/connect?mode=host&token=old", Token: "a+b&c", }) if err != nil { t.Fatal(err) } parsed, _ := url.Parse(result) query := parsed.Query() if query.Get("token") != "a+b&c" || query.Get("mode") != "host" || query.Get("hostApiVersion") != version || query.Get("hostApiCapabilities") != "key-audit-v1,key-delegation-v1" { t.Fatal("proxy connection did not preserve authority and declare producer capabilities") } for _, response := range []*platformapi.HostAPIProxyToken{ {URL: "https://proxy.example.test/connect", Token: "token"}, {URL: "wss://proxy.example.test/connect#fragment", Token: "token"}, {URL: "wss://proxy.example.test/connect", Token: ""}, {URL: "wss://proxy.example.test/connect", Token: strings.Repeat("x", maxProxyTokenBytes+1)}, } { if _, err := proxyConnectionURL(response); err == nil { t.Fatalf("unsafe proxy response was accepted: %#v", response) } } } func TestDefaultVersionIsNumeric(t *testing.T) { if !regexp.MustCompile(`^[0-9]+\.[0-9]+\.[0-9]+$`).MatchString(version) { t.Fatalf("version must be MAJOR.MINOR.PATCH with no suffix: %q", version) } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |