• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.FakeSerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中relengapi.blueprints.tokenauth.util.FakeSerializer的典型用法代码示例。如果您正苦于以下问题:Python FakeSerializer类的具体用法?Python FakeSerializer怎么用?Python FakeSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FakeSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: assert_prm_token

def assert_prm_token(data, **attrs):
    token = _get_token(data)
    attrs['typ'] = 'prm'
    attrs['id'] = id = token.id
    attrs['token'] = FakeSerializer.prm(id)
    attrs['disabled'] = False
    _eq_token(token, attrs)
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:7,代码来源:test_tokenauth.py


示例2: test_loader_good_header

def test_loader_good_header(app, client):
    """With a good Authorization header, the permissions in the DB are allowed"""
    tok = FakeSerializer.prm(1)
    auth = json.loads(
        client.get('/test_tokenauth',
                   headers=[('Authorization', 'Bearer ' + tok)]).data)
    eq_(auth['permissions'], ['test_tokenauth.zig'], auth)
开发者ID:acmiyaguchi,项目名称:build-relengapi,代码行数:7,代码来源:test_loader.py


示例3: test_loader_good_header_Authentication

def test_loader_good_header_Authentication(app, client):
    """The old 'Authentication' header can be used instead of 'Authorization'"""
    # see https://github.com/mozilla/build-relengapi/pull/192/files
    tok = FakeSerializer.prm(1)
    auth = json.loads(
        client.get('/test_tokenauth',
                   headers=[('Authentication', 'Bearer ' + tok)]).data)
    eq_(auth['permissions'], ['test_tokenauth.zig'], auth)
开发者ID:acmiyaguchi,项目名称:build-relengapi,代码行数:8,代码来源:test_loader.py


示例4: test_query_prm_token_exists

def test_query_prm_token_exists(client):
    """Querying a permanent token, with base.tokens.prm.view, returns that token."""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.prm(1))
    eq_(res.status_code, 200)
    eq_(json.loads(res.data),
        {'result': {'id': 1, 'description': 'Zig only', 'typ': 'prm',
                    'permissions': ['test_tokenauth.zig'],
                    'disabled': False}})
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:9,代码来源:test_tokenauth.py


示例5: assert_tmp_token

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)
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:10,代码来源:test_tokenauth.py


示例6: test_query_tmp_token

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,
    })
开发者ID:azizadnan,项目名称:build-relengapi,代码行数:18,代码来源:test_tokenauth.py


示例7: test_from_str_bad_type

def test_from_str_bad_type(app):
    """from_str does not return a user for a token with a bogus typ"""
    tok = FakeSerializer.dumps({'iss': 'ra2', 'typ': 'booogus'})
    with app.app_context():
        eq_(loader.token_loader.from_str(tok), None)
开发者ID:acmiyaguchi,项目名称:build-relengapi,代码行数:5,代码来源:test_loader.py


示例8: test_from_str_no_type

def test_from_str_no_type(app):
    """from_str does not return a user for a token with no 'typ'"""
    tok = FakeSerializer.dumps({})
    with app.app_context():
        eq_(loader.token_loader.from_str(tok), None)
开发者ID:acmiyaguchi,项目名称:build-relengapi,代码行数:5,代码来源:test_loader.py


示例9: test_from_str

def test_from_str(app):
    """from_str returns a TokenUser object for a good token"""
    tok = FakeSerializer.prm(1)
    with app.app_context():
        eq_(loader.token_loader.from_str(tok).permissions,
            set([p.test_tokenauth.zig]))
开发者ID:acmiyaguchi,项目名称:build-relengapi,代码行数:6,代码来源:test_loader.py


示例10: test_query_token_missing

def test_query_token_missing(client):
    """Querying a permanent token that does not exist returns status 404"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.prm(99))
    eq_(res.status_code, 404)
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:5,代码来源:test_tokenauth.py


示例11: test_query_usr_token_success_all

def test_query_usr_token_success_all(client):
    """Querying a user token with base.tokens.usr.view.all returns the token."""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    eq_(json.loads(res.data), {'result': usr_json})
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:5,代码来源:test_tokenauth.py


示例12: test_query_usr_token_forbidden_not_mine

def test_query_usr_token_forbidden_not_mine(client):
    """Querying a user token with base.tokens.usr.view.my gives 403
    if the token email doesn't match the request email"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    eq_(res.status_code, 403)
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:6,代码来源:test_tokenauth.py


示例13: test_query_usr_token_forbidden

def test_query_usr_token_forbidden(client):
    """Querying a user token without permission results in a 403"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    eq_(res.status_code, 403)
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:5,代码来源:test_tokenauth.py


示例14: test_query_prm_token_forbidden_wrong_perm

def test_query_prm_token_forbidden_wrong_perm(client):
    """Querying a permanent token requires base.tokens.prm.view"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.prm(1))
    eq_(res.status_code, 403)
开发者ID:b10n1k,项目名称:build-relengapi,代码行数:5,代码来源:test_tokenauth.py


示例15: test_query_usr_token_success_mine

def test_query_usr_token_success_mine(client):
    """Querying a user token with base.tokens.usr.view.my returns the
    token if the emails match"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    assert_result(res.data, usr_json)
开发者ID:azizadnan,项目名称:build-relengapi,代码行数:6,代码来源:test_tokenauth.py



注:本文中的relengapi.blueprints.tokenauth.util.FakeSerializer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python time.now函数代码示例发布时间:2022-05-26
下一篇:
Python utils.TestHelper类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap