Personal Telegram developer console for GitHub

test: require approved write policy semantics

davoodmehraban89 committed Oct 3, 2026 at 05:23 UTC 3a6b7febbe2c071f038f3889c4ebb904d0021218
1 file changed +26
test/action-policy.test.js
+26
@@ -26,6 +26,32 @@ test('ActionPolicy requires approval for WRITE and DESTRUCTIVE actions', () => {
26 }
27 });
28
29 +test('ActionPolicy allows verified owner approval for WRITE and DESTRUCTIVE actions', () => {
30 + const policy = new ActionPolicy();
31 + assert.deepEqual(policy.evaluate({ action: action('WRITE'), isOwner: true, approved: true }), {
32 + allowed: true,
33 + requiresApproval: false,
34 + risk: 'WRITE',
35 + reason: 'owner_write_approved'
36 + });
37 + assert.deepEqual(policy.evaluate({ action: action('DESTRUCTIVE'), isOwner: true, approved: true }), {
38 + allowed: true,
39 + requiresApproval: false,
40 + risk: 'DESTRUCTIVE',
41 + reason: 'owner_destructive_approved'
42 + });
43 +});
44 +
45 +test('ActionPolicy denies non-owner even when approved flag is present', () => {
46 + const policy = new ActionPolicy();
47 + assert.deepEqual(policy.evaluate({ action: action('WRITE'), isOwner: false, approved: true }), {
48 + allowed: false,
49 + requiresApproval: false,
50 + risk: 'WRITE',
51 + reason: 'owner_required'
52 + });
53 +});
54 +
55 test('ActionPolicy denies non-owner, missing and unknown actions', () => {
56 const policy = new ActionPolicy();
57 assert.deepEqual(policy.evaluate({ action: action('READ'), isOwner: false }), {