package store import "testing" func TestRequestPolicyAllowsOnlyListedUsers(t *testing.T) { policy := RequestPolicy{AllowedUserIDs: []string{"user-2"}} if policy.Allows("user-1") { t.Fatal("unlisted user was allowed") } if !policy.Allows("user-2") { t.Fatal("listed user was denied") } } func TestPlaybackPolicyDefaultsAndClampsDuration(t *testing.T) { defaults := DefaultPlaybackPolicy() if !defaults.PrerollEnabled || defaults.PrerollDurationMs != 6_500 { t.Fatalf("default playback policy = %+v", defaults) } if got := normalizePlaybackPolicy(PlaybackPolicy{PrerollDurationMs: 500}); got.PrerollDurationMs != 1_000 { t.Fatalf("short duration = %d, want 1000", got.PrerollDurationMs) } if got := normalizePlaybackPolicy(PlaybackPolicy{PrerollDurationMs: 60_000}); got.PrerollDurationMs != 30_000 { t.Fatalf("long duration = %d, want 30000", got.PrerollDurationMs) } } func TestFeaturePolicyDefaultsAreRecoverable(t *testing.T) { policy := normalizeFeaturePolicy(FeaturePolicy{}) if policy.Overrides == nil || policy.SafeMode || policy.Revision != 0 { t.Fatalf("default feature policy = %+v", policy) } policy.Overrides["sonarr_preroll"] = false if policy.Overrides["sonarr_preroll"] { t.Fatal("explicit off override was not retained") } }