本文整理汇总了Python中test.fixtures.get_auth函数的典型用法代码示例。如果您正苦于以下问题:Python get_auth函数的具体用法?Python get_auth怎么用?Python get_auth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_auth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_spaces
def test_create_spaces():
cookie = get_auth('thingone', 'how')
response, content = http.request('http://0.0.0.0:8080/spaces/thing',
method='PUT',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie})
assert response['status'] == '201'
response, content = http.request(
'http://thing.0.0.0.0:8080/bags/thing_private/tiddlers/thingone',
method='PUT',
headers={'Content-Type': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie},
body='{"text": "thingone"}')
assert response['status'] == '204'
cookie = get_auth('thingtwo', 'how')
response, content = http.request('http://0.0.0.0:8080/spaces/foo',
method='PUT',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie})
assert response['status'] == '201'
response, content = http.request(
'http://foo.0.0.0.0:8080/bags/foo_private/tiddlers/thingtwo',
method='PUT',
headers={'Content-Type': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie},
body='{"text": "thingtwo"}')
assert response['status'] == '204'
示例2: test_create_spaces
def test_create_spaces():
cookie = get_auth("thingone", "how")
response, content = http.request(
"http://0.0.0.0:8080/spaces/thing", method="PUT", headers={"Cookie": 'tiddlyweb_user="%s"' % cookie}
)
assert response["status"] == "201"
response, content = http.request(
"http://thing.0.0.0.0:8080/bags/thing_private/tiddlers/thingone",
method="PUT",
headers={"Content-Type": "application/json", "Cookie": 'tiddlyweb_user="%s"' % cookie},
body='{"text": "thingone"}',
)
assert response["status"] == "204"
cookie = get_auth("thingtwo", "how")
response, content = http.request(
"http://0.0.0.0:8080/spaces/foo", method="PUT", headers={"Cookie": 'tiddlyweb_user="%s"' % cookie}
)
assert response["status"] == "201"
response, content = http.request(
"http://foo.0.0.0.0:8080/bags/foo_private/tiddlers/thingtwo",
method="PUT",
headers={"Content-Type": "application/json", "Cookie": 'tiddlyweb_user="%s"' % cookie},
body='{"text": "thingtwo"}',
)
assert response["status"] == "204"
示例3: test_subscription
def test_subscription():
cookie = get_auth('cdent', 'cow')
http = httplib2.Http()
subscriptions = simplejson.dumps({'subscriptions': ['extra']})
response, content = http.request('http://0.0.0.0:8080/spaces/cdent',
method='POST',
headers={
'Content-Type': 'application/json',
},
body=subscriptions)
assert response['status'] == '403'
response, content = http.request('http://0.0.0.0:8080/spaces/cdent',
method='POST',
headers={
'Content-Type': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie,
},
body='')
assert response['status'] == '409'
response, content = http.request('http://0.0.0.0:8080/spaces/cdent',
method='POST',
headers={
'Content-Type': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie,
},
body=subscriptions)
assert response['status'] == '204'
示例4: test_register_user
def test_register_user():
data = {'username': 'cdent', 'password': 'cowpig'}
body = simplejson.dumps(data)
response, content = http.request('http://0.0.0.0:8080/users',
method='POST',
headers={'Content-Type': 'application/json'},
body=body)
assert response['status'] == '201'
response, content = http.request('http://0.0.0.0:8080/users',
method='POST',
headers={'Content-Type': 'application/json'},
body=body)
assert response['status'] == '409'
assert 'exists' in content
cookie = get_auth('cdent', 'cowpig')
response, content = http.request('http://0.0.0.0:8080/spaces/cdent',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
method='PUT')
assert response['status'] == '201'
response, content = http.request('http://0.0.0.0:8080/spaces/cdent',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
method='PUT')
assert response['status'] == '409'
示例5: test_case_in_space
def test_case_in_space():
cookie = get_auth('cdent', 'cow')
http = httplib2.Http()
response, content = http.request('http://0.0.0.0:8080/spaces/CeXtRa',
method='PUT',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
)
assert response['status'] == '409'
示例6: test_reserved_space_name
def test_reserved_space_name():
cookie = get_auth('cdent', 'cow')
http = httplib2.Http()
response, content = http.request('http://0.0.0.0:8080/spaces/www',
method='PUT',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
)
assert response['status'] == '409'
assert 'Invalid space name: www' in content
示例7: test_status_space_auth
def test_status_space_auth():
user_cookie = get_auth('foo', 'foobar')
response, content = http.request('http://thing.0.0.0.0:8080/status',
headers={'Cookie': 'tiddlyweb_user="%s"' % user_cookie})
assert response['status'] == '200'
info = simplejson.loads(content)
assert info['username'] == 'foo'
assert info['space']['name'] == 'thing'
assert info['space']['recipe'] == 'thing_private'
示例8: test_mutual_subscription
def test_mutual_subscription():
"""
Subscription should not result in the same bag showing up more than once.
"""
response, content = add_subscription('fnd', 'cdent', cookie=get_auth('cdent', 'bar'))
assert response['status'] == '204'
recipe = store.get(Recipe('cdent_public'))
bags = [bag for bag, filter in recipe.get_recipe()]
unique_bags = list(set(bags))
assert len(bags) == len(unique_bags)
示例9: add_subscription
def add_subscription(subscribed, subscriber, cookie=None, unsubscribe=False):
if not cookie:
cookie = get_auth('fnd', 'foo')
http = httplib2.Http()
if unsubscribe:
subscriptions = simplejson.dumps({'unsubscriptions': [subscribed]})
else:
subscriptions = simplejson.dumps({'subscriptions': [subscribed]})
return http.request('http://0.0.0.0:8080/spaces/%s' % subscriber,
method='POST', headers={
'Content-Type': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie,
}, body=subscriptions)
示例10: test_status_base_auth
def test_status_base_auth():
user = User('foo')
user.set_password('foobar')
store.put(user)
user_cookie = get_auth('foo', 'foobar')
change_space_member(store, 'thing', add='foo')
response, content = http.request('http://0.0.0.0:8080/status',
headers={'Cookie': 'tiddlyweb_user="%s"' % user_cookie})
assert response['status'] == '200'
info = simplejson.loads(content)
assert info['username'] == 'foo'
assert 'space' not in info
示例11: test_delete_member
def test_delete_member():
cookie = get_auth('fnd', 'bird')
http = httplib2.Http()
response, content = http.request('http://0.0.0.0:8080/spaces/extra/members/psd',
method='DELETE',
)
assert response['status'] == '403'
response, content = http.request('http://extra.0.0.0.0:8080/spaces/extra/members/psd',
method='DELETE',
)
assert response['status'] == '403'
response, content = http.request('http://0.0.0.0:8080/spaces/extra/members/psd',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
method='DELETE',
)
assert response['status'] == '403'
response, content = http.request('http://extra.0.0.0.0:8080/spaces/extra/members/psd',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
method='DELETE',
)
assert response['status'] == '204'
# delete self
response, content = http.request('http://extra.0.0.0.0:8080/spaces/extra/members/fnd',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
method='DELETE',
)
assert response['status'] == '204'
bag = store.get(Bag('extra_private'))
assert bag.policy.owner == 'cdent'
assert bag.policy.read == ['cdent']
assert bag.policy.accept == ['NONE']
assert bag.policy.manage == ['cdent']
assert bag.policy.write == ['cdent']
assert bag.policy.create == ['cdent']
assert bag.policy.delete == ['cdent']
bag = store.get(Bag('extra_archive'))
assert bag.policy.owner == 'cdent'
assert bag.policy.read == ['cdent']
assert bag.policy.accept == ['NONE']
assert bag.policy.manage == ['cdent']
assert bag.policy.write == ['cdent']
assert bag.policy.create == ['cdent']
assert bag.policy.delete == ['cdent']
示例12: test_space_members
def test_space_members():
http = httplib2.Http()
response, content = http.request('http://0.0.0.0:8080/spaces/cdent/members',
method='GET')
assert response['status'] == '401'
cookie = get_auth('cdent', 'cow')
response, content = http.request('http://0.0.0.0:8080/spaces/cdent/members',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
method='GET')
assert response['status'] == '200'
assert response['cache-control'] == 'no-cache'
info = simplejson.loads(content)
assert info == ['cdent']
response, content = http.request('http://0.0.0.0:8080/spaces/nancy/members',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
method='GET')
response['status'] == '404'
示例13: test_foo_tiddlers_guest
def test_foo_tiddlers_guest():
cookie = get_auth('thingone', 'how')
response, content = http.request('http://foo.0.0.0.0:8080/',
method='GET',
headers={'Accept': 'application/json'})
guest_content = content
response, content = http.request('http://foo.0.0.0.0:8080/',
headers={'Accept': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie})
user_content = content
assert guest_content == user_content
response, content = http.request(
'http://thing.0.0.0.0:8080/bags/thing_private/tiddlers',
method='GET',
headers={'Accept': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie})
thing_content = content
response, content = http.request(
'http://foo.0.0.0.0:8080/bags/thing_private/tiddlers',
method='GET',
headers={'Accept': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie})
assert response['status'] == '404'
response, content = http.request(
'http://foo.0.0.0.0:8080/bags/thing_private/tiddlers',
method='GET',
headers={'Accept': 'application/json',
'X-ControlView': 'false',
'Cookie': 'tiddlyweb_user="%s"' % cookie})
assert response['status'] == '401'
response, content = http.request(
'http://foo.0.0.0.0:8080/bags/thing_private/tiddlers/more',
method='PUT',
headers={'Content-Type': 'application/json',
'X-ControlView': 'false',
'Cookie': 'tiddlyweb_user="%s"' % cookie},
body='{"text": "hi"}')
assert response['status'] == '403'
示例14: test_foo_tiddlers_guest
def test_foo_tiddlers_guest():
cookie = get_auth("thingone", "how")
response, content = http.request("http://foo.0.0.0.0:8080/", method="GET", headers={"Accept": "application/json"})
guest_content = content
response, content = http.request(
"http://foo.0.0.0.0:8080/", headers={"Accept": "application/json", "Cookie": 'tiddlyweb_user="%s"' % cookie}
)
user_content = content
assert guest_content == user_content
response, content = http.request(
"http://thing.0.0.0.0:8080/bags/thing_private/tiddlers",
method="GET",
headers={"Accept": "application/json", "Cookie": 'tiddlyweb_user="%s"' % cookie},
)
thing_content = content
response, content = http.request(
"http://foo.0.0.0.0:8080/bags/thing_private/tiddlers",
method="GET",
headers={"Accept": "application/json", "Cookie": 'tiddlyweb_user="%s"' % cookie},
)
assert response["status"] == "404"
response, content = http.request(
"http://foo.0.0.0.0:8080/bags/thing_private/tiddlers",
method="GET",
headers={"Accept": "application/json", "X-ControlView": "false", "Cookie": 'tiddlyweb_user="%s"' % cookie},
)
assert response["status"] == "401"
response, content = http.request(
"http://foo.0.0.0.0:8080/bags/thing_private/tiddlers/more",
method="PUT",
headers={
"Content-Type": "application/json",
"X-ControlView": "false",
"Cookie": 'tiddlyweb_user="%s"' % cookie,
},
body='{"text": "hi"}',
)
assert response["status"] == "403"
示例15: test_blacklisted_subscription
def test_blacklisted_subscription():
cookie = get_auth('cdent', 'cow')
http = httplib2.Http()
response, content = http.request('http://0.0.0.0:8080/spaces/scrappy',
method='PUT',
headers={'Cookie': 'tiddlyweb_user="%s"' % cookie},
)
assert response['status'] == '201'
subscriptions = simplejson.dumps({'subscriptions': ['scrappy']})
response, content = http.request('http://0.0.0.0:8080/spaces/cdent',
method='POST',
headers={
'Content-Type': 'application/json',
'Cookie': 'tiddlyweb_user="%s"' % cookie,
},
body=subscriptions)
assert response['status'] == '409'
assert 'Subscription not allowed to space: scrappy' in content