feat(remote): 自 go-hua/remote 并入远程控制服务管理
- RDP/VNC(TightVNC)/Radmin 服务状态查询与启停重置、VNC 安装/配置读写/密码 加解密、GetRemoteInfo 汇总、CAD/SAS 注册表开关 - 与本库 file/shell/process 同属被控端远程运维能力; 新增依赖 kardianos/service、KarpelesLab/vncpasswd - 附 remote_test.go 与包 README(含平台支持矩阵与权限注意)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
//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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user