tests: Define PAM_AUTH_ERROR in init function
authorAndreas Schneider <asn@samba.org>
Tue, 24 Mar 2020 07:37:24 +0000 (08:37 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 24 Mar 2020 07:38:02 +0000 (08:38 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
tests/pypamtest_test.py

index 84617353ab308512eb19f8e00f9031df616756a8..d49a1104e54569f839919551e3cb6d67b01fbce1 100755 (executable)
@@ -103,6 +103,13 @@ class PyPamTestTestResult(PyPamTestCase):
                          "{ errors: { {info}{list} } infos: { {info}{list} } }")
 
 class PyPamTestRunTest(unittest.TestCase):
+    def __init__(self, *args, **kwargs):
+        super(PyPamTestRunTest, self).__init__(*args, **kwargs)
+
+        self.PAM_AUTH_ERR = 7
+        if ("BSD" in platform.system()):
+            self.PAM_AUTH_ERR = 9
+
     def test_run(self):
         neo_password = "secret"
         tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE)
@@ -118,12 +125,7 @@ class PyPamTestRunTest(unittest.TestCase):
 
     def test_run_failed_auth(self):
         neo_password = "not-the-secret"
-        rv = 7 # PAM_AUTH_ERR
-
-        # On SRV4 the PAM_AUTH_ERR is 9
-        if ("BSD" in platform.system()):
-            rv = 9
-        tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=rv)
+        tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=self.PAM_AUTH_ERR)
         res = pypamtest.run_pamtest("neo", "matrix_py", [tc], [ neo_password ])
 
     def test_run_chatty_auth(self):