本文整理汇总了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']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']
示例2: establish_user_auth
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields['mapped_user'] [as 别名]
def establish_user_auth(config, store, host, username):
user = User(username)
mapping_username = 'github-%s' % username
mapping_tiddler = Tiddler(mapping_username, 'MAPUSER')
mapping_tiddler.fields['mapped_user'] = username
try:
store.delete(user)
except StoreError:
pass
try:
store.delete(mapping_tiddler)
except IOError:
pass
user.add_role('MEMBER')
user.note = '{}'
store.put(user)
ensure_bag('MAPUSER', store)
store.put(mapping_tiddler)
stamp = datetime.utcnow().strftime('%Y%m%d%H')
csrf = gen_nonce(username, host, stamp, config['secret'])
cookie = make_cookie('tiddlyweb_user', mapping_username,
mac_key=config['secret'], httponly=False)
return cookie, csrf
示例3: test_simple_translate
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields['mapped_user'] [as 别名]
def test_simple_translate():
bag = Bag('MAPUSER')
store.put(bag)
tiddler = Tiddler('xfoo.example.com', 'MAPUSER')
tiddler.fields['mapped_user'] = 'xfoo'
store.put(tiddler)
extractor = Extractor()
assert extractor.translate_user(environ, 'xfoo.example.com') == 'xfoo'