//go:build windows package remote import "testing" func TestGetServiceStatusNonExist(t *testing.T) { // 不存在的服务应返回错误(Radmin 服务普通机器上不会安装) _, err := GetRadminServiceStatus() if err == nil { t.Log("本机安装了 Radmin 服务,跳过该断言") } } func TestGetRemoteInfo(t *testing.T) { info := GetRemoteInfo() if info.Hostname == "" { t.Error("Hostname 不应为空") } if len(info.IpAddr) == 0 { t.Log("本机无 IPv4 地址(CI 环境可能出现)") } // 只读查询,不应 panic _ = info.RdpState _ = info.VncState } func TestVncPasswordCryptDecrypt(t *testing.T) { password := "tvncpass" encrypted := VncPasswordCrypt(password) if len(encrypted) == 0 { t.Fatal("加密结果不应为空") } if string(encrypted) == password { t.Error("加密结果不应等于明文") } decrypted := VncPasswordDecrypt(encrypted) if decrypted != password { t.Errorf("解密 = %q, want %q", decrypted, password) } } func TestVncServerDefaultConfig(t *testing.T) { cfg := VncServerDefaultConfig(false) if cfg.RfbPort == 0 { t.Error("RfbPort 不应为 0") } if cfg.HttpPort == 0 { t.Error("HttpPort 不应为 0") } }