xnuinside commented on a change in pull request #4238: [AIRFLOW-987] pass
kerberos cli args keytab and principal to kerberos…
URL: https://github.com/apache/incubator-airflow/pull/4238#discussion_r236970400
##########
File path: tests/security/test_kerberos.py
##########
@@ -32,13 +33,26 @@ def setUp(self):
if not configuration.conf.has_section("kerberos"):
configuration.conf.add_section("kerberos")
-
- configuration.conf.set("kerberos",
- "keytab",
+ configuration.conf.set("kerberos", "keytab",
os.environ['KRB5_KTNAME'])
+ keytab_from_cfg = configuration.conf.get("kerberos", "keytab")
+ self.args = Namespace(keytab=keytab_from_cfg, principal=None, pid=None,
+ daemon=None, stdout=None, stderr=None,
log_file=None)
def test_renew_from_kt(self):
"""
We expect no result, but a successful run. No more TypeError
"""
- self.assertIsNone(renew_from_kt())
+ self.assertIsNone(renew_from_kt(args=self.args))
+
+ def test_args_from_cli(self):
+ """
+ We expect no result, but a run with sys.exit(1) because keytab not
exist.
+ """
+ configuration.conf.set("kerberos", "keytab", "")
+ self.args.keytab = "test_keytab"
+
+ with self.assertRaises(SystemExit) as se:
+ renew_from_kt(args=self.args)
Review comment:
@ashb New in version 3.4. method added only in 3.4, at 2.7 will fail with
` with self.assertLogs(LoggingMixin().log) as log:
AttributeError: 'KerberosTest' object has no attribute 'assertLogs'`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services