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_r236365027
 
 

 ##########
 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:
   it sys.exit(1) - 
https://github.com/apache/incubator-airflow/blob/3dc9e4021786e2c2416956f83a1f19ea1052ff3b/airflow/security/kerberos.py#L62
 about assertLogs - okay, I will add it 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to