spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / tests / policy / is-managed-mods-only.test.ts
45 lines · 1.3 KBRaw
1import { describe, expect, test, tier } from 'claude-code/testing'
2
3import Policy from '../../hooks/policy'
4import Fixtures from '../fixtures'
5
6tier('prepend')
7
8describe('is-managed-mods-only', () => {
9 test('true locks; absent or false leaves mods as they are', () => {
10 expect(
11 [
12 Fixtures.modsPolicyOf(true),
13 Fixtures.modsPolicyOf(false),
14 Fixtures.NO_ALLOWLIST,
15 {},
16 ].map(Policy.isManagedModsOnly),
17 ).toEqual([true, false, false, false])
18 })
19
20 test('a value mistyped still locks, as a managed lock reads', () => {
21 expect(
22 [
23 Fixtures.modsPolicyOf('true'),
24 Fixtures.modsPolicyOf('false'),
25 Fixtures.modsPolicyOf(1),
26 Fixtures.modsPolicyOf(0),
27 ].map(Policy.isManagedModsOnly),
28 ).toEqual([true, true, true, true])
29 })
30
31 test('only its own pluginConfigs entry is read', () => {
32 expect(
33 [
34 { allowManagedModsOnly: true },
35 { pluginConfigs: { allowManagedModsOnly: true } },
36 {
37 pluginConfigs: {
38 'guard@corp-market': { options: { allowManagedModsOnly: true } },
39 },
40 },
41 { pluginConfigs: 'cc-plugin-sec-default@builtin' },
42 ].map(Policy.isManagedModsOnly),
43 ).toEqual([false, false, false, false])
44 })
45})