Unit03 commented on a change in pull request #9615: URL: https://github.com/apache/airflow/pull/9615#discussion_r448568444
########## File path: tests/providers/apache/spark/hooks/test_spark_submit.py ########## @@ -748,3 +750,64 @@ def test_k8s_process_on_kill(self, mock_popen, mock_client_method): client.delete_namespaced_pod.assert_called_once_with( 'spark-pi-edf2ace37be7353a958b38733a12f8e6-driver', 'mynamespace', **kwargs) + + +@pytest.mark.parametrize( + ("command", "expected"), + ( + ( + ("spark-submit", "foo", "--bar", "baz", "--password='secret'"), + "spark-submit foo --bar baz --password='******'", + ), + ( + ("spark-submit", "foo", "--bar", "baz", '--password="secret"'), + 'spark-submit foo --bar baz --password="******"', + ), + ( + ("spark-submit", "foo", "--bar", "baz", "--password=secret"), + "spark-submit foo --bar baz --password=******", + ), + ( + ("spark-submit", "foo", "--bar", "baz", "--password 'secret'"), + "spark-submit foo --bar baz --password '******'", + ), + ( + ("spark-submit", "foo", "--bar", "baz", "--password secret"), + "spark-submit foo --bar baz --password ******", + ), + ( + ("spark-submit", "foo", "--bar", "baz", '--password "secret"'), + 'spark-submit foo --bar baz --password "******"', + ), + ( + ("spark-submit", "foo", "--bar", "baz", "--secret='secret'"), + "spark-submit foo --bar baz --secret='******'", + ), + ( + ("spark-submit", "foo", "--bar", "baz", "--foo.password='secret'"), + "spark-submit foo --bar baz --foo.password='******'", + ), + ( + ("spark-submit",), + "spark-submit", + ), + + ( + ("spark-submit", "foo", "--bar", "baz", "--password \"secret'"), + "spark-submit foo --bar baz --password \"secret'", + ), + ( + ("spark-submit", "foo", "--bar", "baz", "--password 'secret\""), + "spark-submit foo --bar baz --password 'secret\"", + ), + ), +) +def test_masks_passwords(command: str, expected: str) -> None: Review comment: I figured it would be a good place to use `pytest.mark.parameterize` - [but it doesn't go along with `unittest.TestCase`](https://docs.pytest.org/en/stable/unittest.html#pytest-features-in-unittest-testcase-subclasses). On the other hand, I get it that going with a separate function outside of the `TestSparkSubmitHook` class looks kind of awkward. Which way do we want this test to go? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org