The distribution's i3lock behind a locker that releases xss-lock's sleep lock once it is up; timeouts and xss-lock from the session's xinitrc slot, ending with the session; i3lock-color and xscreensaver declared absent; Go tools lock, idle, inhibit and locked.
85 lines
3.2 KiB
Go
85 lines
3.2 KiB
Go
package main
|
|
|
|
import (
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// screen-lock's shape (novox/hq ADR 0208, research 026/04): it claims node-lock-screen serving lock,
|
|
// requires the X display on its own machine, installs the watcher and the distribution's locker,
|
|
// declares the colour build and xscreensaver absent, places its locker, and starts the watcher and
|
|
// the timeouts once, from the session's start. The lock key is the window manager's.
|
|
|
|
func TestItClaimsTheLockScreenSeatServingLockAndRequiresTheXDisplay(t *testing.T) {
|
|
m := readManifest(t)
|
|
if m.Module != "screen-lock" || m.Seats != nil {
|
|
t.Fatalf("module %q declares seats %v", m.Module, m.Seats)
|
|
}
|
|
if !reflect.DeepEqual(m.Claims, []claim{{Name: "node-lock-screen", Scope: "node", Serves: []string{"lock"}}}) {
|
|
t.Fatalf("claims: %+v", m.Claims)
|
|
}
|
|
if !reflect.DeepEqual(m.Requires, []string{"x11-display"}) {
|
|
t.Fatalf("requires: %v", m.Requires)
|
|
}
|
|
}
|
|
|
|
func TestTheDistributionsLockerReplacesTheColourBuildAndXscreensaverGoes(t *testing.T) {
|
|
m := readManifest(t)
|
|
present, absent := m.packages()
|
|
if !reflect.DeepEqual(present, []string{"xss-lock", "i3lock"}) || !reflect.DeepEqual(absent, []string{"i3lock-color", "xscreensaver"}) {
|
|
t.Fatalf("packages: %v, absent %v", present, absent)
|
|
}
|
|
m.sameAsSource(t, "wrapper", "files/bin/screen-lock")
|
|
wrapper := m.resource(t, "wrapper")
|
|
if wrapper["mode"] != "0755" || wrapper["path"] != "${machine:account-home}/.local/bin/screen-lock" {
|
|
t.Fatalf("the locker: %v", wrapper)
|
|
}
|
|
c := wrapper["content"].(string)
|
|
for _, colourOnly := range []string{"--ring-color", "--blur", "--clock", "--indicator", "--time-str"} {
|
|
if strings.Contains(c, colourOnly) {
|
|
t.Errorf("the wrapper passes %s, which only the colour build knows", colourOnly)
|
|
}
|
|
}
|
|
if !strings.Contains(c, "XSS_SLEEP_LOCK_FD}<&-") {
|
|
t.Error("the locker must not inherit the sleep lock")
|
|
}
|
|
}
|
|
|
|
func TestTheSessionStartSetsTheTimeoutsAndKeepsOneWatcherForTheSession(t *testing.T) {
|
|
m := readManifest(t)
|
|
if len(m.Shell) != 1 || m.Shell[0].For != "xinitrc" || m.Shell[0].Slot != "normal" {
|
|
t.Fatalf("one xinitrc contribution in normal: %+v", m.Shell)
|
|
}
|
|
code := m.Shell[0].Code
|
|
if strings.Count(code, "xss-lock --") != 1 || !strings.Contains(code, "--transfer-sleep-lock") ||
|
|
!strings.Contains(code, "while kill -0 $$") || !strings.HasSuffix(strings.TrimSpace(code), "&") {
|
|
t.Fatalf("the watcher: %q", code)
|
|
}
|
|
if strings.Contains(code, "xscreensaver") || strings.Contains(code, "my-i3lock") {
|
|
t.Fatalf("names what it replaced: %q", code)
|
|
}
|
|
for _, r := range m.Resources {
|
|
if r["type"] == "service" || r["type"] == "process" {
|
|
t.Fatalf("xss-lock needs the login session and is never a unit: %v", r)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTheLockKeyIsTheWindowManagersNotThisModules(t *testing.T) {
|
|
m := readManifest(t)
|
|
// The i3 module binds $mod+Delete to logind's lock, which names no locker; a binding here as well
|
|
// would be i3's duplicate.
|
|
for _, r := range m.Resources {
|
|
if p, _ := r["path"].(string); strings.Contains(p, "i3/config.d") {
|
|
t.Fatalf("a key binding: %v", r)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTheToolsAgreeWithTheManifest(t *testing.T) {
|
|
m := readManifest(t)
|
|
checkTheToolsAgree(t, m)
|
|
checkNoSecretsOrInstallationNames(t)
|
|
}
|