本文整理匯總了Python中relengapi.blueprints.tokenauth.util.FakeSerializer.tmp方法的典型用法代碼示例。如果您正苦於以下問題:Python FakeSerializer.tmp方法的具體用法?Python FakeSerializer.tmp怎麽用?Python FakeSerializer.tmp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類relengapi.blueprints.tokenauth.util.FakeSerializer
的用法示例。
在下文中一共展示了FakeSerializer.tmp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: assert_tmp_token
# 需要導入模塊: from relengapi.blueprints.tokenauth.util import FakeSerializer [as 別名]
# 或者: from relengapi.blueprints.tokenauth.util.FakeSerializer import tmp [as 別名]
def assert_tmp_token(data, **attrs):
token = _get_token(data)
attrs['typ'] = 'tmp'
attrs['disabled'] = False
nbf = JAN_2014
exp = calendar.timegm(token.expires.utctimetuple())
attrs['token'] = FakeSerializer.tmp(
nbf=nbf, exp=exp, prm=token.permissions,
mta=token.metadata)
_eq_token(token, attrs)
示例2: test_query_tmp_token
# 需要導入模塊: from relengapi.blueprints.tokenauth.util import FakeSerializer [as 別名]
# 或者: from relengapi.blueprints.tokenauth.util.FakeSerializer import tmp [as 別名]
def test_query_tmp_token(client):
"""Querying a temporary token returns that token's info,
without requiring any special permissions"""
tok = FakeSerializer.tmp(
nbf=946684800, # Jan 1, 2000
exp=32503680000, # Jan 1, 3000
prm=['test_tokenauth.zag'],
mta={})
res = client.post_json('/tokenauth/tokens/query', tok)
eq_(res.status_code, 200)
assert_result(res.data, {
'typ': 'tmp',
'not_before': '2000-01-01T00:00:00+00:00',
'expires': '3000-01-01T00:00:00+00:00',
'metadata': {},
'permissions': ['test_tokenauth.zag'],
'disabled': False,
})