Exemplo n.º 1
0
    def test_burned_nonce(self):
        nonce = '001' + time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                      time.gmtime()) + '123456'
        nonce2 = '001' + time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                       time.gmtime()) + '654321'
        logger.debug('nonce=%s, nonce2=%s', nonce, nonce2)

        self.assertFalse(utils.verify_and_burn_nonce(nonce))
        self.assertFalse(utils.verify_and_burn_nonce(nonce))

        self.assertFalse(utils.verify_and_burn_nonce(nonce2))
        self.assertFalse(utils.verify_and_burn_nonce(nonce2))
Exemplo n.º 2
0
    def test_almost_future_nonce(self):
        now = int(time.time())
        then = now+((2*60)-3)   # three seconds avoids possible race condition
        nonce = '001' + time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                      time.gmtime(then)) + '123456'
        logger.debug('nonce=%s', nonce)

        self.assertFalse(utils.verify_and_burn_nonce(nonce))
Exemplo n.º 3
0
    def test_almost_expired_nonce(self):
        now = int(time.time())
        nbf = datetime.utcfromtimestamp(now - 3).replace(tzinfo=tz.tzutc())
        nonce = '001' + time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                      time.gmtime(now)) + '123456'
        logger.debug('nonce=%s, nbf=%s', nonce, nbf)

        self.assertFalse(utils.verify_and_burn_nonce(nonce, nbf))
Exemplo n.º 4
0
    def test_invalid_nonce(self):
        nonce = '002' + time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                      time.gmtime()) + '123456'
        logger.debug('nonce=%s', nonce)

        self.assertFalse(utils.verify_and_burn_nonce(nonce))