Files
DankMaterialShell/core/cmd/dms/immutable_policy_test.go
T
purian23 6d00fd7295 feat(duxinstall): config support for immutable image-based hosts
- detect ostree/bootc/transactional hosts
- official dms doctor & dms command support
- updated installation instructions on dux labs docs

Port 2.0

(cherry picked from commit 696be97018)
2026-10-25 07:20:54 +00:00

31 lines
1.0 KiB
Go

package main
import (
"encoding/json"
"testing"
"github.com/duxlabs-dev/dux-shell/core/internal/clipolicy"
)
// The greeter commands forward to dms-greeter, which applies its own policy;
// a packaged /usr/share/dms/cli-policy.json can still block them here.
func TestDefaultImmutablePolicyBlocksNothing(t *testing.T) {
var policyFile clipolicy.File
if err := json.Unmarshal(defaultCLIPolicyJSON, &policyFile); err != nil {
t.Fatalf("failed to parse embedded CLI policy: %v", err)
}
if policyFile.BlockedCommands == nil {
t.Fatal("embedded CLI policy has no blocked_commands")
}
blocked := normalizeBlockedCommands(*policyFile.BlockedCommands)
for _, command := range []string{"greeter install", "greeter enable", "greeter uninstall", "greeter sync"} {
if commandBlockedByPolicy(command, blocked) {
t.Fatalf("%s must be available by default on image-based systems", command)
}
}
if commandBlockedByPolicy("setup", blocked) {
t.Fatal("setup only writes to the home directory and must stay available on image-based systems")
}
}