Improve portable launch, forge persistence, and operator auth UX.
Persist build extra_files for Build Manager history, print dashboard login on every start, add libp2p for Mesh P2P forge, defer WebSocket until login, and split devrun.bat from LAUNCH.bat with USB deck auto-detection.
This commit is contained in:
@@ -162,3 +162,98 @@ func TestUpnpSOAPErrorResponse(t *testing.T) {
|
||||
t.Fatalf("expected SOAP error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReLocationParsesSSDPResponse(t *testing.T) {
|
||||
cases := []struct {
|
||||
body string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
"HTTP/1.1 200 OK\r\nLOCATION: http://192.168.0.1:49152/desc.xml\r\n\r\n",
|
||||
"http://192.168.0.1:49152/desc.xml",
|
||||
},
|
||||
{
|
||||
"location: http://10.0.0.1/igd.xml",
|
||||
"http://10.0.0.1/igd.xml",
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
m := reLocation.FindStringSubmatch(tc.body)
|
||||
if len(m) != 2 {
|
||||
t.Fatalf("no LOCATION match in %q", tc.body)
|
||||
}
|
||||
if got := strings.TrimSpace(m[1]); got != tc.want {
|
||||
t.Fatalf("got %q want %q", got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveWANControlURLRelativeWithoutLeadingSlash(t *testing.T) {
|
||||
const igdXML = `<?xml version="1.0"?>
|
||||
<root>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
|
||||
<controlURL>ctl/IPConn</controlURL>
|
||||
</service>
|
||||
</root>`
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, igdXML)
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
got, err := resolveWANControlURL(srv.URL + "/igd.xml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := srv.URL + "/ctl/IPConn"
|
||||
if got != want {
|
||||
t.Fatalf("got %q want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpnpSOAPRequestHeaders(t *testing.T) {
|
||||
var contentType, soapAction string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
contentType = r.Header.Get("Content-Type")
|
||||
soapAction = r.Header.Get("SOAPAction")
|
||||
fmt.Fprint(w, `<response/>`)
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
if _, err := upnpSOAP(srv.URL, "GetExternalIPAddress", "<body/>"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(contentType, "text/xml") {
|
||||
t.Fatalf("Content-Type: %q", contentType)
|
||||
}
|
||||
wantAction := `"urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress"`
|
||||
if soapAction != wantAction {
|
||||
t.Fatalf("SOAPAction: got %q want %q", soapAction, wantAction)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpnpDeletePortMapping(t *testing.T) {
|
||||
var gotBody, gotAction string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotAction = r.Header.Get("SOAPAction")
|
||||
buf := make([]byte, 4096)
|
||||
n, _ := r.Body.Read(buf)
|
||||
gotBody = string(buf[:n])
|
||||
fmt.Fprint(w, `<?xml version="1.0"?><ok/>`)
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
if err := upnpDeletePortMapping(srv.URL, 8989); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(gotAction, "DeletePortMapping") {
|
||||
t.Fatalf("SOAPAction: %q", gotAction)
|
||||
}
|
||||
if !strings.Contains(gotBody, "<NewExternalPort>8989</NewExternalPort>") {
|
||||
t.Fatalf("body missing port: %q", gotBody)
|
||||
}
|
||||
if !strings.Contains(gotBody, "<NewProtocol>TCP</NewProtocol>") {
|
||||
t.Fatalf("body missing protocol: %q", gotBody)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user