def test_auth_expire_warning(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = os.environ["PASSWORD"] warn_pwd_expire = int(os.environ["WARN_PWD_EXPIRE"]) if domain != "": unix_username = "******" % (domain, username) else: unix_username = "******" % username expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) try: res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) except pypamtest.PamTestError as e: raise AssertionError(str(e)) self.assertTrue(res is not None) if warn_pwd_expire == 0: self.assertTrue(res.info == ()) elif warn_pwd_expire == 50: # This is needed as otherwise a build started around # midnight can fail if (res.info[0] != u"Your password will expire in 41 days.\n") and \ (res.info[0] != u"Your password will expire in 43 days.\n"): self.assertEqual(res.info[0], u"Your password will expire in 42 days.\n") else: self.assertEqual(warn_pwd_expire, 0)
def test_authenticate_error(self): alice_password = "******" expected_rc = 7 # PAM_AUTH_ERR tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest("SAMBADOMAIN/alice", "samba", [tc], [alice_password]) self.assertTrue(res != None)
def test_authenticate(self): alice_password = "******" expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest("SAMBADOMAIN/alice", "samba", [tc], [alice_password]) self.assertTrue(res != None)
def test_authenticate(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = os.environ["PASSWORD"] unix_username = "******" % (domain, username) expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res is not None)
def test_authenticate(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = os.environ["PASSWORD"] unix_username = "******" % (domain, username) expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res != None)
def test_authenticate_error(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = "******" unix_username = "******" % (domain, username) expected_rc = 7 # PAM_AUTH_ERR tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res != None)
def test_authenticate_error(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = "******" unix_username = "******" % (domain, username) expected_rc = 7 # PAM_AUTH_ERR tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res is not None) # Authenticate again to check that we are not locked out with just one # failed login password = os.environ["PASSWORD"] expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res is not None)
def test_run(self): neo_password = "******" tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE) res = pypamtest.run_pamtest("neo", "matrix_py", [tc], [ neo_password ]) # No messages from this test -> both info and err should be empty tuples self.assertTrue(res != None) self.assertTrue(hasattr(res, 'info')) self.assertTrue(hasattr(res, 'errors')) # Running with verbose mode so there would be an info message self.assertSequenceEqual(res.info, (u'Authentication succeeded',)) self.assertSequenceEqual(res.errors, ())
def test_authenticate_error(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = "******" unix_username = "******" % (domain, username) expected_rc = 7 # PAM_AUTH_ERR tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res != None) # Authenticate again to check that we are not locked out with just one # failed login password = os.environ["PASSWORD"] expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res != None)
def test_chauthtok(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = os.environ["PASSWORD"] newpassword = os.environ["NEWPASSWORD"] unix_username = "******" % (domain, username) expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_CHAUTHTOK, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password, newpassword, newpassword]) self.assertTrue(res is not None)
def test_chauthtok(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = os.environ["PASSWORD"] newpassword = os.environ["NEWPASSWORD"] if domain != "": unix_username = "******" % (domain, username) else: unix_username = "******" % username expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_CHAUTHTOK, expected_rc) try: res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password, newpassword, newpassword]) except pypamtest.PamTestError as e: raise AssertionError(str(e)) self.assertTrue(res is not None)
def test_auth_expire_warning(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = os.environ["PASSWORD"] warn_pwd_expire = int(os.environ["WARN_PWD_EXPIRE"]) unix_username = "******" % (domain, username) expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res != None) if warn_pwd_expire == 0: self.assertTrue(res.info == ()) elif warn_pwd_expire == 50: self.assertEqual(res.info[0], u"Your password will expire in 42 days.\n") else: self.assertEqual(warn_pwd_expire, 0)
def test_auth_expire_warning(self): domain = os.environ["DOMAIN"] username = os.environ["USERNAME"] password = os.environ["PASSWORD"] warn_pwd_expire = int(os.environ["WARN_PWD_EXPIRE"]) unix_username = "******" % (domain, username) expected_rc = 0 # PAM_SUCCESS tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) self.assertTrue(res != None) if warn_pwd_expire == 0: self.assertTrue(res.info == ()) elif warn_pwd_expire == 50: # This is needed as otherwise a build started around # midnight can fail if (res.info[0] != u"Your password will expire in 41 days.\n") and \ (res.info[0] != u"Your password will expire in 43 days.\n"): self.assertEqual(res.info[0], u"Your password will expire in 42 days.\n") else: self.assertEqual(warn_pwd_expire, 0)
def _run_pwrap_test(self, tc, user, service): res = pypamtest.run_pamtest(user, service, [tc])