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


Python test_common.create_role_ref函数代码示例

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


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

示例1: test_create_and_delete_role_that_has_references

 def test_create_and_delete_role_that_has_references(self):
     resp, content = utils.create_role('test_role', self.auth_token)
     self.assertEqual(201, int(resp['status']))
     utils.create_role_ref(
         self.user, "test_role",
         self.tenant, self.auth_token)
     resp, content = utils.delete_role('test_role', self.auth_token)
     self.assertEqual(204, int(resp['status']))
开发者ID:Cerberus98,项目名称:keystone,代码行数:8,代码来源:test_roles.py

示例2: test_service_which_has_dependencies_delete

    def test_service_which_has_dependencies_delete(self):
        resp, _content = utils.create_service(
            self.test_service, str(self.auth_token))
        resp, _content = utils.create_role_mapped_to_service(
            self.test_service + ":test_role",
            self.auth_token, self.test_service)
        self.assertEqual(201, int(resp['status']))
        resp, _content = utils.create_role_ref(
            self.user, self.test_service +
            ":test_role", self.tenant, self.auth_token)
        self.assertEqual(201, int(resp['status']))
        resp, _content = utils.create_endpoint_template(\
            'DFW', self.test_service, 'public_url',\
            'admin_url', 'internal_url', True, False, self.auth_token)
        self.assertEqual(201, int(resp['status']))

        #verify content
        obj = json.loads(_content)
        if not "endpointTemplate" in obj:
            raise fault.BadRequestFault("Expecting endpointTemplate")
        endpoint_template = obj["endpointTemplate"]
        if not "id" in endpoint_template:
            endpoint_template_id = None
        else:
            endpoint_template_id = endpoint_template["id"]
        resp, _content = utils.create_endpoint_xml(self.tenant,
            endpoint_template_id,
            str(self.auth_token))
        resp_val = int(resp['status'])
        self.assertEqual(201, resp_val)

        resp, _content = utils.delete_service(
            self.test_service, self.auth_token)
        resp_val = int(resp['status'])
        self.assertEqual(204, resp_val)
开发者ID:Mirantis,项目名称:keystone,代码行数:35,代码来源:test_services.py

示例3: test_delete_roleref_using_invalid_token

 def test_delete_roleref_using_invalid_token(self):
     header = httplib2.Http(".cache")
     utils.add_user_json(self.auth_token)
     resp, content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.auth_token))
     resp_val = int(resp["status"])
     self.assertEqual(201, resp_val)
     obj = json.loads(content)
     if not "roleRef" in obj:
         raise fault.BadRequestFault("Expecting RoleRef")
     roleRef = obj["roleRef"]
     if not "id" in roleRef:
         role_ref_id = None
     else:
         role_ref_id = roleRef["id"]
     if role_ref_id is None:
         raise fault.BadRequestFault("Expecting RoleRefId")
     url = "%susers/%s/roleRefs/%s" % (URL_V2, self.user, role_ref_id)
     resp, content = header.request(
         url,
         "DELETE",
         body="",
         headers={"Content-Type": "application/json", "X-Auth-Token": str(self.invalid_token)},
     )
     resp_val = int(resp["status"])
     self.assertEqual(404, resp_val)
开发者ID:Mirantis,项目名称:keystone,代码行数:25,代码来源:test_roles.py

示例4: test_get_rolerefs_json_using_invalid_token

 def test_get_rolerefs_json_using_invalid_token(self):
     header = httplib2.Http(".cache")
     utils.add_user_json(self.auth_token)
     _resp, _content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.auth_token))
     url = "%susers/%s/roleRefs" % (URL_V2, self.user)
     # test for Content-Type = application/json
     resp, _content = header.request(
         url, "GET", body="{}", headers={"Content-Type": "application/json", "X-Auth-Token": str(self.invalid_token)}
     )
     self.assertEqual(404, int(resp["status"]))
开发者ID:Mirantis,项目名称:keystone,代码行数:10,代码来源:test_roles.py

示例5: test_get_rolerefs_using_missing_token

 def test_get_rolerefs_using_missing_token(self):
     header = httplib2.Http(".cache")
     utils.add_user_json(self.auth_token)
     _resp, _content = utils.create_role_ref(self.user, 'Admin',
         self.tenant, str(self.auth_token))
     url = '%susers/%s/roleRefs' % (URL_V2, self.user)
     #test for Content-Type = application/json
     resp, _content = header.request(url, "GET", body='{}', headers={
         "Content-Type": "application/json",
         "X-Auth-Token": str(self.missing_token)})
     self.assertEqual(401, int(resp['status']))
开发者ID:Cerberus98,项目名称:keystone,代码行数:11,代码来源:test_roles.py

示例6: test_get_rolerefs_using_invalid_token

 def test_get_rolerefs_using_invalid_token(self):
     header = httplib2.Http(".cache")
     utils.add_user_json(self.tenant, self.user, self.auth_token)
     resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant,
         str(self.auth_token))
     url = '%susers/%s/roleRefs' % (URL, self.user)
     #test for Content-Type = application/json
     resp, content = header.request(url, "GET", body='{}',
                               headers={"Content-Type": "application/json",
                                      "X-Auth-Token": str(self.invalid_token)})
     if int(resp['status']) == 500:
         self.fail('Identity Fault')
     elif int(resp['status']) == 503:
         self.fail('Service Not Available')
     self.assertEqual(404, int(resp['status']))
开发者ID:jakedahn,项目名称:keystone,代码行数:15,代码来源:test_roles.py

示例7: test_get_rolerefs

    def test_get_rolerefs(self):
        header = httplib2.Http(".cache")
        utils.add_user_json(self.auth_token)
        _resp, _content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.auth_token))
        url = "%susers/%s/roleRefs" % (URL_V2, self.user)
        # test for Content-Type = application/json
        resp, content = header.request(
            url, "GET", body="{}", headers={"Content-Type": "application/json", "X-Auth-Token": str(self.auth_token)}
        )
        self.assertEqual(200, int(resp["status"]))

        # verify content
        obj = json.loads(content)
        if not "roleRefs" in obj:
            raise self.fail("Expecting RoleRefs")
开发者ID:Mirantis,项目名称:keystone,代码行数:15,代码来源:test_roles.py

示例8: setUp

 def setUp(self):
     self.tenant = utils.get_tenant()
     self.user = 'joeuser'
     self.token = utils.get_token('joeuser', 'secrete', self.tenant,
                                 'token')
     self.auth_token = utils.get_auth_token()
     self.exp_auth_token = utils.get_exp_auth_token()
     _resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant,
         str(self.auth_token))
     obj = json.loads(content)
     if not "roleRef" in obj:
         raise fault.BadRequestFault("Expecting RoleRef")
     roleRef = obj["roleRef"]
     if not "id" in roleRef:
         self.role_ref_id = None
     else:
         self.role_ref_id = roleRef["id"]
开发者ID:Mirantis,项目名称:keystone,代码行数:17,代码来源:test_token.py

示例9: test_get_rolerefs

 def test_get_rolerefs(self):
     header = httplib2.Http(".cache")
     utils.add_user_json(self.tenant, self.user, self.auth_token)
     resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant,
         str(self.auth_token))
     url = '%susers/%s/roleRefs' % (URL, self.user)
     #test for Content-Type = application/json
     resp, content = header.request(url, "GET", body='{}',
                               headers={"Content-Type": "application/json",
                                      "X-Auth-Token": str(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']))
     
     #verify content
     obj = json.loads(content)
     if not "roleRefs" in obj:
         raise self.fail("Expecting RoleRefs")
开发者ID:jakedahn,项目名称:keystone,代码行数:20,代码来源:test_roles.py

示例10: test_get_rolerefs_xml_using_service_admin_token

 def test_get_rolerefs_xml_using_service_admin_token(self):
     header = httplib2.Http(".cache")
     utils.add_user_json(self.auth_token)
     _resp, _content = utils.create_role_ref(
         self.user, 'Admin', self.tenant,
             str(self.auth_token))
     url = '%susers/%s/roleRefs' % (URL_V2, self.user)
     #test for Content-Type = application/xml
     resp, content = header.request(url, "GET", body='{}',
         headers={"Content-Type": "application/xml",
         "X-Auth-Token": str(self.service_token),
         "ACCEPT": "application/xml"})
     self.assertEqual(200, int(resp['status']))
     #verify content
     dom = etree.Element("root")
     dom.append(etree.fromstring(content))
     roles = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \
         "roleRefs")
     if roles == None:
         self.fail("Expecting Role Refs")
开发者ID:Cerberus98,项目名称:keystone,代码行数:20,代码来源:test_roles.py

示例11: test_role_ref_create_json_using_invalid_token

 def test_role_ref_create_json_using_invalid_token(self):
     utils.add_user_json(self.tenant, self.user, self.auth_token)
     resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant,
         str(self.invalid_token))
     resp_val = int(resp['status'])
     self.assertEqual(404, resp_val)
开发者ID:jakedahn,项目名称:keystone,代码行数:6,代码来源:test_roles.py

示例12: test_role_ref_create_json_using_service_admin_token

 def test_role_ref_create_json_using_service_admin_token(self):
     utils.add_user_json(self.auth_token)
     resp, _content = utils.create_role_ref(self.user, 'Admin', self.tenant,
         str(self.service_token))
     resp_val = int(resp['status'])
     self.assertEqual(201, resp_val)
开发者ID:Cerberus98,项目名称:keystone,代码行数:6,代码来源:test_roles.py

示例13: test_role_ref_create_json_using_missing_token

 def test_role_ref_create_json_using_missing_token(self):
     utils.add_user_json(self.auth_token)
     resp, _content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.missing_token))
     resp_val = int(resp["status"])
     self.assertEqual(401, resp_val)
开发者ID:Mirantis,项目名称:keystone,代码行数:5,代码来源:test_roles.py


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