예제 #1
0
    def test_cache_validation(self):
        """cache correctly validates"""
        version = cachebuster.get_version(self.cache_name)
        self.assertEqual(version, 0)

        db_version = CacheVersion.objects.get(cache=self.cache_name).version
        self.assertEqual(db_version, 0)

        self.assertEqual(db_version, version)
        self.assertTrue(cachebuster.is_valid(self.cache_name, version))
        self.assertTrue(cachebuster.is_valid(self.cache_name, db_version))
예제 #2
0
    def test_cache_invalidation(self):
        """invalidate has increased valid version number"""
        db_version = CacheVersion.objects.get(cache=self.cache_name).version
        cachebuster.invalidate(self.cache_name)

        new_version = cachebuster.get_version(self.cache_name)
        new_db_version = CacheVersion.objects.get(cache=self.cache_name)
        new_db_version = new_db_version.version

        self.assertEqual(new_version, 1)
        self.assertEqual(new_db_version, 1)
        self.assertEqual(new_version, new_db_version)
        self.assertFalse(cachebuster.is_valid(self.cache_name, db_version))
        self.assertTrue(cachebuster.is_valid(self.cache_name, new_db_version))
예제 #3
0
파일: bans.py 프로젝트: qhhonx/Misago
    def is_valid(self):
        version_is_valid = cachebuster.is_valid(BAN_CACHEBUSTER,
                                                self.bans_version)
        date_today = timezone.now().date()
        not_expired = not self.valid_until or self.valid_until > date_today

        return version_is_valid and not_expired
예제 #4
0
파일: bans.py 프로젝트: dahito/Misago
    def is_valid(self):
        version_is_valid = cachebuster.is_valid(BAN_CACHEBUSTER,
                                                self.bans_version)
        date_today = timezone.now().date()
        not_expired = not self.valid_until or self.valid_until > date_today

        return version_is_valid and not_expired
예제 #5
0
파일: bans.py 프로젝트: jasonlife/Misago
def _get_session_bancache(request):
    try:
        ban_cache = request.session[CACHE_SESSION_KEY]
        ban_cache = _hydrate_session_cache(ban_cache)
        if ban_cache['ip'] != request.user_ip:
            return None
        if not cachebuster.is_valid(VERSION_KEY, ban_cache['version']):
            return None
        if ban_cache.get('expires_on'):
            if ban_cache['expires_on'] < timezone.today():
                return None
        return ban_cache
    except KeyError:
        return None
예제 #6
0
def _get_session_bancache(request):
    try:
        ban_cache = request.session[CACHE_SESSION_KEY]
        ban_cache = _hydrate_session_cache(ban_cache)
        if ban_cache['ip'] != request.user_ip:
            return None
        if not cachebuster.is_valid(VERSION_KEY, ban_cache['version']):
            return None
        if ban_cache.get('expires_on'):
            if ban_cache['expires_on'] < timezone.today():
                return None
        return ban_cache
    except KeyError:
        return None
예제 #7
0
def _get_session_bancache(request):
    try:
        ban_cache = request.session[BAN_CACHE_SESSION_KEY]
        ban_cache = _hydrate_session_cache(ban_cache)
        if ban_cache['ip'] != request._misago_real_ip:
            return None
        if not cachebuster.is_valid(BAN_VERSION_KEY, ban_cache['version']):
            return None
        if ban_cache.get('valid_until'):
            """
            Make two timezone unaware dates and compare them
            """
            if ban_cache.get('valid_until') < date.today():
                return None
        return ban_cache
    except KeyError:
        return None
예제 #8
0
파일: bans.py 프로젝트: CAvancouver/Misago
def _get_session_bancache(request):
    try:
        ban_cache = request.session[BAN_CACHE_SESSION_KEY]
        ban_cache = _hydrate_session_cache(ban_cache)
        if ban_cache['ip'] != request._misago_real_ip:
            return None
        if not cachebuster.is_valid(BAN_VERSION_KEY, ban_cache['version']):
            return None
        if ban_cache.get('expires_on'):
            """
            Hydrate ban date
            """
            if ban_cache['expires_on'] < timezone.today():
                return None
        return ban_cache
    except KeyError:
        return None
예제 #9
0
파일: bans.py 프로젝트: pombreda/Misago
def _get_session_bancache(request):
    try:
        ban_cache = request.session[BAN_CACHE_SESSION_KEY]
        ban_cache = _hydrate_session_cache(ban_cache)
        if ban_cache['ip'] != request._misago_real_ip:
            return None
        if not cachebuster.is_valid(BAN_VERSION_KEY, ban_cache['version']):
            return None
        if ban_cache.get('expires_on'):
            """
            Hydrate ban date
            """
            if ban_cache['expires_on'] < timezone.today():
                return None
        return ban_cache
    except KeyError:
        return None
예제 #10
0
파일: bans.py 프로젝트: ZerGabriel/Misago
def _get_session_bancache(request):
    try:
        ban_cache = request.session[BAN_CACHE_SESSION_KEY]
        ban_cache = _hydrate_session_cache(ban_cache)
        if ban_cache["ip"] != request.user_ip:
            return None
        if not cachebuster.is_valid(BAN_VERSION_KEY, ban_cache["version"]):
            return None
        if ban_cache.get("expires_on"):
            """
            Hydrate ban date
            """
            if ban_cache["expires_on"] < timezone.today():
                return None
        return ban_cache
    except KeyError:
        return None
예제 #11
0
def is_valid(version):
    return cachebuster.is_valid(ACL_CACHEBUSTER, version)
예제 #12
0
파일: ban.py 프로젝트: ZerGabriel/Misago
    def is_valid(self):
        version_is_valid = cachebuster.is_valid(BAN_CACHEBUSTER,
                                                self.bans_version)
        expired = self.expires_on and self.expires_on < timezone.now()

        return version_is_valid and not expired
예제 #13
0
    def is_valid(self):
        version_is_valid = cachebuster.is_valid(BAN_CACHEBUSTER,
                                                self.bans_version)
        expired = self.expires_on and self.expires_on < timezone.now()

        return version_is_valid and not expired
예제 #14
0
파일: version.py 프로젝트: 1905410/Misago
def is_valid(version):
    return cb.is_valid(ACL_CACHE_NAME, version)
예제 #15
0
def is_valid(version):
    return cb.is_valid(ACL_CACHE_NAME, version)