diff --git a/tests/test_containers/test_aws.py b/tests/test_containers/test_aws.py index 4532109..f6d1e8b 100644 --- a/tests/test_containers/test_aws.py +++ b/tests/test_containers/test_aws.py @@ -55,12 +55,8 @@ def test_sso_login(mocked_new_tab, aws_container, fake_os_user, propagate_logs, container_args = aws_container.client.api.create_container.call_args_list[0][1] # make sure we: point to the correct script - assert container_args["command"] == "/root/scripts/aws-sso/aws-sso-login.sh" + assert container_args["command"] == "/opt/scripts/aws-sso/aws-sso-login.sh" # the browser tab points to the correct code and the correct region assert mocked_new_tab.call_args[0][0] == "https://device.sso.us-east-1.amazonaws.com/?user_code=TEST-CODE" - # ownership of the files was given back - container_args = aws_container.client.api.create_container.call_args_list[1][1] - assert container_args["command"] == "chown 1234:5678 -R /root/tmp/test" - assert mocked_new_tab.call_args[0][0] == test_link # and the fallback method is printed assert caplog.messages[0] == aws_container.FALLBACK_LINK_MSG.format(link=test_link) diff --git a/tests/test_containers/test_kubectl.py b/tests/test_containers/test_kubectl.py index 8435e4e..51895f1 100644 --- a/tests/test_containers/test_kubectl.py +++ b/tests/test_containers/test_kubectl.py @@ -57,14 +57,15 @@ def test_start_shell(kubectl_container): assert container_args["entrypoint"] == "" # make sure we are pointing to the AWS credentials - assert container_args["environment"]["AWS_CONFIG_FILE"] == "/root/tmp/test/config" - assert container_args["environment"]["AWS_SHARED_CREDENTIALS_FILE"] == "/root/tmp/test/credentials" + assert container_args["environment"]["AWS_CONFIG_FILE"] == "/home/leverage/tmp/test/config" + assert container_args["environment"]["AWS_SHARED_CREDENTIALS_FILE"] == "/home/leverage/tmp/test/credentials" # make sure we mounted the .kube config folder - assert next(m for m in container_args["host_config"]["Mounts"] if m["Target"] == "/root/.kube") + print(container_args["host_config"]) + assert next(m for m in container_args["host_config"]["Mounts"] if m["Target"] == "/home/leverage/.kube") # and the aws config folder - assert next(m for m in container_args["host_config"]["Mounts"] if m["Target"] == "/root/tmp/test") + assert next(m for m in container_args["host_config"]["Mounts"] if m["Target"] == "/home/leverage/tmp/test") # don't rely on the filesystem @@ -75,7 +76,7 @@ def test_configure(kubectl_container, fake_os_user): with patch.object(kubectl_container, "_start", return_value=0) as mock_start: kubectl_container.configure() - assert mock_start.call_args[0][0] == f'bash -c "{AWS_EKS_UPDATE_KUBECONFIG} && chown 1234:5678 /root/.kube/config"' + assert mock_start.call_args[0][0] == AWS_EKS_UPDATE_KUBECONFIG ##################### @@ -96,11 +97,11 @@ def test_start_shell_mfa(kubectl_container): # we want a shell, so -> /bin/bash with no entrypoint assert container_args["command"] == "/bin/bash" - assert container_args["entrypoint"] == "/root/scripts/aws-mfa/aws-mfa-entrypoint.sh -- " + assert container_args["entrypoint"] == "/opt/scripts/aws-mfa/aws-mfa-entrypoint.sh -- " # make sure we are pointing to the right AWS credentials: /.aws/ folder for MFA - assert container_args["environment"]["AWS_CONFIG_FILE"] == "/root/.aws/test/config" - assert container_args["environment"]["AWS_SHARED_CREDENTIALS_FILE"] == "/root/.aws/test/credentials" + assert container_args["environment"]["AWS_CONFIG_FILE"] == "/home/leverage/.aws/test/config" + assert container_args["environment"]["AWS_SHARED_CREDENTIALS_FILE"] == "/home/leverage/.aws/test/credentials" @patch("leverage.container.refresh_layer_credentials") @@ -118,5 +119,5 @@ def test_start_shell_sso(mock_refresh, kubectl_container): assert mock_refresh.called_once # make sure we are pointing to the right AWS credentials: /tmp/ folder for SSO - assert container_args["environment"]["AWS_CONFIG_FILE"] == "/root/tmp/test/config" - assert container_args["environment"]["AWS_SHARED_CREDENTIALS_FILE"] == "/root/tmp/test/credentials" + assert container_args["environment"]["AWS_CONFIG_FILE"] == "/home/leverage/tmp/test/config" + assert container_args["environment"]["AWS_SHARED_CREDENTIALS_FILE"] == "/home/leverage/tmp/test/credentials" diff --git a/tests/test_containers/test_leverage.py b/tests/test_containers/test_leverage.py index 35eaaf5..8eca98d 100644 --- a/tests/test_containers/test_leverage.py +++ b/tests/test_containers/test_leverage.py @@ -9,14 +9,6 @@ def leverage_container(muted_click_context): return container_fixture_factory(LeverageContainer) -def test_change_ownership_cmd(leverage_container, fake_os_user): - assert leverage_container.change_ownership_cmd("/tmp/", recursive=True) == "chown 1234:5678 -R /tmp/" - - -def test_change_ownership_non_recursive_cmd(leverage_container, fake_os_user): - assert leverage_container.change_ownership_cmd("/tmp/file.txt", recursive=False) == "chown 1234:5678 /tmp/file.txt" - - def test_mounts(muted_click_context): container = container_fixture_factory( LeverageContainer, mounts=(("/usr/bin", "/usr/bin"), ("/tmp/file.txt", "/tmp/file.txt")) diff --git a/tests/test_containers/test_terraform.py b/tests/test_containers/test_terraform.py index 4c91e2d..1d61b65 100644 --- a/tests/test_containers/test_terraform.py +++ b/tests/test_containers/test_terraform.py @@ -51,7 +51,7 @@ def test_auth_method_mfa_enabled(terraform_container): terraform_container.sso_enabled = False terraform_container.mfa_enabled = True - assert terraform_container.auth_method() == "/root/scripts/aws-mfa/aws-mfa-entrypoint.sh -- " + assert terraform_container.auth_method() == "/opt/scripts/aws-mfa/aws-mfa-entrypoint.sh -- " def test_auth_method_else(terraform_container):