-
Notifications
You must be signed in to change notification settings - Fork 80
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
Capturing any file and anonymous function grants #653
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b62b999
Capturing Any file and anonymous function grants
prajin-29 c07afa2
Capturing Any file and anonymous function grants
prajin-29 7e6c3c8
Fixed Linting Errors
prajin-29 3c309f1
Added few more assertions
prajin-29 7b63b87
Added few more assertions
prajin-29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,50 @@ | |
logger = logging.getLogger(__name__) | ||
|
||
|
||
def test_permission_for_files_anonymous_func(sql_backend, inventory_schema, make_group): | ||
group_a = make_group() | ||
group_b = make_group() | ||
group_c = make_group() | ||
group_d = make_group() | ||
|
||
sql_backend.execute(f"GRANT READ_METADATA ON ANY FILE TO `{group_a.display_name}`") | ||
sql_backend.execute(f"GRANT SELECT ON ANONYMOUS FUNCTION TO `{group_c.display_name}`") | ||
|
||
tables = StaticTablesCrawler(sql_backend, inventory_schema, []) | ||
grants = GrantsCrawler(tables) | ||
|
||
tacl_support = TableAclSupport(grants, sql_backend) | ||
|
||
migration_state = MigrationState( | ||
[ | ||
MigratedGroup.partial_info(group_a, group_b), | ||
MigratedGroup.partial_info(group_c, group_d), | ||
] | ||
) | ||
for crawler_task in tacl_support.get_crawler_tasks(): | ||
permission = crawler_task() | ||
apply_task = tacl_support.get_apply_task(permission, migration_state) | ||
if not apply_task: | ||
continue | ||
apply_task() | ||
|
||
any_file_actual = {} | ||
for any_file_grant in grants._grants(any_file=True): | ||
any_file_actual[any_file_grant.principal] = any_file_grant.action_type | ||
|
||
assert group_b.display_name in any_file_actual | ||
assert any_file_actual[group_b.display_name] == "READ_METADATA" | ||
assert any_file_actual[group_a.display_name] == any_file_actual[group_b.display_name] | ||
|
||
anonymous_function_actual = {} | ||
for ano_func_grant in grants._grants(anonymous_function=True): | ||
anonymous_function_actual[ano_func_grant.principal] = ano_func_grant.action_type | ||
|
||
assert group_d.display_name in anonymous_function_actual | ||
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. Same here 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. Added the assertions |
||
assert anonymous_function_actual[group_d.display_name] == "SELECT" | ||
assert anonymous_function_actual[group_c.display_name] == anonymous_function_actual[group_d.display_name] | ||
|
||
|
||
def test_owner_permissions_for_tables_and_schemas(sql_backend, inventory_schema, make_schema, make_table, make_group): | ||
group_a = make_group() | ||
group_b = make_group() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you also assert the action type that new groups got as part of reassignment?
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.
Added the assertions