def test_06_test_radius(self): radiusmock.setdata(success=False) r = test_radius(identifier="myserver", server="1.2.3.4", user="******", password="******", secret="testing123", dictionary=DICT_FILE) self.assertFalse(r) radiusmock.setdata(success=True) r = test_radius(identifier="myserver", server="1.2.3.4", user="******", password="******", secret="testing123", dictionary=DICT_FILE) self.assertTrue(r) # raises error on long secrets self.assertRaises(privacyIDEAError, test_radius, identifier="myserver", server="1.2.3.4", user="******", password="******", secret="x" * 96, dictionary=DICT_FILE)
def test(): """ Test the RADIUS definition :return: """ param = request.all_data identifier = getParam(param, "identifier", required) server = getParam(param, "server", required) port = int(getParam(param, "port", default=1812)) secret = getParam(param, "secret", required) retries = int(getParam(param, "retries", default=3)) timeout = int(getParam(param, "timeout", default=5)) user = getParam(param, "username", required) password = getParam(param, "password", required) dictionary = getParam(param, "dictionary", default="/etc/privacyidea/dictionary") r = test_radius(identifier, server, secret, user, password, port=port, dictionary=dictionary, retries=retries, timeout=timeout) g.audit_object.log({'success': r > 0, 'info': r}) return send_result(r > 0)