Owen-CH-Leung commented on code in PR #71692:
URL: https://github.com/apache/airflow/pull/71692#discussion_r3835737608
##########
providers/opensearch/tests/unit/opensearch/log/test_os_task_handler.py:
##########
@@ -786,6 +831,48 @@ def test_upload_returns_early_when_ti_is_none(self,
tmp_path):
log_file.write_text('{"message": "test"}\n')
self.opensearch_io.upload(log_file, ti=None)
+ @pytest.mark.parametrize(
+ ("username", "password"),
+ [
+ ("admin", "secret"),
+ ("admin", ""),
+ ("", "secret"),
+ ],
+ )
+ def test_client_with_auth(self, username, password):
+ """If either username or password are provided, the IO should pass
http_auth to the client."""
+ opensearch_io = OpensearchRemoteLogIO(
+ write_to_opensearch=True,
+ write_stdout=True,
+ delete_local_copy=True,
+ host="localhost",
+ port=9200,
+ username=username,
+ password=password,
+ base_log_folder=self.opensearch_io.base_log_folder,
+
log_id_template="{dag_id}-{task_id}-{run_id}-{map_index}-{try_number}",
+ )
+
+ transport_args = opensearch_io.client.transport.kwargs
+ assert "http_auth" in transport_args
+ assert transport_args["http_auth"] == (username, password)
+
+ def test_client_no_auth(self):
Review Comment:
I think it's better to combine both test into one ? something like :
```
@pytest.mark.parametrize(
("username", "password", "expect_auth"),
[
("admin", "secret", True),
("admin", "", True),
("", "secret", True),
("", "", False),
],
)
```
--
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]