コード例 #1
0
    def test_01_config(self):
        self.assertEqual(get_app_config(), current_app.config)
        self.assertEqual(get_app_config()["SUPERUSER_REALM"], ["adminrealm"])

        self.assertEqual(get_app_config_value("SUPERUSER_REALM"), ["adminrealm"])
        self.assertEqual(get_app_config_value("DOES_NOT_EXIST"), None)
        self.assertEqual(get_app_config_value("DOES_NOT_EXIST", 1337), 1337)
コード例 #2
0
    def test_01_config(self):
        self.assertEqual(get_app_config(), current_app.config)
        self.assertEqual(get_app_config()["SUPERUSER_REALM"], ["adminrealm"])

        self.assertEqual(get_app_config_value("SUPERUSER_REALM"), ["adminrealm"])
        self.assertEqual(get_app_config_value("DOES_NOT_EXIST"), None)
        self.assertEqual(get_app_config_value("DOES_NOT_EXIST", 1337), 1337)
コード例 #3
0
def get_taskmodule(identifier, config=None):
    """
    Return an instance of the given task module. Raise ParameterError if it does not exist.
    :param identifier: identifier of the task module
    :return: instance of a BaseTask subclass
    """
    if identifier not in TASK_MODULES:
        raise ParameterError(u"Unknown task module: {!r}".format(identifier))
    else:
        r = TASK_MODULES[identifier](config=get_app_config())
        return r
コード例 #4
0
def get_taskmodule(identifier, config=None):
    """
    Return an instance of the given task module. Raise ParameterError if it does not exist.
    :param identifier: identifier of the task module
    :return: instance of a BaseTask subclass
    """
    if identifier not in TASK_MODULES:
        raise ParameterError(u"Unknown task module: {!r}".format(identifier))
    else:
        r = TASK_MODULES[identifier](config=get_app_config())
        return r
コード例 #5
0
ファイル: crypto.py プロジェクト: segfault/privacyidea
def init_hsm():
    """
    Initialize the HSM in the app-local store

    The config file pi.cfg may contain PI_HSM_MODULE and parameters like:
    PI_HSM_MODULE_MODULE
    PI_HSM_MODULE_SLOT_ID...

    :return: hsm object
    """
    app_store = get_app_local_store()
    if "pi_hsm" not in app_store or not isinstance(app_store["pi_hsm"], dict):
        config = get_app_config()
        HSM_config = {"obj": create_hsm_object(config)}
        app_store["pi_hsm"] = HSM_config
        log.info("Initialized HSM object {0}".format(HSM_config))
    return app_store["pi_hsm"]["obj"]
コード例 #6
0
ファイル: crypto.py プロジェクト: salvorapi/privacyidea
def init_hsm():
    """
    Initialize the HSM in the app-local store

    The config file pi.cfg may contain PI_HSM_MODULE and parameters like:
    PI_HSM_MODULE_MODULE
    PI_HSM_MODULE_SLOT_ID...

    :return: hsm object
    """
    app_store = get_app_local_store()
    if "pi_hsm" not in app_store or not isinstance(app_store["pi_hsm"], dict):
        config = get_app_config()
        HSM_config = {"obj": create_hsm_object(config)}
        app_store["pi_hsm"] = HSM_config
        log.info("Initialized HSM object {0}".format(HSM_config))
    return app_store["pi_hsm"]["obj"]
コード例 #7
0
def _get_monitoring():
    """
    This wrapper function creates a new monitoring object based on the config
    from the config file. The config file entry could look like this:

        PI_MONITORING_MODULE = privacyidea.lib.monitoringmodule.sqlstats

    Each monitoring module can have its own config values.

    :return: Monitoring Object
    """
    store = get_request_local_store()
    # check if the monitoring object is not yet in this request_store
    if 'monitoring_object' not in store:
        config = get_app_config()
        monitoring_module = config.get(
            "PI_MONITORING_MODULE",
            "privacyidea.lib.monitoringmodules.sqlstats")
        monitoring = get_module_class(monitoring_module, "Monitoring")(config)
        store['monitoring_object'] = monitoring
    return store.get('monitoring_object')