def test_construct_refresh_token_request(self): auth_request = AuthorizationRequest( redirect_uri='https://example.com/cli/authz_cb', state='state') auth_response = AuthorizationResponse(code='access_code') token_response = AccessTokenResponse(refresh_token="refresh_with_me", access_token="access") _state = State(auth_response=auth_response.to_json(), auth_request=auth_request.to_json(), token_response=token_response.to_json()) self.client.state_db.set('ABCDE', _state.to_json()) req_args = {} msg = self.client.service['refresh_token'].construct( request_args=req_args, state='ABCDE') assert isinstance(msg, RefreshAccessTokenRequest) assert msg.to_dict() == { 'client_id': 'client_1', 'client_secret': 'abcdefghijklmnop', 'grant_type': 'refresh_token', 'refresh_token': 'refresh_with_me' }
def test_construct_accesstoken_request(self): # Bind access code to state req_args = {} auth_request = AuthorizationRequest( redirect_uri='https://example.com/cli/authz_cb', state='state') auth_response = AuthorizationResponse(code='access_code') _state = State(auth_response=auth_response.to_json(), auth_request=auth_request.to_json()) self.client.state_db.set('ABCDE', _state.to_json()) msg = self.client.service['accesstoken'].construct( request_args=req_args, state='ABCDE') assert isinstance(msg, AccessTokenRequest) assert msg.to_dict() == { 'client_id': 'client_1', 'code': 'access_code', 'client_secret': 'abcdefghijklmnop', 'grant_type': 'authorization_code', 'redirect_uri': 'https://example.com/cli/authz_cb', 'state': 'state' }