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


Python IdentityManagementServiceClient.delete_actor_identity方法代码示例

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


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

示例1: test_non_anonymous_resource_registry_operations_through_gateway

# 需要导入模块: from interface.services.coi.iidentity_management_service import IdentityManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iidentity_management_service.IdentityManagementServiceClient import delete_actor_identity [as 别名]
    def test_non_anonymous_resource_registry_operations_through_gateway(self):

        id_client = IdentityManagementServiceClient(node=self.container.node)

        actor_id, valid_until, registered = id_client.signon(USER1_CERTIFICATE, True)

        response = self.test_app.get('/ion-service/resource_registry/find_resources?name=TestDataProduct&id_only=True&requester=' + actor_id)
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json['data'])
        response_data = response.json['data'][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data),2 )
        self.assertEqual(len(response_data[0]), 0 )

        id_client.delete_actor_identity(actor_id)
开发者ID:MatthewArrott,项目名称:coi-services,代码行数:16,代码来源:test_service_gateway_service.py

示例2: TestIdentityManagementServiceInt

# 需要导入模块: from interface.services.coi.iidentity_management_service import IdentityManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iidentity_management_service.IdentityManagementServiceClient import delete_actor_identity [as 别名]
class TestIdentityManagementServiceInt(IonIntegrationTestCase):
    
    def setUp(self):
        self.subject = "/DC=org/DC=cilogon/C=US/O=ProtectNetwork/CN=Roger Unwin A254"

        # Start container
        self._start_container()
        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.resource_registry = ResourceRegistryServiceClient(node=self.container.node)
        self.identity_management_service = IdentityManagementServiceClient(node=self.container.node)
        self.org_client = OrgManagementServiceClient(node=self.container.node)

    def test_actor_identity(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})        
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        actor_identity = self.identity_management_service.read_actor_identity(user_id)

        actor_identity.name = 'Updated subject'
        self.identity_management_service.update_actor_identity(actor_identity)

        ai = self.identity_management_service.find_actor_identity_by_name(actor_identity.name)
        self._baseAssertEqual(ai.name, actor_identity.name)
        with self.assertRaises(NotFound):
            ai = self.identity_management_service.find_actor_identity_by_name("Yeah, well, you know, that's just, like, your opinion, man.")

        self._baseAssertEqual(ai.name, actor_identity.name)

        self.identity_management_service.delete_actor_identity(user_id)
 
        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.read_actor_identity(user_id)
        self.assertTrue("does not exist" in cm.exception.message)
 
        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.delete_actor_identity(user_id)
        self.assertTrue("does not exist" in cm.exception.message)

    def test_user_credentials(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})        
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        user_credentials_obj = IonObject("UserCredentials", {"name": self.subject})        
        self.identity_management_service.register_user_credentials(user_id, user_credentials_obj)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials("bad", self.subject)
        self.assertTrue("does not exist" in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials(user_id, "bad")
        self.assertTrue("does not exist" in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials('bad', 'bad')
        self.assertTrue("does not exist" in cm.exception.message)

        self.identity_management_service.unregister_user_credentials(user_id, self.subject)

        self.identity_management_service.delete_actor_identity(user_id)




    def test_user_info(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        user_credentials_obj = IonObject("UserCredentials", {"name": self.subject})
        self.identity_management_service.register_user_credentials(user_id, user_credentials_obj)

        user_info_obj = IonObject("UserInfo", {"name": "Foo"})
        user_info = self.identity_management_service.create_user_info(user_id, user_info_obj)

        with self.assertRaises(Conflict) as cm:
            self.identity_management_service.create_user_info(user_id, user_info_obj)
        self.assertTrue("UserInfo already exists for user id" in cm.exception.message)

        user_info_obj = self.identity_management_service.find_user_info_by_id(user_id)

        user_info_obj = self.identity_management_service.find_user_info_by_name("Foo")

        user_info_obj = self.identity_management_service.find_user_info_by_subject(self.subject)

        user_info_obj = self.identity_management_service.read_user_info(user_info)

        user_info_obj.name = 'Jane Doe'

        self.identity_management_service.update_user_info(user_info_obj)

        self.identity_management_service.delete_user_info(user_info)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.read_user_info(user_info)
        self.assertTrue('does not exist' in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.delete_user_info(user_info)
        self.assertTrue('does not exist' in cm.exception.message)
#.........这里部分代码省略.........
开发者ID:lukecampbell,项目名称:coi-services,代码行数:103,代码来源:test_identity_management_service.py

示例3: test_user_role_cache

# 需要导入模块: from interface.services.coi.iidentity_management_service import IdentityManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iidentity_management_service.IdentityManagementServiceClient import delete_actor_identity [as 别名]
    def test_user_role_cache(self):
        # Create a user
        id_client = IdentityManagementServiceClient()

        actor_id, valid_until, registered = id_client.signon(USER1_CERTIFICATE, True)

        # Make a request with this new user  to get it into the cache
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=TestDataProduct&id_only=True&requester=" + actor_id
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])

        # Check the contents of the user role cache for this user
        service_gateway_user_role_cache = self.container.proc_manager.procs_by_name["service_gateway"].user_role_cache
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), True)

        role_header = service_gateway_user_role_cache.get(actor_id)
        self.assertIn("ION", role_header)
        self.assertEqual(len(role_header["ION"]), 1)
        self.assertIn("ORG_MEMBER", role_header["ION"])

        org_client = OrgManagementServiceClient()

        ion_org = org_client.find_org()
        manager_role = org_client.find_org_role_by_name(org_id=ion_org._id, role_name="ORG_MANAGER")

        org_client.grant_role(org_id=ion_org._id, actor_id=actor_id, role_name="ORG_MANAGER")

        # Just allow some time for event processing on slower platforms
        gevent.sleep(2)

        # The user should be evicted from the cache due to a change in roles
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), False)

        # Do it again to check for new roles
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=TestDataProduct&id_only=True&requester=" + actor_id
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])

        # Check the contents of the user role cache for this user
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), True)

        role_header = service_gateway_user_role_cache.get(actor_id)
        self.assertIn("ION", role_header)
        self.assertEqual(len(role_header["ION"]), 2)
        self.assertIn("ORG_MEMBER", role_header["ION"])
        self.assertIn("ORG_MANAGER", role_header["ION"])

        # Now flush the user_role_cache and make sure it was flushed
        event_publisher = EventPublisher()
        event_publisher.publish_event(event_type=OT.UserRoleCacheResetEvent)

        # Just allow some time for event processing on slower platforms
        gevent.sleep(2)

        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), False)
        self.assertEqual(service_gateway_user_role_cache.size(), 0)

        # Change the role once again and see if it is there again
        org_client.revoke_role(org_id=ion_org._id, actor_id=actor_id, role_name="ORG_MANAGER")

        # Just allow some time for event processing on slower platforms
        gevent.sleep(2)

        # The user should still not be there
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), False)

        # Do it again to check for new roles
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=TestDataProduct&id_only=True&requester=" + actor_id
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])

        # Check the contents of the user role cache for this user
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), True)

        role_header = service_gateway_user_role_cache.get(actor_id)
        self.assertIn("ION", role_header)
        self.assertEqual(len(role_header["ION"]), 1)
        self.assertIn("ORG_MEMBER", role_header["ION"])

        id_client.delete_actor_identity(actor_id)
开发者ID:edwardhunter2,项目名称:coi-services,代码行数:88,代码来源:test_service_gateway_service.py

示例4: test_non_anonymous_resource_registry_operations_with_token

# 需要导入模块: from interface.services.coi.iidentity_management_service import IdentityManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iidentity_management_service.IdentityManagementServiceClient import delete_actor_identity [as 别名]

#.........这里部分代码省略.........
        self.assertGreaterEqual(len(response_data[0]), 20)  # This is a resource_id
        inst_id = str(response_data[0])

        inst_obj = rr.read(inst_id)
        self.assertEquals(inst_obj.type_, RT.InstrumentDevice)
        self.assertEquals(inst_obj.name, "Instrument1")
        self.assertEquals(inst_obj.visibility, ResourceVisibilityEnum.OWNER)

        act_objs, assocs = rr.find_objects(inst_id, PRED.hasOwner, RT.ActorIdentity, id_only=False)
        self.assertEquals(len(act_objs), 1)
        self.assertEquals(act_objs[0]._id, actor_id)

        # Anonymous query should not show the resource anymore
        response = self.test_app.get("/ion-service/resource_registry/find_resources?name=Instrument1&id_only=True")
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])
        response_data = response.json["data"][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data), 2)
        self.assertEqual(len(response_data[0]), 0)

        # Authenticated request with owner shows resource
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=Instrument1&id_only=True&requester=" + actor_id
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])
        response_data = response.json["data"][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data), 2)
        self.assertEqual(len(response_data[0]), 1)
        self.assertEqual(len(response_data[1]), 1)
        self.assertEqual(response_data[0][0], inst_id)

        token_str = id_client.create_authentication_token(actor_id, validity=2)

        # Request with authentication token for owner shows resource
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=Instrument1&id_only=True&authtoken=" + token_str
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])
        response_data = response.json["data"][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data), 2)
        self.assertEqual(len(response_data[0]), 1)
        self.assertEqual(len(response_data[1]), 1)
        self.assertEqual(response_data[0][0], inst_id)

        gevent.sleep(2.1)

        # Request with expired authentication token for owner does not show resource (no error though)
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=Instrument1&id_only=True&authtoken=" + token_str
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])
        response_data = response.json["data"][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data), 2)
        self.assertEqual(len(response_data[0]), 0)

        # Request with valid authentication token for different user does not show resource
        actor_id2, _ = rr.create(IonObject(RT.ActorIdentity, name="Actor2"))
        token_str2 = id_client.create_authentication_token(actor_id2, validity=2)

        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=Instrument1&id_only=True&authtoken=" + token_str2
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])
        response_data = response.json["data"][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data), 2)
        self.assertEqual(len(response_data[0]), 0)

        token_str3 = id_client.create_authentication_token(actor_id, validity=2)

        # Request with new authentication token for owner shows resource
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=Instrument1&id_only=True&authtoken=" + token_str3
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])
        response_data = response.json["data"][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data), 2)
        self.assertEqual(len(response_data[0]), 1)
        self.assertEqual(len(response_data[1]), 1)
        self.assertEqual(response_data[0][0], inst_id)

        id_client.invalidate_authentication_token(token_str3)

        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=Instrument1&id_only=True&authtoken=" + token_str3
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])
        response_data = response.json["data"][GATEWAY_RESPONSE]
        self.assertEqual(len(response_data), 2)
        self.assertEqual(len(response_data[0]), 0)

        # Cleanup
        rr.delete(inst_id)
        rr.delete(actor_id2)
        id_client.delete_actor_identity(actor_id)
开发者ID:edwardhunter2,项目名称:coi-services,代码行数:104,代码来源:test_service_gateway_service.py

示例5: TestIdentityManagementServiceInt

# 需要导入模块: from interface.services.coi.iidentity_management_service import IdentityManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iidentity_management_service.IdentityManagementServiceClient import delete_actor_identity [as 别名]
class TestIdentityManagementServiceInt(IonIntegrationTestCase):
    
    def setUp(self):
        self.subject = "/DC=org/DC=cilogon/C=US/O=ProtectNetwork/CN=Roger Unwin A254"

        # Start container
        self._start_container()
        self.container.start_rel_from_url('res/deploy/r2coi.yml')

        self.identity_management_service = IdentityManagementServiceClient(node=self.container.node)

    def test_actor_identity(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})        
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        actor_identity = self.identity_management_service.read_actor_identity(user_id)

        actor_identity.name = 'Updated subject'
        self.identity_management_service.update_actor_identity(actor_identity)

        self.identity_management_service.delete_actor_identity(user_id)
 
        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.read_actor_identity(user_id)
        self.assertTrue("does not exist" in cm.exception.message)
 
        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.delete_actor_identity(user_id)
        self.assertTrue("does not exist" in cm.exception.message)

    def test_user_credentials(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})        
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        user_credentials_obj = IonObject("UserCredentials", {"name": self.subject})        
        self.identity_management_service.register_user_credentials(user_id, user_credentials_obj)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials("bad", self.subject)
        self.assertTrue("does not exist" in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials(user_id, "bad")
        self.assertTrue("does not exist" in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials('bad', 'bad')
        self.assertTrue("does not exist" in cm.exception.message)

        self.identity_management_service.unregister_user_credentials(user_id, self.subject)

        self.identity_management_service.delete_actor_identity(user_id)

    def test_user_info(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})        
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        user_credentials_obj = IonObject("UserCredentials", {"name": self.subject})        
        self.identity_management_service.register_user_credentials(user_id, user_credentials_obj)

        user_info_obj = IonObject("UserInfo", {"name": "Foo"})        
        user_info = self.identity_management_service.create_user_info(user_id, user_info_obj)

        with self.assertRaises(Conflict) as cm:
            self.identity_management_service.create_user_info(user_id, user_info_obj)
        self.assertTrue("UserInfo already exists for user id" in cm.exception.message)

        user_info_obj = self.identity_management_service.find_user_info_by_id(user_id)

        user_info_obj = self.identity_management_service.find_user_info_by_name("Foo")

        user_info_obj = self.identity_management_service.find_user_info_by_subject(self.subject)

        user_info_obj = self.identity_management_service.read_user_info(user_info)
        
        user_info_obj.name = 'Jane Doe'
        
        self.identity_management_service.update_user_info(user_info_obj)
        
        self.identity_management_service.delete_user_info(user_info)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.read_user_info(user_info)
        self.assertTrue('does not exist' in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.delete_user_info(user_info)
        self.assertTrue('does not exist' in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.find_user_info_by_name("John Doe")
        self.assertEqual(cm.exception.message, 'UserInfo with name John Doe does not exist')

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.find_user_info_by_subject("Bogus subject")
        self.assertEqual(cm.exception.message, "UserCredentials with subject Bogus subject does not exist")

        self.identity_management_service.unregister_user_credentials(user_id, self.subject)

        self.identity_management_service.delete_actor_identity(user_id)
#.........这里部分代码省略.........
开发者ID:dstuebe,项目名称:coi-services,代码行数:103,代码来源:test_identity_management_service.py

示例6: TestRegisterAndActivate

# 需要导入模块: from interface.services.coi.iidentity_management_service import IdentityManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iidentity_management_service.IdentityManagementServiceClient import delete_actor_identity [as 别名]

#.........这里部分代码省略.........
        if self.cabled_instrument_model_id:
            self.oms.unassign_instrument_model_from_instrument_site(
                self.cabled_instrument_model_id, self.cabled_instrument_site_id)
            self.ims.delete_instrument_model(self.cabled_instrument_model_id)
            self.cabled_instrument_model_id = None

        if self.cabled_platform_model_id:
            self.oms.unassign_platform_model_from_platform_site(
                self.cabled_platform_model_id, self.cabled_platform_site_id)
            self.ims.delete_platform_model(self.cabled_platform_model_id)
            self.cabled_platform_model_id = None

        if self.cabled_instrument_site_id:
            self.oms.unassign_site_from_site(self.cabled_instrument_site_id,
                                             self.cabled_platform_site_id)
            self.oms.delete_instrument_site(self.cabled_instrument_site_id)
            self.cabled_instrument_site_id = None

        if self.cabled_platform_site_id:
            self.oms.unassign_site_from_site(self.cabled_platform_site_id,
                                             self.obs_id)
            self.oms.delete_platform_site(self.cabled_platform_site_id)
            self.cabled_platform_site_id = None

        # Check and clean up unclabled resources.
        # TODO

        # Clean up generic resources.
        if self.user_info_id:
            self.idms.delete_user_info(self.user_info_id)
            self.user_info_id = None

        if self.actor_id:
            self.idms.delete_actor_identity(self.actor_id)
            self.actor_id = None

        if self.obs_id:
            self.oms.delete_observatory(self.obs_id)
            self.obs_id = None

        if self.org_id:
            self.container.resource_registry.delete(self.org_id)
            self.org_id = None


    def _load_system_actors(self):
        """
        Retrieve system and webauth actors and headers for later use.
        """

        # Retrieve and store system actor and headers.
        system_actor, _ = self.container.resource_registry.find_resources(
            RT.ActorIdentity,
            name=CFG.system.system_actor,
            id_only=False)
        self.system_actor = system_actor[0] if system_actor else None
        self.system_actor_id = system_actor[0]._id if system_actor \
            else 'anonymous'
        self.system_actor_headers = {
            'ion-actor-id': self.system_actor_id,
            'ion-actor-roles': {'ION': ['ION_MANAGER', 'ORG_MANAGER']},
            'expiry':'0'
        }

        # Retrieve and store webauth actor and headers.
        webauth_actor, _ = self.container.resource_registry.find_resources(
开发者ID:pkediyal,项目名称:coi-services,代码行数:70,代码来源:test_register_and_activate.py


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