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)
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)
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, })