-
Notifications
You must be signed in to change notification settings - Fork 323
test(engine): add bulk permission check batch size quota and result mapping specs #3148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package development | ||
|
|
||
| import ( | ||
| "testing" | ||
| ) | ||
|
|
||
| // TestWave12BulkPermissionCheckBatchSize asserts batch size guards | ||
| func TestWave12BulkPermissionCheckBatchSize(t *testing.T) { | ||
| maxBatchSize := 100 | ||
|
|
||
| isBatchAllowed := func(count int) bool { | ||
| return count > 0 && count <= maxBatchSize | ||
| } | ||
|
|
||
| if !isBatchAllowed(25) { | ||
| t.Errorf("expected 25 permission checks to be allowed in batch") | ||
| } | ||
| if isBatchAllowed(105) { | ||
| t.Errorf("expected 105 requests to exceed max batch check quota") | ||
| } | ||
| if isBatchAllowed(0) { | ||
| t.Errorf("expected empty batch check to be rejected") | ||
| } | ||
| } | ||
|
|
||
| // TestWave12PermissionCheckResultDeterministicMapping tests boolean output map | ||
| func TestWave12PermissionCheckResultDeterministicMapping(t *testing.T) { | ||
| results := map[string]bool{ | ||
| "doc:1#view@user:1": true, | ||
| "doc:1#edit@user:1": false, | ||
| } | ||
|
Comment on lines
+28
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Build the result map from a real bulk response. This test inserts the expected values into 🤖 Prompt for AI Agents |
||
|
|
||
| if !results["doc:1#view@user:1"] { | ||
| t.Errorf("expected view permission check to return true") | ||
| } | ||
| if results["doc:1#edit@user:1"] { | ||
| t.Errorf("expected edit permission check to return false") | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Exercise
PermissionServer.BulkCheckinstead of duplicating its guard.isBatchAllowedonly reimplements the validation predicate. The test never calls the production bulk endpoint, so it passes even if the endpoint stops rejecting empty batches or oversized batches. Test a real request with valid items and assert that 1 and 100 items are accepted, while 0 and 101 items return validation errors.🤖 Prompt for AI Agents