#!/usr/bin/env bats # Unit tests for desktop-environment.sh hook # Tests for FR-003: Minimal Desktop Environment # Copyright © 2026 Known Element Enterprises LLC # License: GNU Affero General Public License v3.0 only # ============================================================================= # FILE EXISTENCE AND PROPERTIES # ============================================================================= @test "desktop-environment.sh hook exists" { [ -f "/workspace/config/hooks/live/desktop-environment.sh" ] } @test "desktop-environment.sh hook is executable" { [ -x "/workspace/config/hooks/live/desktop-environment.sh" ] } @test "desktop-environment.sh uses strict mode" { grep -q "set -euo pipefail" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # ICEWM CONFIGURATION # ============================================================================= @test "IceWM config directory is created" { grep -q "mkdir -p /etc/icewm" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM preferences file is created" { grep -q "/etc/icewm/preferences" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM theme file is created" { grep -q "/etc/icewm/theme" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM shows taskbar" { grep -q "ShowTaskBar=1" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM shows all windows in taskbar" { grep -q "TaskBarShowAllWindows=1" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM shows clock" { grep -q "TaskBarShowClock=1" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM disables CPU monitor (privacy)" { grep -q "TaskBarShowCPU=0" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM disables network monitor (privacy)" { grep -q "TaskBarShowNet=0" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM uses sloppy focus" { grep -q "InputFocusSloppy=1" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM enables mouse wheel" { grep -q "UseMouseWheel=1" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM enables quick switch (Alt+Tab)" { grep -q "QuickSwitch=1" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # ICEWM THEME CONFIGURATION # ============================================================================= @test "IceWM theme sets dark background colors" { grep -q "BkColor.*40/40/40\|BkColor.*30/30/30" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM theme sets white text color" { grep -q "TextColor.*FF/FF/FF\|Foreground.*FF/FF/FF" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM theme uses Flat theme" { grep -q "Flat/default.theme\|Theme=.*Flat" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # LIGHTDM CONFIGURATION (PRIVACY) # ============================================================================= @test "LightDM config directory is created" { grep -q "mkdir -p /etc/lightdm/lightdm.conf.d" /workspace/config/hooks/live/desktop-environment.sh } @test "LightDM privacy config file is created" { grep -q "99-privacy.conf" /workspace/config/hooks/live/desktop-environment.sh } @test "LightDM hides user list (privacy)" { grep -q "greeter-hide-users=true" /workspace/config/hooks/live/desktop-environment.sh } @test "LightDM shows manual login" { grep -q "greeter-show-manual-login=true" /workspace/config/hooks/live/desktop-environment.sh } @test "LightDM disables guest account" { grep -q "greeter-allow-guest=false\|allow-guest=false" /workspace/config/hooks/live/desktop-environment.sh } @test "LightDM has no autologin" { grep -q "autologin-user=" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # AUTOSTART CONFIGURATION # ============================================================================= @test "autostart directory is created" { grep -q "mkdir -p /etc/skel/.config/autostart" /workspace/config/hooks/live/desktop-environment.sh } @test "Remmina autostart is configured" { grep -q "remmina.desktop" /workspace/config/hooks/live/desktop-environment.sh } @test "autostart uses desktop entry format" { grep -q "\[Desktop Entry\]" /workspace/config/hooks/live/desktop-environment.sh } @test "autostart entry is for Network category" { grep -q "Categories=Network" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # X SESSION CONFIGURATION # ============================================================================= @test "Xsession.d directory is created" { grep -q "mkdir -p /etc/X11/Xsession.d" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM session script is created" { grep -q "99icewm" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM session uses icewm-session" { grep -q "icewm-session" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM is set as default window manager" { grep -q "update-alternatives.*x-window-manager" /workspace/config/hooks/live/desktop-environment.sh } @test "IceWM is registered with update-alternatives" { grep -q "update-alternatives --install" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # SECURITY PROPERTIES # ============================================================================= @test "no hardcoded passwords in script" { ! grep -qi "password\|secret\|passwd" /workspace/config/hooks/live/desktop-environment.sh } @test "guest account is disabled" { grep -q "allow-guest=false" /workspace/config/hooks/live/desktop-environment.sh } @test "user list is hidden (prevents user enumeration)" { grep -q "greeter-hide-users=true" /workspace/config/hooks/live/desktop-environment.sh } @test "no autologin configured" { # autologin-user= is empty grep -q "autologin-user=" /workspace/config/hooks/live/desktop-environment.sh ! grep -q "autologin-user=[a-zA-Z]" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # PRIVACY FEATURES # ============================================================================= @test "CPU monitor disabled (privacy)" { grep -q "TaskBarShowCPU=0" /workspace/config/hooks/live/desktop-environment.sh } @test "Network monitor disabled (privacy)" { grep -q "TaskBarShowNet=0" /workspace/config/hooks/live/desktop-environment.sh } @test "Auto reload menus disabled" { grep -q "AutoReloadMenus=0" /workspace/config/hooks/live/desktop-environment.sh } @test "Popups disabled while grabbed" { grep -q "ShowPopupsWhileGrabbed=0" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # LOGGING AND OUTPUT # ============================================================================= @test "script outputs status message" { grep -q "echo" /workspace/config/hooks/live/desktop-environment.sh } @test "script has startup message" { grep -q "Configuring desktop environment" /workspace/config/hooks/live/desktop-environment.sh } @test "script has success completion message" { grep -q "configured successfully" /workspace/config/hooks/live/desktop-environment.sh } # ============================================================================= # FILE PERMISSIONS # ============================================================================= @test "script creates files in /etc/skel for new users" { grep -q "/etc/skel" /workspace/config/hooks/live/desktop-environment.sh } @test "script creates system-wide config in /etc" { grep -q "/etc/icewm\|/etc/lightdm\|/etc/X11" /workspace/config/hooks/live/desktop-environment.sh }