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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    def assertPamReturns(self, user, service, rc,
                         host=None, pam_mod_opts=None,
                         additional_modules=None,
                         start_ssl=True):
        if host is None:
            host = self.client_hostname
        self._config_setup(host, start_ssl)

        svc_file = self._write_pam_svc_file(service,
                                            self.ph_abspath,
                                            self.config_file.name,
                                            pam_mod_opts,
                                            additional_modules)
        try:
            tc = pypamtest.TestCase(pypamtest.PAMTEST_ACCOUNT, rc)
            self._run_pwrap_test(tc, user, service)
        finally:
            os.unlink(svc_file.name)
    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)
Ejemplo n.º 10
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:
            self.assertEqual(res.info[0],
                             u"Your password will expire in 42 days.\n")
        else:
            self.assertEqual(warn_pwd_expire, 0)