mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 03:36:37 +08:00
add cloud playback diagnostics
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package handler
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCloudMountLibraryNameDefaultsToDirectoryBaseName(t *testing.T) {
|
||||
tests := []struct {
|
||||
@@ -24,3 +27,24 @@ func TestCloudMountLibraryNameDefaultsToDirectoryBaseName(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloudPlaybackDiagnosticsDoNotExposeRawRefOrURL(t *testing.T) {
|
||||
rawRef := "/剧集/国产剧/很长的敏感文件名.S01E01.mkv"
|
||||
refHash, refExt := cloudPlaybackRefFingerprint(rawRef)
|
||||
if refHash == "" || strings.Contains(rawRef, refHash) {
|
||||
t.Fatalf("ref hash should be a short fingerprint, got %q", refHash)
|
||||
}
|
||||
if refExt != ".mkv" {
|
||||
t.Fatalf("ref ext = %q, want .mkv", refExt)
|
||||
}
|
||||
if host := cloudPlaybackLinkHost("https://cdn.example.test/movie.mkv?token=secret"); host != "cdn.example.test" {
|
||||
t.Fatalf("host = %q, want cdn.example.test", host)
|
||||
}
|
||||
names := cloudPlaybackHeaderNames(map[string]string{
|
||||
"Authorization": "Bearer secret",
|
||||
"Cookie": "sid=secret",
|
||||
})
|
||||
if got := strings.Join(names, ","); got != "Authorization,Cookie" {
|
||||
t.Fatalf("header names = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user