seanghaeli commented on code in PR #74775:
URL: https://github.com/apache/airflow/pull/74775#discussion_r4300034966
##########
providers/amazon/tests/unit/amazon/aws/hooks/test_eks.py:
##########
@@ -1212,6 +1215,86 @@ def test_create_fargate_selectors(self, cluster_builder,
selectors, expected_mes
class TestEksHook:
python_executable = f"python{sys.version_info[0]}.{sys.version_info[1]}"
+ @mock.patch.object(EksHook, "generate_config_file", autospec=True)
+ @mock.patch.object(EksHook, "get_session", autospec=True)
+ def test_generate_config_file_with_credentials(self, get_session,
generate_config):
+ hook = EksHook(aws_conn_id=None)
+ session = mock.create_autospec(Session, instance=True)
+ session.get_credentials.return_value = Credentials("access-key",
"secret-key", "session-token")
+ get_session.return_value = session
+ config_context = mock.MagicMock(spec=AbstractContextManager)
+ config_context.__enter__.return_value = "/tmp/kubeconfig"
+ generate_config.return_value = config_context
+
+ with hook.generate_config_file_with_credentials("cluster",
"namespace") as (config, credentials):
+ assert config == "/tmp/kubeconfig"
+ assert Path(credentials).read_text() == (
+ "export AWS_ACCESS_KEY_ID='access-key'\n"
+ "export AWS_SECRET_ACCESS_KEY='secret-key'\n"
+ "export AWS_SESSION_TOKEN='session-token'\n"
+ )
Review Comment:
```suggestion
)
config_context.__exit__.assert_not_called()
```
We want to verify the kubeconfig context hasn't exited yet while the caller
is still using it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]