def test_trusted_client_without_code_challenge(self):
    self.prepare_data('client_secret_basic')
    rv = self.client.get(self.authorize_url)
    self.assertEqual(rv.data, b'ok')
    rv = self.client.post(self.authorize_url, data={'user_id': '1'})
    self.assertIn('code=', rv.location)
    params = dict(url_decode(urlparse.urlparse(rv.location).query))
    code = params['code']
    headers = self.create_basic_header('code-client', 'code-secret')
    rv = self.client.post('/oauth/token', data={'grant_type': 'authorization_code', 'code': code}, headers=headers)
    resp = json.loads(rv.data)
    self.assertIn('access_token', resp)
def test_trusted_client_without_code_challenge(self):
    self.prepare_data('client_secret_basic')
    rv = self.client.get(self.authorize_url)
    self.assertEqual(rv.data, b'ok')
    rv = self.client.post(self.authorize_url, data={'user_id': '1'})
    self.assertIn('code=', rv.location)
    params = dict(url_decode(urlparse.urlparse(rv.location).query))
    code = params['code']
    headers = self.create_basic_header('code-client', 'code-secret')
    rv = self.client.post('/oauth/token', data={'grant_type': 'authorization_code', 'code': code}, headers=headers)
    resp = json.loads(rv.data)
    self.assertIn('access_token', resp)