- Merge essential builtins (driver, default theme, start prep, host workarounds) into always-on system plugin builtin.core, with state.json and arg-ledger migration plus app-scoped workaround settings honored by both GUI and CLI. - Ensure disabling builtin.bridge.guest-tools stops the localhost bridge without being restarted by feature callers, fix guesttools.Server Start/Close race, and reflect the disabled state in VMPage and SettingsModal. - Add QQ community group entry in About settings with Windows tencent:// protocol detection, cached invite redirect resolution, and copy-ID fallback. - Update docs/plugin-architecture.md, Wails bindings, and i18n strings.
72 lines
2.4 KiB
Go
72 lines
2.4 KiB
Go
package app
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestParseQQGroupRedirect(t *testing.T) {
|
|
loc := "https://qun.qq.com/universal-share/share?ac=1&authKey=0gmB8kE9XLpaQhm%2FxA2hrXECer6N8BpXCVjjDbYXyVdxHFmXNqtpw2ffMdFhqYKU&busi_data=eyJncm91cENvZGUiOiIxMTM2MDQyNzQ0IiwidG9rZW4iOiJ0ZXN0IiwidWluIjoiMTIzIn0%3D&svctype=5"
|
|
auth, err := parseQQGroupRedirect(loc)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if auth.groupCode != "1136042744" {
|
|
t.Fatalf("groupCode = %q, want 1136042744", auth.groupCode)
|
|
}
|
|
if auth.authKey != "0gmB8kE9XLpaQhm/xA2hrXECer6N8BpXCVjjDbYXyVdxHFmXNqtpw2ffMdFhqYKU" {
|
|
t.Fatalf("authKey = %q", auth.authKey)
|
|
}
|
|
|
|
if _, err := parseQQGroupRedirect("http://qun.qq.com/universal-share/share?authKey=abc"); err == nil {
|
|
t.Fatal("expected error for non-HTTPS redirect")
|
|
}
|
|
if _, err := parseQQGroupRedirect("https://qun.qq.com/universal-share/share?ac=1"); err == nil {
|
|
t.Fatal("expected error when authKey is missing")
|
|
}
|
|
}
|
|
|
|
func TestBuildQQGroupSchemeURL(t *testing.T) {
|
|
ts := time.UnixMilli(1730000000123)
|
|
got := buildQQGroupSchemeURL("1136042744", "key/with+chars", ts)
|
|
const prefix = "tencent://groupwpa/?subcmd=all¶m="
|
|
const suffix = "&jump_from="
|
|
if !strings.HasPrefix(got, prefix) || !strings.HasSuffix(got, suffix) {
|
|
t.Fatalf("unexpected scheme URL: %q", got)
|
|
}
|
|
hexPart := strings.TrimSuffix(strings.TrimPrefix(got, prefix), suffix)
|
|
if hexPart != strings.ToUpper(hexPart) {
|
|
t.Fatalf("expected uppercase hex param, got %q", hexPart)
|
|
}
|
|
raw, err := hex.DecodeString(hexPart)
|
|
if err != nil {
|
|
t.Fatalf("decode hex: %v", err)
|
|
}
|
|
var param qqGroupWPAParam
|
|
if err := json.Unmarshal(raw, ¶m); err != nil {
|
|
t.Fatalf("unmarshal param: %v", err)
|
|
}
|
|
if param.GroupUin != "1136042744" || param.TimeStamp != 1730000000123 || param.AuthKey != "key/with+chars" || param.Auth != "" {
|
|
t.Fatalf("unexpected decoded param: %+v", param)
|
|
}
|
|
}
|
|
|
|
func TestExtractCommandExecutable(t *testing.T) {
|
|
cases := []struct {
|
|
in string
|
|
want string
|
|
}{
|
|
{`"D:\Program Files\Tencent\QQNT\versions\9.9.37-54395\resources\app\timwp.exe" "%1"`, `D:\Program Files\Tencent\QQNT\versions\9.9.37-54395\resources\app\timwp.exe`},
|
|
{`C:\QQ\timwp.exe "%1"`, `C:\QQ\timwp.exe`},
|
|
{` `, ``},
|
|
}
|
|
for _, tc := range cases {
|
|
if got := extractCommandExecutable(tc.in); got != tc.want {
|
|
t.Errorf("extractCommandExecutable(%q) = %q, want %q", tc.in, got, tc.want)
|
|
}
|
|
}
|
|
}
|