Beispiel #1
0
    def test_02_config_model(self):
        c = Config("splitRealm", True, Type="string", Description="something")

        cid = c.save()
        self.assertTrue(cid == "splitRealm", cid)
        self.assertTrue(u"{0!s}".format(c) == "<splitRealm (string)>", c)

        # delete the config
        config = Config.query.filter_by(Key="splitRealm").first()
        self.assertTrue(config.delete() == "splitRealm")
        q = Config.query.filter_by(Key="splitRealm").all()
        # the list is empty
        self.assertTrue(len(q) == 0, q)
Beispiel #2
0
 def test_02_config_model(self):
     c = Config("splitRealm", True,
                Type="string", Description="something")
     
     cid = c.save()
     self.assertTrue(cid == "splitRealm", cid)
     self.assertTrue(u"{0!s}".format(c) == "<splitRealm (string)>", c)
     
     # delete the config
     config = Config.query.filter_by(Key="splitRealm").first()
     self.assertTrue(config.delete() == "splitRealm")
     q = Config.query.filter_by(Key="splitRealm").all()
     # the list is empty
     self.assertTrue(len(q) == 0, q)
 def test_12_inc_otp_counter(self):
     db_token = Token.query.filter_by(serial=self.serial1).first()
     token = TokenClass(db_token)
     
     token.set_otp_count(10)
     self.assertTrue(token.token.count == 10, token.token.count)
     # increase counter by 1
     token.inc_otp_counter()
     self.assertTrue(token.token.count == 11, token.token.count)
     # increase counter to 21
     Config(Key="DefaultResetFailCount", Value=True).save()
     token.inc_otp_counter(counter=20)
     self.assertTrue(token.token.count == 21, token.token.count)
 def test_09_invalidate_config_object(self):
     # Test manual invalidation of the config object
     # Ensure we have a config object
     get_config_object()
     # Add a config option *without invalidating the config*
     db.session.add(Config(Key=u"some_key", Value=u"some_value"))
     save_config_timestamp(False)
     db.session.commit()
     # The request-local config does not know about the new config option
     self.assertEqual(get_from_config("some_key", "default"), "default")
     # ... so we manually invalidate it ...
     invalidate_config_object()
     # ... and the new config object knows!
     self.assertEqual(get_from_config("some_key", "default"), "some_value")