コード例 #1
0
    def test_sha512salt_get(self):
        '''This test case ensures sha512 with salt passwords hasher can be instantiated using the factory.'''

        sha512_hasher = PasswordsHasherFactory().get_hasher(
            PasswordsHasherFactory.SHA512_SALT)

        self.assertIsInstance(sha512_hasher, Sha512SaltPasswordsHasher)
コード例 #2
0
class PasswordsHasherFactoryTests(FantasticoUnitTestsCase):
    '''This class provides the tests suite which ensures passwords hasher factory correct behavior.'''

    _factory = None

    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()

    def test_sha512salt_get(self):
        '''This test case ensures sha512 with salt passwords hasher can be instantiated using the factory.'''

        sha512_hasher = PasswordsHasherFactory().get_hasher(PasswordsHasherFactory.SHA512_SALT)

        self.assertIsInstance(sha512_hasher, Sha512SaltPasswordsHasher)

    def test_unsupportedalg_get(self):
        '''This test case ensures a concrete exception is raised if the requested algorithm is not supported.'''

        with self.assertRaises(OAuth2TokenEncryptionError):
            self._factory.get_hasher("unknown algorithm")
コード例 #3
0
class PasswordsHasherFactoryTests(FantasticoUnitTestsCase):
    '''This class provides the tests suite which ensures passwords hasher factory correct behavior.'''

    _factory = None

    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()

    def test_sha512salt_get(self):
        '''This test case ensures sha512 with salt passwords hasher can be instantiated using the factory.'''

        sha512_hasher = PasswordsHasherFactory().get_hasher(
            PasswordsHasherFactory.SHA512_SALT)

        self.assertIsInstance(sha512_hasher, Sha512SaltPasswordsHasher)

    def test_unsupportedalg_get(self):
        '''This test case ensures a concrete exception is raised if the requested algorithm is not supported.'''

        with self.assertRaises(OAuth2TokenEncryptionError):
            self._factory.get_hasher("unknown algorithm")
コード例 #4
0
    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()
コード例 #5
0
    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()