本文整理汇总了Python中test_common.content_type函数的典型用法代码示例。如果您正苦于以下问题:Python content_type函数的具体用法?Python content_type怎么用?Python content_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了content_type函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_validate_token_true_xml
def test_validate_token_true_xml(self):
header = httplib2.Http(".cache")
url = '%stokens/%s?belongsTo=%s' % (utils.URL, self.token, self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
if int(resp['status']) == 500:
self.fail('Identity Fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/xml', utils.content_type(resp))
#verify content
dom = etree.Element("root")
dom.append(etree.fromstring(content))
auth = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \
"auth")
if auth == None:
self.fail("Expecting Auth")
user = auth.find("{http://docs.openstack.org/identity/api/v2.0}" \
"user")
if user == None:
self.fail("Expecting User")
roleRefs = user.find("{http://docs.openstack.org/identity/api/v2.0}" \
"roleRefs")
if roleRefs == None:
self.fail("Expecting Role Refs")
roleRef = roleRefs.find("{http://docs.openstack.org/identity/api/v2.0}" \
"roleRef")
if roleRef == None:
self.fail("Expecting Role Refs")
self.assertEqual(str(self.role_ref_id), roleRef.get("id"))
开发者ID:aabes,项目名称:keystone,代码行数:34,代码来源:test_token.py
示例2: test_a_get_version_xml
def test_a_get_version_xml(self):
header = httplib2.Http(".cache")
resp, content = header.request(utils.URL_V2, "GET", body="",
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/xml', utils.content_type(resp))
开发者ID:Cerberus98,项目名称:keystone,代码行数:7,代码来源:test_version.py
示例3: test_a_authorize
def test_a_authorize(self):
resp, content = utils.get_token('joeuser', 'secrete', self.tenant)
self.assertEqual(200, int(resp['status']))
obj = content
if not "auth" in obj:
raise fault.BadRequestFault("Expecting Auth")
auth = obj["auth"]
if not "serviceCatalog" in auth:
raise fault.BadRequestFault("Expecting Service Catalog")
self.assertEqual('application/json', utils.content_type(resp))
开发者ID:Mirantis,项目名称:keystone,代码行数:11,代码来源:test_authentication.py
示例4: test_validate_token_expired
def test_validate_token_expired(self):
header = httplib2.Http(".cache")
url = "%stoken/%s?belongsTo=%s" % (utils.URL, self.exp_auth_token, self.tenant)
resp, content = header.request(
url, "GET", body="", headers={"Content-Type": "application/json", "X-Auth-Token": self.exp_auth_token}
)
if int(resp["status"]) == 500:
self.fail("IDM fault")
elif int(resp["status"]) == 503:
self.fail("Service Not Available")
self.assertEqual(403, int(resp["status"]))
self.assertEqual("application/json", utils.content_type(resp))
开发者ID:roarking,项目名称:keystone,代码行数:12,代码来源:test_token.py
示例5: test_validate_token_invalid_xml
def test_validate_token_invalid_xml(self):
header = httplib2.Http(".cache")
url = '%stokens/%s?belongsTo=%s' % (utils.URL, 'NonExistingToken',
self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
self.fail('Identity Fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(401, int(resp['status']))
self.assertEqual('application/json', utils.content_type(resp))
开发者ID:aabes,项目名称:keystone,代码行数:13,代码来源:test_token.py
示例6: test_validate_token_true_xml
def test_validate_token_true_xml(self):
header = httplib2.Http(".cache")
url = '%stoken/%s?belongsTo=%s' % (utils.URL, self.token, self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/xml', utils.content_type(resp))
开发者ID:juvvadi,项目名称:keystone,代码行数:13,代码来源:test_token.py
示例7: test_a_authorize_user_wrong
def test_a_authorize_user_wrong(self):
header = httplib2.Http(".cache")
url = '%stoken' % utils.URL
body = {"passwordCredentials": {"username-w": "disabled",
"password": "secrete"}}
resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json"})
content = json.loads(content)
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(400, int(resp['status']))
self.assertEqual('application/json', utils.content_type(resp))
开发者ID:roarking,项目名称:keystone,代码行数:14,代码来源:test_authentication.py
示例8: test_a_authorize_xml
def test_a_authorize_xml(self):
resp, content = utils.get_token_xml('joeuser', 'secrete',
self.tenant)
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/xml', utils.content_type(resp))
#verify content
dom = etree.Element("root")
dom.append(etree.fromstring(content))
auth = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \
"auth")
if auth == None:
self.fail("Expecting Auth")
service_catalog = auth.find(
"{http://docs.openstack.org/identity/api/v2.0}" \
"serviceCatalog")
if service_catalog == None:
self.fail("Expecting Service Catalog")
开发者ID:Mirantis,项目名称:keystone,代码行数:17,代码来源:test_authentication.py
示例9: test_a_authorize_user_wrong_xml
def test_a_authorize_user_wrong_xml(self):
header = httplib2.Http(".cache")
url = '%stoken' % utils.URL
body = '<?xml version="1.0" encoding="UTF-8"?> \
<passwordCredentials \
xmlns="http://docs.openstack.org/identity/api/v2.0" \
password="secrete" username-w="disabled" \
tenantId="%s"/>' % self.tenant
resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
content = etree.fromstring(content)
if int(resp['status']) == 500:
self.fail('Identity Fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(400, int(resp['status']))
self.assertEqual('application/xml', utils.content_type(resp))
开发者ID:slashk,项目名称:keystone,代码行数:18,代码来源:test_authentication.py
示例10: test_validate_token_true
def test_validate_token_true(self):
header = httplib2.Http(".cache")
url = '%stokens/%s?belongsTo=%s' % (utils.URL, self.token, self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
self.fail('Identity Fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/json', utils.content_type(resp))
#verify content
obj = json.loads(content)
if not "auth" in obj:
raise self.fail("Expecting Auth")
role_refs = obj["auth"]["user"]["roleRefs"]
role_ref = role_refs[0]
role_ref_id = role_ref["id"]
self.assertEqual(self.role_ref_id, role_ref_id)
开发者ID:aabes,项目名称:keystone,代码行数:21,代码来源:test_token.py
示例11: test_a_authorize_xml
def test_a_authorize_xml(self):
resp, content = utils.get_token_xml('joeuser', 'secrete',
self.tenant)
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/xml', utils.content_type(resp))
开发者ID:slashk,项目名称:keystone,代码行数:5,代码来源:test_authentication.py
示例12: test_a_authorize
def test_a_authorize(self):
resp, content = utils.get_token('joeuser', 'secrete', '')
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/json', utils.content_type(resp))
开发者ID:roarking,项目名称:keystone,代码行数:4,代码来源:test_authentication.py
注:本文中的test_common.content_type函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论