Commit 8336e48
Domain: iam: Repository: update list-grant-scope and test setup to use new model (#5679)
* implement getRoleScopeId
* move query to query.go
* improve notfound err message
* improve other err messages
* use named parameter and move getRoleScopeId implementation
* moved getRoleScopeId test
* rename getRoleScopeId to getRoleScopeType
* fix public_id ambiguous error
* undo unintended change to getUserWithAccount
* fix the correct query
* split iam_role_global_individual_grant_scope to have separate tables for org and project
* small comment change
* small comment change
* WIP: add tests
* remove grant_scope as immutable column
* add trigger to delete individual grant scope when grant_scope changes
* add a test that covers changing grant_scope
* rename function and trigger in iam_role_global
* improve assertion in sqltest for iam_role_global
* update iam_role_org to delete redundant grants scope
* minor comment fix
* no longer handle individual grant scope deletion with triggers and rename some functions
* rename test
* add all subtype definitions
* remove unnecessary baseRole subtype
* add clone, setTableName, and GetScope tests
* add ResourceType and Actions test
* add create and delete tests for globalROle
* finish create and delete tests
* add trigger for deleting base role
* add trigger to sync update_time back to base iam_role table
* add update tests
* fix missing err checks
* fix iam_role delete subtype trigger function name and use new.update_time instead of now()
* add struct documentation to role subtypes
* add version update check
* implement getRoleScopeId
* implement getRoleScopeId
* save
* remove struct embedding from iam.Role
* fix tests to use new iam.Role definition
* repository_role_test.go move to new iam.Role model
* repository_principal_role_test.go use new iam.Role model
* repository_role_grant_test.go use new iam.Role model in test
* add oplog info to sql schema
* internal/iam/testing.go use new role schema in TestRole
* add toRole helper function to all role subtype
* remove tests that are no longer relevant
* internal/iam/repository_scope.go use new iam model
* internal/iam/repository_role_grant.go use new iam model
* internal/iam/repository_principal_role.go use new iam model
* internal/iam/repository_role_test.go add test case for global scoped role
* internal/iam/repository_grant_scope.go use new iam model
* fix query
* make create and lookup role work and add tests
* add role id to getRoleScopeId error message
* make DeleteRole work with new model and add tests
* fix update
* ensure oplog.ReplayableMessage is implemented on all role subtypes
* internal/iam/repository_role_grant.go fix slugging version properly
* internal/iam/repository_role.go minor correction to error message saying org instead of scope
* internal/iam/repository_role_test.go add more update tests
* add immutable_fields tests
* fix rebase
* change error code to RecordNotFound
* refactor to use getScopeType
* fix delete test
* add getRoleScope utility function
* repository_principal_role.go: refactor to remove multiple switch statements
* repository_role_grant.go: refactor to reduce LOC
* repository_role.go small refactor to use alloc func
* repository_grant_scope.go refactor
* review comments
* implement getRoleScopeId
* move query to query.go
* improve notfound err message
* improve other err messages
* use named parameter and move getRoleScopeId implementation
* moved getRoleScopeId test
* rename getRoleScopeId to getRoleScopeType
* fix public_id ambiguous error
* undo unintended change to getUserWithAccount
* fix the correct query
* rename test
* change error code to RecordNotFound
* Update internal/iam/repository_role.go
Co-authored-by: David Kanney <[email protected]>
* switch to slice instead of counter
* fix merge mistakes
* handling special scopes in test function
* fix TestRoleWithGrants
* fix minor typo
* make gen
* fix comment typos
* Bosorawis domain iam role use new model list role (#5676)
* add and use new list roles query
* run make gen
* tweaked returned error
* replace tabs with spaces in query string
* missed one tab
* remove leading spaces
* move ListRoleGrantScopes to repository_grant_scope.go
* rename repository_grant_scope to repository_role_grant_scope
* add proto definition for global role individual grant scope tables
* fix test from removing embeded struct from RoleGrantScope
* add grant_scope to proto definition
* implement GlobalRoleIndividualOrgGrantScope and GlobalRoleIndividualProjectGrantScope
* update comment
* run make gen to update comment
* implement OrgRoleIndividualGrantScope and add tests
* implement part of ListRoleGrantScopes
* Add more test
* add more test cases and remove add-grants test
* unexport listRoleGrantScopes
* use reader from function parameter instead of struct method
* rename test to match actual function
* run make gen
* unexport individual grants structs
* unexport individual grants structs - missed one file
* change TestRole and TestRoleGrantScope function to support new model
* add validation for special scopes
* add role_org_individual_grant_scope.pb.go to protobuild make target
* remove dead code from listRoleGrantScopes
* fix testRoleGrantScopeSpecial not handling org role special scope properly
* add back query removed by rebase
---------
Co-authored-by: David Kanney <[email protected]>1 parent 9b9aa75 commit 8336e48
File tree
20 files changed
+1918
-183
lines changed- internal
- daemon/controller/handlers
- roles
- targets/tcp
- db/schema/migrations/oss/postgres/100
- iam
- store
- proto/controller/storage/iam/store/v1
20 files changed
+1918
-183
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
2791 | 2791 | | |
2792 | 2792 | | |
2793 | 2793 | | |
2794 | | - | |
| 2794 | + | |
2795 | 2795 | | |
2796 | 2796 | | |
2797 | 2797 | | |
| |||
3129 | 3129 | | |
3130 | 3130 | | |
3131 | 3131 | | |
3132 | | - | |
| 3132 | + | |
3133 | 3133 | | |
3134 | 3134 | | |
3135 | 3135 | | |
| |||
3326 | 3326 | | |
3327 | 3327 | | |
3328 | 3328 | | |
3329 | | - | |
| 3329 | + | |
3330 | 3330 | | |
3331 | 3331 | | |
3332 | 3332 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1295 | 1295 | | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | | - | |
| 1298 | + | |
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
270 | 378 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | 432 | | |
458 | 433 | | |
459 | 434 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
0 commit comments