def test_answer(self): from py3oauth2.provider import AuthorizationProvider provider = AuthorizationProvider(self.store) client = self.make_client() req = self.target() req.update({"response_type": "token", "client_id": client.id, "state": "statestring"}) resp = req.answer(provider, self.owner) resp.validate() self.assertIsInstance(resp, req.response) token = self.store.get_access_token(resp.access_token) self.assertIsNotNone(token) self.assertEqual(resp.token_type, token.get_type()) self.assertEqual(resp.expires_in, token.get_expires_in()) self.assertEqual(provider.normalize_scope(resp.scope), token.get_scope()) self.assertEqual(resp.state, req.state) self.assertTrue(resp.is_redirect())
def make_authcode(self, client, owner, scope='view'): return self.store.issue_authorization_code( client, owner, AuthorizationProvider.normalize_scope(scope))