def test_encode_token(encode):
token, expiry = generate_token(CLIENT, SCOPE, 'grant_type')
decoded = jwt.decode(token, verify=False)
expected_expiry = calendar.timegm(NOW.timetuple()) + EXPIRY * 60
data = {
'exp': expected_expiry,
'iss': 'localhost:8006/token',
'aud': 'localhost:8006/verify',
'sub': CLIENT.id,
'client': {
'id': CLIENT.id,
'service_type': CLIENT.service_type,
'organisation_id': CLIENT.organisation_id,
},
'scope': SCOPE,
'grant_type': 'grant_type',
'delegate': False
}
assert decoded == data
assert encode.call_count == 1
assert encode.call_args_list[0][-1] == {'algorithm': 'RS256'}
assert expiry == expected_expiry
评论列表
文章目录