· 7 years ago · Aug 24, 2018, 02:46 PM
1def test_grant_type(app):
2 path = '/oauth/token'
3 payload = {'grant_type': 'client_credentials', 'scope': 'test_user'}
4 auth_header = "client_id:client_secret"
5 b64val = base64.b64encode(auth_header.encode('UTF-8'))
6 headers = {'Authorization': 'Basic %s' % b64val.decode('UTF-8')}
7
8 with app.test_request_context(path, method="POST") as req:
9 req.request.args = payload
10 req.request.headers = headers
11
12 import pdb;
13 pdb.set_trace()
14
15 client_id = "test_user"
16 assert "test_account_id"==get_grant_type(req.request, client_id)
17
18/Users/t/local/c/tests/auth.py(149)test_grant_type()
19-> client_id = "test_user"
20(Pdb) p req.request.form
21ImmutableMultiDict([])
22(Pdb) p request
23<Request 'http://localhost/' [GET]>
24(Pdb) p req.request
25<Request 'http://localhost/oauth/token' [POST]>
26(Pdb) p req.request.args
27{'grant_type': 'client_credentials', 'scope': 'test_user'}