V13
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"encoding/binary"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDecodeWireTokenAllowsEmptyToken(t *testing.T) {
|
||||
if got := decodeWireToken("-"); got != "" {
|
||||
t.Fatalf("empty wire token decoded as %q", got)
|
||||
func TestParseOpenAllowsEmptyToken(t *testing.T) {
|
||||
host := "example.com"
|
||||
p := make([]byte, 6+len(host))
|
||||
binary.BigEndian.PutUint16(p[0:2], 0)
|
||||
binary.BigEndian.PutUint16(p[2:4], uint16(len(host)))
|
||||
binary.BigEndian.PutUint16(p[4:6], 443)
|
||||
copy(p[6:], host)
|
||||
token, gotHost, port, err := parseOpen(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := decodeWireToken("secret"); got != "secret" {
|
||||
t.Fatalf("non-empty token changed: %q", got)
|
||||
if token != "" || gotHost != host || port != 443 {
|
||||
t.Fatalf("got token=%q host=%q port=%d", token, gotHost, port)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user