56 lines
2.2 KiB
Go
56 lines
2.2 KiB
Go
package windows
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/rvbox/rvbox/internal/client/supervisor"
|
|
)
|
|
|
|
func TestDesktopPlacementFollowsSelectedIdentity_HP_DESKTOP_01(t *testing.T) {
|
|
for _, context := range []ExecutionContext{ContextActiveUser, ContextActiveUserElevated, ContextActiveSystem} {
|
|
for _, sessionID := range []uint32{1, 7, 42} {
|
|
desktop, err := desktopForIdentity(supervisor.EffectiveIdentity{Context: string(context), SessionID: sessionID})
|
|
if err != nil || desktop != interactiveDesktop {
|
|
t.Fatalf("%s/%d: desktop=%q err=%v", context, sessionID, desktop, err)
|
|
}
|
|
}
|
|
}
|
|
for _, context := range []ExecutionContext{ContextLocalService, ContextLocalSystem} {
|
|
desktop, err := desktopForIdentity(supervisor.EffectiveIdentity{Context: string(context)})
|
|
if err != nil || desktop != "" {
|
|
t.Fatalf("%s: desktop=%q err=%v", context, desktop, err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDesktopRejectsWrongSessionAndSecureTargets_BH_DESKTOP_01(t *testing.T) {
|
|
for _, identity := range []supervisor.EffectiveIdentity{
|
|
{Context: string(ContextActiveUser)}, {Context: string(ContextActiveUserElevated)}, {Context: string(ContextActiveSystem)},
|
|
{Context: string(ContextLocalService), SessionID: 1}, {Context: string(ContextLocalSystem), SessionID: 1}, {Context: "unknown", SessionID: 1},
|
|
} {
|
|
if _, err := desktopForIdentity(identity); err == nil {
|
|
t.Fatalf("invalid identity accepted: %+v", identity)
|
|
}
|
|
}
|
|
for _, target := range []string{"", `winsta0\winlogon`, `winsta0\screensaver`, `Service-0x0-3e7$\default`, `winsta0\other`, `winsta0\default\extra`} {
|
|
if err := validateInteractiveDesktop(target); err == nil {
|
|
t.Fatalf("wrong desktop accepted: %q", target)
|
|
}
|
|
}
|
|
if err := validateInteractiveDesktop(`WinSta0\Default`); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestDesktopFailureDiagnosticIsBounded_BH_DESKTOP_02(t *testing.T) {
|
|
if err := launcherAbortError([]byte("interactive desktop access: Access is denied.")); !strings.Contains(err.Error(), "Access is denied") {
|
|
t.Fatal(err)
|
|
}
|
|
for _, payload := range [][]byte{nil, make([]byte, 4097)} {
|
|
if err := launcherAbortError(payload); !strings.Contains(err.Error(), "without a valid diagnostic") {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
}
|