Exemple #1
0
    def test_authenticate_exception(self):
        provider = InMemoryProvider([{"username": "******", "password": "******", "roles": ["ADMIN"]}, {"username": "******"}])

        auth_provider = DaoAuthenticationProvider(provider, "admin")

        with self.assertRaises(UsernameNotFoundException):
            auth_provider.authenticate(UsernamePasswordToken("admin", "anno."))

        with self.assertRaises(BadCredentialsException):
            t = UsernamePasswordToken("admin", "foo")
            t.credentials = "fake password"
            auth_provider.authenticate(t)
    def test_authenticate_exception(self):
        provider = InMemoryProvider([
            {'username': '******', 'password': '******', 'roles': ['ADMIN']},
            {'username': '******'}
        ])

        auth_provider = DaoAuthenticationProvider(provider, 'admin')

        with self.assertRaises(UsernameNotFoundException):
            auth_provider.authenticate(UsernamePasswordToken('admin', 'anno.'))

        with self.assertRaises(BadCredentialsException):
            t = UsernamePasswordToken('admin', 'foo')
            t.credentials = 'fake password'
            auth_provider.authenticate(t)
Exemple #3
0
    def test_authenticate(self):
        provider = InMemoryProvider([{"username": "******", "password": "******", "roles": ["ADMIN"]}, {"username": "******"}])

        auth_provider = DaoAuthenticationProvider(provider, "admin")

        t = UsernamePasswordToken("admin", "foo")
        t.credentials = "bar"
        token = auth_provider.authenticate(t)

        self.assertEquals(["ADMIN"], token.roles)
    def test_authenticate(self):
        provider = InMemoryProvider([
            {'username': '******', 'password': '******', 'roles': ['ADMIN']},
            {'username': '******'}
        ])

        auth_provider = DaoAuthenticationProvider(provider, 'admin')

        t = UsernamePasswordToken('admin', 'foo')
        t.credentials = 'bar'
        token = auth_provider.authenticate(t)

        self.assertEquals(['ADMIN'], token.roles)