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


Python IdentityManagementServiceClient.signon方法代码示例

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


在下文中一共展示了IdentityManagementServiceClient.signon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 signon [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 signon [as 别名]

#.........这里部分代码省略.........
        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)


    def test_signon(self):
        certificate =  """-----BEGIN CERTIFICATE-----
MIIEMzCCAxugAwIBAgICBQAwDQYJKoZIhvcNAQEFBQAwajETMBEGCgmSJomT8ixkARkWA29yZzEX
MBUGCgmSJomT8ixkARkWB2NpbG9nb24xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdDSUxvZ29uMRsw
GQYDVQQDExJDSUxvZ29uIEJhc2ljIENBIDEwHhcNMTAxMTE4MjIyNTA2WhcNMTAxMTE5MTAzMDA2
WjBvMRMwEQYKCZImiZPyLGQBGRMDb3JnMRcwFQYKCZImiZPyLGQBGRMHY2lsb2dvbjELMAkGA1UE
BhMCVVMxFzAVBgNVBAoTDlByb3RlY3ROZXR3b3JrMRkwFwYDVQQDExBSb2dlciBVbndpbiBBMjU0
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6QhsWxhUXbIxg+1ZyEc7d+hIGvchVmtb
g0kKLmivgoVsA4U7swNDRH6svW242THta0oTf6crkRx7kOKg6jma2lcAC1sjOSddqX7/92ChoUPq
7LWt2T6GVVA10ex5WAeB/o7br/Z4U8/75uCBis+ru7xEDl09PToK20mrkcz9M4HqIv1eSoPkrs3b
2lUtQc6cjuHRDU4NknXaVMXTBHKPM40UxEDHJueFyCiZJFg3lvQuSsAl4JL5Z8pC02T8/bODBuf4
dszsqn2SC8YDw1xrujvW2Bd7Q7BwMQ/gO+dZKM1mLJFpfEsR9WrjMeg6vkD2TMWLMr0/WIkGC8u+
6M6SMQIDAQABo4HdMIHaMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgSwMBMGA1UdJQQMMAoG
CCsGAQUFBwMCMBgGA1UdIAQRMA8wDQYLKwYBBAGCkTYBAgEwagYDVR0fBGMwYTAuoCygKoYoaHR0
cDovL2NybC5jaWxvZ29uLm9yZy9jaWxvZ29uLWJhc2ljLmNybDAvoC2gK4YpaHR0cDovL2NybC5k
b2Vncmlkcy5vcmcvY2lsb2dvbi1iYXNpYy5jcmwwHwYDVR0RBBgwFoEUaXRzYWdyZWVuMUB5YWhv
by5jb20wDQYJKoZIhvcNAQEFBQADggEBAEYHQPMY9Grs19MHxUzMwXp1GzCKhGpgyVKJKW86PJlr
HGruoWvx+DLNX75Oj5FC4t8bOUQVQusZGeGSEGegzzfIeOI/jWP1UtIjzvTFDq3tQMNvsgROSCx5
CkpK4nS0kbwLux+zI7BWON97UpMIzEeE05pd7SmNAETuWRsHMP+x6i7hoUp/uad4DwbzNUGIotdK
f8b270icOVgkOKRdLP/Q4r/x8skKSCRz1ZsRdR+7+B/EgksAJj7Ut3yiWoUekEMxCaTdAHPTMD/g
Mh9xL90hfMJyoGemjJswG5g3fAdTP/Lv0I6/nWeH/cLjwwpQgIEjEAVXl7KHuzX5vPD/wqQ=
-----END CERTIFICATE-----"""
        id, valid_until, registered = self.identity_management_service.signon(certificate, True)

        self.assertFalse(registered)

        id2, valid_until2, registered2 = self.identity_management_service.signon(certificate, True)

        self.assertFalse(registered2)
        self.assertTrue(id == id2)
        self.assertTrue(valid_until == valid_until2)

        user_info_obj = IonObject("UserInfo", {"name": "Foo"})        
开发者ID:lukecampbell,项目名称:coi-services,代码行数:70,代码来源: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 signon [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 signon [as 别名]
    def test_non_anonymous_resource_registry_operations_with_token(self):
        rr = self.container.resource_registry
        id_client = IdentityManagementServiceClient()

        create_request = {
            "serviceRequest": {
                "serviceName": "resource_registry",
                "serviceOp": "create",
                "params": {"object": {"name": "Instrument1", "type_": "InstrumentDevice"}},
            }
        }

        # Create without actor
        response = self.test_app.post(
            "/ion-service/resource_registry/create", {"payload": simplejson.dumps(create_request)}
        )
        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.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.PUBLIC)

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

        # Anonymous query shows PUBLIC visibility 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]), 1)
        self.assertEqual(len(response_data[1]), 1)
        self.assertEqual(response_data[0][0], inst_id)

        inst_obj.visibility = ResourceVisibilityEnum.OWNER
        rr.update(inst_obj)

        # Now the 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)

        rr.delete(inst_id)

        # Create with actor
        actor_id, valid_until, registered = id_client.signon(USER1_CERTIFICATE, True)

        create_request = {
            "serviceRequest": {
                "serviceName": "resource_registry",
                "serviceOp": "create",
                "requester": actor_id,
                "params": {
                    "object": {
                        "name": "Instrument1",
                        "type_": "InstrumentDevice",
                        "visibility": ResourceVisibilityEnum.OWNER,
                    }
                },
            }
        }

        response = self.test_app.post(
            "/ion-service/resource_registry/create", {"payload": simplejson.dumps(create_request)}
        )
        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.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
#.........这里部分代码省略.........
开发者ID:edwardhunter2,项目名称:coi-services,代码行数:103,代码来源: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 signon [as 别名]

#.........这里部分代码省略.........
        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)

    def test_signon(self):
        certificate =  """-----BEGIN CERTIFICATE-----
MIIEMzCCAxugAwIBAgICBQAwDQYJKoZIhvcNAQEFBQAwajETMBEGCgmSJomT8ixkARkWA29yZzEX
MBUGCgmSJomT8ixkARkWB2NpbG9nb24xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdDSUxvZ29uMRsw
GQYDVQQDExJDSUxvZ29uIEJhc2ljIENBIDEwHhcNMTAxMTE4MjIyNTA2WhcNMTAxMTE5MTAzMDA2
WjBvMRMwEQYKCZImiZPyLGQBGRMDb3JnMRcwFQYKCZImiZPyLGQBGRMHY2lsb2dvbjELMAkGA1UE
BhMCVVMxFzAVBgNVBAoTDlByb3RlY3ROZXR3b3JrMRkwFwYDVQQD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EjEAVXl7KHuzX5vPD/wqQ=
-----END CERTIFICATE-----"""
        id, valid_until, registered = self.identity_management_service.signon(certificate, True)

        self.assertFalse(registered)

        id2, valid_until2, registered2 = self.identity_management_service.signon(certificate, True)

        self.assertFalse(registered2)
        self.assertTrue(id == id2)
        self.assertTrue(valid_until == valid_until2)

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

        id3, valid_until3, registered3 = self.identity_management_service.signon(certificate, True)

        self.assertTrue(registered3)
        self.assertTrue(id == id3)
        self.assertTrue(valid_until == valid_until3)
开发者ID:dstuebe,项目名称:coi-services,代码行数:104,代码来源:test_identity_management_service.py


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