Ejemplo n.º 1
0
    def test_provider_identity_error(self):
        MockResponses.provider_identity(self.provider, code=401)

        with self.assertRaises(ProviderError) as e:
            self.provider.identity('qwerty')

        self.assertEqual(e.exception.code, 401)
Ejemplo n.º 2
0
    def test_view_login_provider_error(self):
        for provider in providers.values():
            MockResponses.provider_tokenize_access(provider)
            MockResponses.provider_identity(provider, code=400)

            url = url_for('views.login', provider=provider.name, code=123)
            response = self.client.get(url)

            self.assertFalse(Account.query.all())
            self.assertEqual(response.status_code, 302)
            self.assertTrue(response.location.endswith(url_for('views.main')))
Ejemplo n.º 3
0
    def test_view_login(self):
        for provider in providers.values():
            MockResponses.provider_tokenize_access(provider)
            MockResponses.provider_identity(provider)

            url = url_for('views.login', provider=provider.name, code=123)
            response = self.client.get(url)

            self.assertResponseRedirect(response, url_for('views.resume'))

        self.assertEqual(Account.query.count(), len(providers))
Ejemplo n.º 4
0
    def test_provider_identity(self):
        MockResponses.provider_identity(self.provider, identity='12345')

        result = self.provider.identity('qwerty')

        self.assertIn('12345', result)