This commit is contained in:
2026-08-16 13:17:19 -03:00
parent c0a337be3f
commit 7b8e7bfbd0
82 changed files with 5479 additions and 1016 deletions
+16 -6
View File
@@ -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)
}
}