Skip to content

Commit

Permalink
Test mounts are crawled for create uber service principal
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Sep 16, 2024
1 parent ce754ac commit caa5496
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,29 @@ def test_create_aws_uber_principal_raises_value_error_if_aws_profile_is_missing(
create_uber_principal(ws, prompts, ctx=ctx)


def successful_aws_cli_call(_):
successful_return = """
{
"UserId": "uu@mail.com",
"Account": "1234",
"Arn": "arn:aws:sts::1234:assumed-role/AWSVIEW/uu@mail.com"
}
"""
return 0, successful_return, ""


def test_create_aws_uber_principal_calls_dbutils_fs_mounts(ws) -> None:
ctx = WorkspaceContext(ws).replace(
is_azure=False,
is_aws=True,
aws_profile="test",
aws_cli_run_command=successful_aws_cli_call,
)
prompts = MockPrompts({})
create_uber_principal(ws, prompts, ctx=ctx)
ws.dbutils.fs.mounts.assert_called_once()


def test_migrate_locations_azure(ws):
azurerm = create_autospec(AzureResources)
ctx = WorkspaceContext(ws).replace(
Expand All @@ -628,22 +651,11 @@ def test_migrate_locations_azure(ws):


def test_migrate_locations_aws(ws, caplog):
successful_return = """
{
"UserId": "uu@mail.com",
"Account": "1234",
"Arn": "arn:aws:sts::1234:assumed-role/AWSVIEW/uu@mail.com"
}
"""

def successful_call(_):
return 0, successful_return, ""

ctx = WorkspaceContext(ws).replace(
is_aws=True,
is_azure=False,
aws_profile="profile",
aws_cli_run_command=successful_call,
aws_cli_run_command=successful_aws_cli_call,
)
migrate_locations(ws, ctx=ctx)
ws.external_locations.list.assert_called()
Expand Down

0 comments on commit caa5496

Please sign in to comment.