def test_refresh_token(u1client, random_str1): code = authorize(u1client=u1client, code_verifier=random_str1) refresh_token, access_token = tokens(u1client=u1client, code=code, code_verifier=random_str1) assert_claim(token=refresh_token, tpa_id=2, user_id=1) assert_claim(token=access_token, tpa_id=2, user_id=1, scope='admin')
def test_switch(db, u1client): res = u1client.post(f'/auth/workspaces/2/switch/') assert_success(response=res, status_code=200) data = res.json() assert 'access_token' in data and 'refresh_token' in data access_token = data['access_token'] refresh_token = data['refresh_token'] assert_claim(token=access_token, workspace_id=2)
def test_signin(db, client): res = client.post('/auth/basic/signin/', data={ 'email': '*****@*****.**', 'password': '******' }) assert_success(response=res, status_code=200) data = res.json() access_token = data['access_token'] refresh_token = data['refresh_token'] assert_claim(token=refresh_token, workspace_id=None, user_id=1) assert_claim(token=access_token, workspace_id=None, user_id=1)
def test_access_token(u1client): code = authorize(u1client=u1client) refresh_token, access_token = tokens(u1client=u1client, code=code) res = u1client.post('/auth/o/token/', data={ 'client_id': 2, 'client_secret': 'password123', 'refresh_token': refresh_token, 'grant_type': 'refresh_token' }) assert_success(response=res, status_code=200) data = res.json() assert 'refresh_token' in data assert 'access_token' in data assert_claim(token=access_token, tpa_id=2)
def test_access_token(u1client, random_str1): code = authorize(u1client=u1client, code_verifier=random_str1) refresh_token, access_token = tokens(u1client=u1client, code=code, code_verifier=random_str1) res = u1client.post('/auth/o/token/', data={ 'client_id': 2, 'code_verifier': random_str1, 'refresh_token': refresh_token, 'grant_type': 'refresh_token' }) assert_success(response=res, status_code=200) data = res.json() assert 'refresh_token' in data assert 'access_token' in data assert_claim(token=access_token, tpa_id=2)
def test_refresh_token(u1client): code = authorize(u1client=u1client) refresh_token, access_token = tokens(u1client=u1client, code=code) assert_claim(token=refresh_token, tpa_id=2, user_id=1) assert_claim(token=access_token, tpa_id=2, user_id=1, scope='admin')
def test_authorize(u1client): code = authorize(u1client=u1client) assert code, 'code is null' assert_claim(token=code, tpa_id=2, user_id=1, workspace_id=2)
def test_authorize(u1client, random_str1): code = authorize(u1client=u1client, code_verifier=random_str1) assert code, 'code is null' assert_claim(token=code, tpa_id=2, user_id=1, workspace_id=2)