-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added integration test and converted from username to userid for memb…
…ership lookup
- Loading branch information
Showing
6 changed files
with
35 additions
and
31 deletions.
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
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 |
---|---|---|
|
@@ -163,7 +163,7 @@ def mock_workspace_client( | |
): | ||
ws = create_autospec(WorkspaceClient) | ||
ws.current_user.me.side_effect = lambda: iam.User( | ||
user_name="[email protected]", groups=[iam.ComplexValue(display="admins")] | ||
id="666", user_name="[email protected]", groups=[iam.ComplexValue(display="admins")] | ||
) | ||
ws.api_client.do.return_value = {} | ||
ws.permissions.get.return_value = {} | ||
|
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 |
---|---|---|
|
@@ -8,15 +8,13 @@ | |
import yaml | ||
from databricks.labs.lsql.backends import MockBackend | ||
from databricks.labs.lsql.core import Row | ||
from databricks.sdk import WorkspaceClient | ||
from databricks.sdk.service.iam import ComplexValue, Group | ||
|
||
from databricks.labs.ucx.__about__ import __version__ as ucx_version | ||
from databricks.labs.ucx.contexts.workspace_cli import WorkspaceContext | ||
from databricks.labs.ucx.framework.owners import AdministratorLocator | ||
from databricks.labs.ucx.hive_metastore.catalog_schema import Catalog, Schema | ||
from databricks.labs.ucx.hive_metastore.grants import Grant, GrantsCrawler, MigrateGrants, GrantOwnership | ||
from databricks.labs.ucx.hive_metastore.ownership import DefaultSecurableOwnership | ||
from databricks.labs.ucx.hive_metastore.tables import Table, TablesCrawler | ||
from databricks.labs.ucx.hive_metastore.udfs import UdfsCrawler | ||
from databricks.labs.ucx.progress.history import ProgressEncoder | ||
|
@@ -223,7 +221,7 @@ def test_crawler_crawl() -> None: | |
"SHOW GRANTS ON CATALOG `hive_metastore`": SHOW_GRANTS[("princ1", "USE", "CATALOG$", "hive_metastore"),], | ||
"SHOW GRANTS ON DATABASE `hive_metastore`\\.`database_one`": SHOW_GRANTS[ | ||
("princ2", "OWN", "DATABASE", "database_one"), | ||
# Enumerating database grants can include some grants for the catalog. | ||
# Enumerating database grants can include some grants for the catalog. | ||
("princ1", "SELECT", "CATALOG$", None), | ||
], | ||
"SHOW GRANTS ON VIEW `hive_metastore`\\.`database_one`\\.`table_one`": SHOW_GRANTS[ | ||
|
@@ -959,14 +957,9 @@ def test_grant_supports_history(mock_backend, grant_record: Grant, history_recor | |
assert rows == [history_record] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"member, expected", | ||
[ | ||
("[email protected]", "owners"), | ||
("[email protected]", None) | ||
] | ||
) | ||
def test_default_owner(member, expected) -> None: | ||
# Testing the validation in retrival of the default owner group. 666 is the current_user user_id. | ||
@pytest.mark.parametrize("user_id, expected", [("666", "owners"), ("777", None)]) | ||
def test_default_owner(user_id, expected) -> None: | ||
ws = mock_workspace_client() | ||
download_yaml = { | ||
'config.yml': yaml.dump( | ||
|
@@ -984,9 +977,9 @@ def test_default_owner(member, expected) -> None: | |
} | ||
|
||
ws.workspace.download.side_effect = lambda file_name: io.StringIO(download_yaml[os.path.basename(file_name)]) | ||
account_admins_group = Group(id="1234", | ||
display_name="owners", | ||
members=[ComplexValue(display=member, value="1")]) | ||
account_admins_group = Group( | ||
id="1234", display_name="owners", members=[ComplexValue(display="User Name", value=user_id)] | ||
) | ||
ws.api_client.do.return_value = { | ||
"Resources": [account_admins_group.as_dict()], | ||
} | ||
|
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