Esempio n. 1
0
    def __init__(self):

        self.delay = False
        self.realms = None
        self.glo = current_app.linotp_app_config
        conf = self.glo.getConfig()

        do_reload = False

        # do the bootstrap if no entry in the app_globals
        if len(list(conf.keys())) == 0:
            do_reload = True

        if self.glo.isConfigComplete() is False:
            do_reload = True
            self.delay = True

        if 'linotp.enableReplication' in conf:
            val = conf.get('linotp.enableReplication')
            if val.lower() == 'true':

                # look for the timestamp when config was created
                e_conf_date = conf.get('linotp.Config')

                # in case of replication, we always have to look if the
                # config data in the database changed
                db_conf_date = _retrieveConfigDB('linotp.Config')

                if str(db_conf_date) != str(e_conf_date):
                    do_reload = True

        self.refreshConfig(do_reload=do_reload)

        return
Esempio n. 2
0
    def test_storeConfigDB_encoding(self):
        # Test round trip of _storeConfigDB with entries that require
        # encoding of special characters
        conf = {
            'Key': 'linotp.TËST',
            'Value': 'VALUEÄ',
            'Type': 'TYPEß',
            'Description': 'DESCRIPTIÖN',
        }

        _storeConfigDB(conf['Key'], conf['Value'], conf['Type'],
                       conf['Description'])

        # Check value is correctly returned
        stored_value = _retrieveConfigDB(conf['Key'])
        assert conf['Value'] == stored_value

        # Check type, description in database
        entries = Session.query(Config).all()

        assert (len(entries) == 1)
        stored_conf = entries[0]

        for key in list(conf.keys()):
            assert conf[key] == getattr(stored_conf, key), \
                             "Key should match key:%s - expected %r, recevied %r" % (key, conf[key], getattr(stored_conf, key))
Esempio n. 3
0
    def test_storeConfigDB_encoding(self):
        # Test round trip of _storeConfigDB with entries that require
        # encoding of special characters
        conf = {
            'Key': u'linotp.TËST',
            'Value': u'VALUEÄ',
            'Type': u'TYPEß',
            'Description': u'DESCRIPTIÖN',
        }

        _storeConfigDB(conf['Key'], conf['Value'],
                       conf['Type'], conf['Description'])

        # Check value is correctly returned
        stored_value = _retrieveConfigDB(conf['Key'])
        self.assertEqual(conf['Value'], stored_value)

        # Check type, description in database
        entries = Session.query(Config).all()

        assert(len(entries) == 1)
        stored_conf = entries[0]

        for key in conf.keys():
            self.assertEqual(conf[key], getattr(stored_conf, key),
                             "Key should match key:%s - expected %r, recevied %r" % (key, conf[key], getattr(stored_conf, key)))
Esempio n. 4
0
    def test_storeConfigDB_encoding(self):
        # Test round trip of _storeConfigDB with entries that require
        # encoding of special characters
        conf = {
            "Key": "linotp.TËST",
            "Value": "VALUEÄ",
            "Type": "TYPEß",
            "Description": "DESCRIPTIÖN",
        }

        _storeConfigDB(conf["Key"], conf["Value"], conf["Type"],
                       conf["Description"])

        # Check value is correctly returned
        stored_value = _retrieveConfigDB(conf["Key"])
        assert conf["Value"] == stored_value

        # Check type, description in database
        entries = Config.query.all()

        assert len(entries) == 1
        stored_conf = entries[0]

        for key in list(conf.keys()):
            assert conf[key] == getattr(
                stored_conf,
                key), "Key should match key:%s - expected %r, recevied %r" % (
                    key,
                    conf[key],
                    getattr(stored_conf, key),
                )
Esempio n. 5
0
    def __init__(self, *args, **kw):
        self.parent = super(LinOtpConfig, self)
        self.parent.__init__(*args, **kw)

        self.delay = False
        self.realms = None
        self.glo = getGlobalObject()
        conf = self.glo.getConfig()

        do_reload = False

        # do the bootstrap if no entry in the app_globals
        if len(conf.keys()) == 0:
            do_reload = True

        if self.glo.isConfigComplet() is False:
            do_reload = True
            self.delay = True

        if 'linotp.enableReplication' in conf:
            val = conf.get('linotp.enableReplication')
            if val.lower() == 'true':

                # look for the timestamp when config was created
                e_conf_date = conf.get('linotp.Config')

                # in case of replication, we always have to look if the
                # config data in the database changed
                db_conf_date = _retrieveConfigDB('linotp.Config')

                if str(db_conf_date) != str(e_conf_date):
                    do_reload = True

        self.refreshConfig(do_reload=do_reload)

        return