test_token.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:auth-srv 作者: openpermissions 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号