Skip to content

Commit 3e51f62

Browse files
Copilothsluoyz
andcommitted
Fix code review issues: add updatePolicy to MockAdapter and remove await from removePolicy
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
1 parent 7f4bd0f commit 3e51f62

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/internalEnforcer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ export class InternalEnforcer extends CoreEnforcer {
337337
return false;
338338
}
339339

340-
const ok = await this.model.removePolicy(sec, ptype, rule);
340+
const ok = this.model.removePolicy(sec, ptype, rule);
341341
if (sec === 'g' && ok) {
342342
await this.buildIncrementalRoleLinks(PolicyOp.PolicyRemove, ptype, [rule]);
343343
}

test/selfManagementAPI.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class MockAdapter implements Adapter {
4242
async removeFilteredPolicy(sec: string, ptype: string, fieldIndex: number, ...fieldValues: string[]): Promise<void> {
4343
this.removeFilteredPolicyCalls.push({ sec, ptype, fieldIndex, fieldValues });
4444
}
45+
46+
async updatePolicy(sec: string, ptype: string, oldRule: string[], newRule: string[]): Promise<void> {
47+
this.updatePolicyCalls.push({ sec, ptype, oldRule, newRule });
48+
}
4549
}
4650

4751
// Mock watcher that tracks calls

0 commit comments

Comments
 (0)