예제 #1
0
    def test_provider_tokenize_error(self):
        MockResponses.provider_tokenize_access(self.provider, code=400)

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

        self.assertEqual(e.exception.code, 400)
예제 #2
0
    def test_provider_tokenize_access(self):
        MockResponses.provider_tokenize_access(self.provider)

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

        self.assertIn('access_token', result)
        self.assertIn('refresh_token', result)
예제 #3
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')))
예제 #4
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))