Ejemplo n.º 1
0
 def test_variable_length_in_possible_tokens(self):
     """
     Check if length is respected when verifying tokens
     """
     # When default is length of 6:
     self.assertFalse(_is_possible_token(1234567))
     # Longer version:
     self.assertTrue(_is_possible_token(1234567, token_length=7))
     # Shorter version, when longer is allowed:
     self.assertTrue(_is_possible_token(123456, token_length=7))
     # Invalid token with correct length:
     self.assertFalse(_is_possible_token('abcdefg', token_length=7))
Ejemplo n.º 2
0
 def test_variable_length_in_possible_tokens(self):
     """
     Check if length is respected when verifying tokens
     """
     # When default is length of 6:
     self.assertFalse(_is_possible_token(1234567))
     # Longer version:
     self.assertTrue(_is_possible_token(1234567, token_length=7))
     # Shorter version, when longer is allowed:
     self.assertTrue(_is_possible_token(123456, token_length=7))
     # Invalid token with correct length:
     self.assertFalse(_is_possible_token('abcdefg', token_length=7))
Ejemplo n.º 3
0
    def test_is_possible_token_helper(self):
        """
        Checks ``_is_possible_token`` helper method for valid behaviour
        """
        # Properly formatted tokens:
        # integer
        self.assertTrue(_is_possible_token(123456))
        # bytes
        self.assertTrue(_is_possible_token(b'123456'))
        # unicode
        self.assertTrue(_is_possible_token(six.u('123456')))

        # token with invalid characters
        self.assertFalse(_is_possible_token(b'abcdef'))
        # token being too long
        self.assertFalse(_is_possible_token(b'12345678'))

        # similar cases as above, but for unicode
        self.assertFalse(_is_possible_token(six.u('abcdef')))
        self.assertFalse(_is_possible_token(six.u('12345678')))
Ejemplo n.º 4
0
    def test_is_possible_token_helper(self):
        """
        Checks ``_is_possible_token`` helper method for valid behaviour
        """
        # Properly formatted tokens:
        # integer
        self.assertTrue(_is_possible_token(123456))
        # bytes
        self.assertTrue(_is_possible_token(b'123456'))
        # unicode
        self.assertTrue(_is_possible_token(six.u('123456')))

        # token with invalid characters
        self.assertFalse(_is_possible_token(b'abcdef'))
        # token being too long
        self.assertFalse(_is_possible_token(b'12345678'))

        # similar cases as above, but for unicode
        self.assertFalse(_is_possible_token(six.u('abcdef')))
        self.assertFalse(_is_possible_token(six.u('12345678')))