-
Notifications
You must be signed in to change notification settings - Fork 323
test(validation): add multi-tenant ID format sanitization and recursion depth boundary assertions #3140
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?
test(validation): add multi-tenant ID format sanitization and recursion depth boundary assertions #3140
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,42 @@ | ||
| package validation | ||
|
|
||
| import ( | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestWave4TenantIDSanitization(t *testing.T) { | ||
| isValidTenantID := func(tenant string) bool { | ||
| if len(tenant) == 0 || len(tenant) > 64 { | ||
| return false | ||
| } | ||
| for _, r := range tenant { | ||
| if !((r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '-' || r == '_') { | ||
| return false | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| if !isValidTenantID("t_org_prod_99") { | ||
| t.Error("expected valid tenant ID") | ||
| } | ||
| if isValidTenantID("invalid tenant with spaces") { | ||
| t.Error("expected invalid tenant ID with spaces") | ||
| } | ||
| if isValidTenantID("") { | ||
| t.Error("expected invalid empty tenant ID") | ||
| } | ||
|
Comment on lines
+20
to
+28
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Cover the tenant ID format and length boundaries. The test has one accepted value. It covers 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| func TestWave4DepthLimitBoundary(t *testing.T) { | ||
| checkGraphDepth := func(currentDepth int, maxDepth int) bool { | ||
| return currentDepth <= maxDepth && currentDepth >= 0 | ||
| } | ||
|
|
||
| if !checkGraphDepth(15, 30) { | ||
| t.Error("depth 15 of 30 should be allowed") | ||
| } | ||
| if checkGraphDepth(31, 30) { | ||
| t.Error("depth 31 of 30 should exceed maximum recursion depth") | ||
|
Comment on lines
+36
to
+40
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Test equality at the maximum depth.
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
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
Call the implementations under test.
isValidTenantIDandcheckGraphDepthreimplement the expected rules inside the test. They do not call the production validator or traversal guard. The tests can pass after a production regression. Replace both closures with calls to the implementations under test.Also applies to: 32-34
🤖 Prompt for AI Agents