From 74070aa0f9e667e3eabb55393e81e9a604b62b77 Mon Sep 17 00:00:00 2001 From: ila <2+ila@noreply.git.ilapage.cn> Date: Thu, 13 Aug 2026 12:23:43 +0800 Subject: [PATCH] feat: complete split camera credentials (#50) --- .../app/sense/adapters/onvif/client_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sense/server/app/sense/adapters/onvif/client_test.go b/Sense/server/app/sense/adapters/onvif/client_test.go index c8d6154..cf8664a 100644 --- a/Sense/server/app/sense/adapters/onvif/client_test.go +++ b/Sense/server/app/sense/adapters/onvif/client_test.go @@ -43,7 +43,8 @@ func TestProfilesDiscoversMediaServiceAndUsesDigest(t *testing.T) { if err != nil { t.Fatal(err) } - if len(profiles) != 1 || profiles[0].Width != 1920 || profiles[0].StreamURI != "rtsp://camera.invalid/live" { + serverURL, _ := url.Parse(server.URL) + if len(profiles) != 1 || profiles[0].Width != 1920 || profiles[0].StreamURI != "rtsp://"+serverURL.Hostname()+"/live" { t.Fatalf("profiles=%#v", profiles) } if digestRequests.Load() != 2 { @@ -80,6 +81,19 @@ func TestNormalizeServiceEndpoint(t *testing.T) { } } +func TestNormalizeStreamURI(t *testing.T) { + got, err := normalizeStreamURI("http://192.0.2.10:80/onvif/device_service", "rtsp://unusable.local:8554/live/main?channel=1") + if err != nil || got != "rtsp://192.0.2.10:8554/live/main?channel=1" { + t.Fatalf("got=%q err=%v", got, err) + } + if _, err := normalizeStreamURI("http://camera.local/onvif", "rtsp://user:pass@camera.local/live"); err == nil { + t.Fatal("credential stream URI accepted") + } + if _, err := normalizeStreamURI("http://camera.local/onvif", "http://camera.local/live"); err == nil { + t.Fatal("non-RTSP URI accepted") + } +} + func TestRejectUnsupportedDigestChallenge(t *testing.T) { for _, challenge := range []string{ `Digest realm="camera", nonce="n", algorithm=SHA-512, qop="auth"`,