当前位置: 首页>>代码示例>>Python>>正文


Python Tiddler.fields["mapped_user"]方法代码示例

本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.fields["mapped_user"]方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.fields["mapped_user"]方法的具体用法?Python Tiddler.fields["mapped_user"]怎么用?Python Tiddler.fields["mapped_user"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tiddlyweb.model.tiddler.Tiddler的用法示例。


在下文中一共展示了Tiddler.fields["mapped_user"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_user_maps_info

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields["mapped_user"] [as 别名]
def test_user_maps_info():
    """User can get their own identities at /users/{username}/identities"""
    global AUTH_COOKIE
    http = httplib2.Http()

    # auth required
    response, content = http.request("http://0.0.0.0:8080/users/cdent/identities", method="GET")
    assert response["status"] == "401"

    # user can get own identities
    response, content = http.request(
        "http://0.0.0.0:8080/users/cdent/identities",
        method="GET",
        headers={"Cookie": 'tiddlyweb_user="%s"' % AUTH_COOKIE},
    )
    assert response["status"] == "200", content

    info = simplejson.loads(content)
    assert "x.auth.thing" in info, info

    tiddler = Tiddler("fnd.example.org", "MAPUSER")
    tiddler.fields["mapped_user"] = "fnd"
    tiddler = store.put(tiddler)
    tiddler = Tiddler("cdent.example.com", "MAPUSER")
    tiddler.fields["mapped_user"] = "cdent"
    tiddler = store.put(tiddler)

    response, content = http.request(
        "http://0.0.0.0:8080/users/cdent/identities",
        method="GET",
        headers={"Cookie": 'tiddlyweb_user="%s"' % AUTH_COOKIE},
    )
    identities = simplejson.loads(content)
    assert response["status"] == "200", content
    assert len(identities) == 2
    assert "x.auth.thing" in identities
    assert "cdent.example.com" in identities
    assert "fnd.example.org" not in identities

    # user can't get other identities
    response, content = http.request(
        "http://0.0.0.0:8080/users/fnd/identities",
        method="GET",
        headers={"Cookie": 'tiddlyweb_user="%s"' % AUTH_COOKIE},
    )
    assert response["status"] == "403"
    assert "Bad user for action" in content

    # admin can get other identities
    user = store.get(User("cdent"))
    user.add_role("ADMIN")
    store.put(user)
    response, content = http.request(
        "http://0.0.0.0:8080/users/fnd/identities",
        method="GET",
        headers={"Cookie": 'tiddlyweb_user="%s"' % AUTH_COOKIE},
    )
    assert response["status"] == "200"
    identities = simplejson.loads(content)
    assert identities == ["fnd.example.org"]
开发者ID:TiddlySpace,项目名称:tiddlyspace,代码行数:62,代码来源:test_mapuser_validate.py


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