本文整理汇总了Python中interface.services.coi.iorg_management_service.OrgManagementServiceClient.find_org方法的典型用法代码示例。如果您正苦于以下问题:Python OrgManagementServiceClient.find_org方法的具体用法?Python OrgManagementServiceClient.find_org怎么用?Python OrgManagementServiceClient.find_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.coi.iorg_management_service.OrgManagementServiceClient
的用法示例。
在下文中一共展示了OrgManagementServiceClient.find_org方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_extended_user_identity
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [as 别名]
def test_get_extended_user_identity(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)
org_client = OrgManagementServiceClient(node=self.container.node)
ion_org = org_client.find_org()
extended_user = self.identity_management_service.get_actor_identity_extension(user_id, ion_org._id)
self.assertEqual(actor_identity_obj.type_,extended_user.resource.type_)
self.assertEqual(len(extended_user.roles),1)
extended_user = self.identity_management_service.get_actor_identity_extension(user_id)
self.assertEqual(actor_identity_obj.type_,extended_user.resource.type_)
self.assertEqual(len(extended_user.roles),0)
self.identity_management_service.delete_user_info(user_info)
self.identity_management_service.unregister_user_credentials(user_id, self.subject)
self.identity_management_service.delete_actor_identity(user_id)
示例2: TestOrgManagementServiceInt
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [as 别名]
class TestOrgManagementServiceInt(IonIntegrationTestCase):
def setUp(self):
# Start container
self._start_container()
# Establish endpoint with container
container_client = ContainerAgentClient(node=self.container.node, name=self.container.name)
container_client.start_rel_from_url('res/deploy/r2coi.yml')
self.org_management_service = OrgManagementServiceClient(node=self.container.node)
def test_org_crud(self):
org_obj = IonObject("Org", {"name": "Test Facility"})
org_id = self.org_management_service.create_org(org_obj)
self.assertNotEqual(org_id, None)
org = None
org = self.org_management_service.read_org(org_id)
self.assertNotEqual(org, None)
org.name = 'Updated Test Facility'
self.org_management_service.update_org(org)
org = None
org = self.org_management_service.read_org(org_id)
self.assertNotEqual(org, None)
self.assertEqual(org.name, 'Updated Test Facility')
self.org_management_service.delete_org(org_id)
with self.assertRaises(NotFound) as cm:
self.org_management_service.read_org(org_id)
self.assertIn("does not exist", cm.exception.message)
with self.assertRaises(NotFound) as cm:
self.org_management_service.delete_org(org_id)
self.assertIn("does not exist", cm.exception.message)
def test_org_affiliation(self):
root_org = None
root_org = self.org_management_service.find_org()
self.assertNotEqual(root_org, None)
org_obj = IonObject("Org", {"name": "Test Facility"})
org_id = self.org_management_service.create_org(org_obj)
self.assertNotEqual(org_id, None)
ret = self.org_management_service.affiliate_org(root_org._id, org_id)
self.assertTrue(ret)
ret = self.org_management_service.unaffiliate_org(root_org._id, org_id)
self.assertTrue(ret)
示例3: TestOrgManagementServiceInt
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [as 别名]
class TestOrgManagementServiceInt(IonIntegrationTestCase):
def setUp(self):
# Start container
self._start_container()
self.container.start_rel_from_url("res/deploy/r2coi.yml")
self.resource_registry = ResourceRegistryServiceClient(node=self.container.node)
self.org_management_service = OrgManagementServiceClient(node=self.container.node)
def test_org_crud(self):
with self.assertRaises(BadRequest) as br:
self.org_management_service.create_org(
IonObject("Org", {"name": "Test Facility", "org_governance_name": "Test Facility"})
)
self.assertTrue("can only contain alphanumeric and underscore characters" in br.exception.message)
with self.assertRaises(BadRequest):
self.org_management_service.create_org()
org_obj = IonObject("Org", {"name": "Test Facility"})
org_id = self.org_management_service.create_org(org_obj)
self.assertNotEqual(org_id, None)
org = None
org = self.org_management_service.read_org(org_id)
self.assertNotEqual(org, None)
self.assertEqual(org.org_governance_name, "Test_Facility")
# Check that the roles got associated to them
role_list = self.org_management_service.find_org_roles(org_id)
self.assertEqual(len(role_list), 2)
with self.assertRaises(BadRequest):
self.org_management_service.update_org()
org.name = "Updated Test Facility"
self.org_management_service.update_org(org)
org = None
org = self.org_management_service.read_org(org_id)
self.assertNotEqual(org, None)
self.assertEqual(org.name, "Updated Test Facility")
self.assertEqual(org.org_governance_name, "Test_Facility")
user_role = self.org_management_service.find_org_role_by_name(org_id, ORG_MANAGER_ROLE)
self.assertNotEqual(user_role, None)
self.org_management_service.remove_user_role(org_id, ORG_MANAGER_ROLE)
with self.assertRaises(BadRequest) as cm:
user_role = self.org_management_service.find_org_role_by_name(org_id, ORG_MANAGER_ROLE)
self.assertIn("The User Role 'ORG_MANAGER' does not exist for this Org", cm.exception.message)
with self.assertRaises(BadRequest):
self.org_management_service.delete_org()
self.org_management_service.delete_org(org_id)
with self.assertRaises(NotFound) as cm:
self.org_management_service.read_org(org_id)
self.assertIn("does not exist", cm.exception.message)
with self.assertRaises(NotFound) as cm:
self.org_management_service.delete_org(org_id)
self.assertIn("does not exist", cm.exception.message)
def test_org_affiliation(self):
root_org = None
root_org = self.org_management_service.find_org()
self.assertNotEqual(root_org, None)
org_obj = IonObject("Org", {"name": "TestFacility"})
org_id = self.org_management_service.create_org(org_obj)
self.assertNotEqual(org_id, None)
ret = self.org_management_service.affiliate_org(root_org._id, org_id)
self.assertTrue(ret)
ret = self.org_management_service.unaffiliate_org(root_org._id, org_id)
self.assertTrue(ret)
def test_find_org_containers(self):
root_org = None
root_org = self.org_management_service.find_org()
self.assertNotEqual(root_org, None)
containers = self.org_management_service.find_org_containers(root_org._id)
all_containers, _ = self.resource_registry.find_resources(restype=RT.CapabilityContainer, id_only=True)
self.assertEqual(len(containers), len(all_containers))
示例4: TestIdentityManagementServiceInt
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [as 别名]
#.........这里部分代码省略.........
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"})
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)
@attr('EXT')
def test_get_extended_user_identity(self):
actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})
actor_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(actor_id, user_credentials_obj)
user_info_obj = IonObject("UserInfo", {"name": "Foo"})
user_info_id = self.identity_management_service.create_user_info(actor_id, user_info_obj)
ion_org = self.org_client.find_org()
#Build the Service Agreement Proposal to to request a role but never close it
sap = IonObject(OT.RequestRoleProposal,consumer=actor_id, provider=ion_org._id, role_name=ORG_MANAGER_ROLE )
sap_response = self.org_client.negotiate(sap)
#Just grant the role anyway
#self.org_client.grant_role(ion_org._id, actor_id, ORG_MANAGER_ROLE)
with self.assertRaises(NotFound):
self.identity_management_service.get_user_info_extension('That rug really tied the room together.')
with self.assertRaises(BadRequest):
self.identity_management_service.get_user_info_extension()
#Check the user without the negotiation role request
extended_user = self.identity_management_service.get_user_info_extension(user_info_id, org_id=ion_org._id)
self.assertEqual(user_info_obj.type_,extended_user.resource.type_)
self.assertEqual(len(extended_user.roles),1)
self.assertEqual(len(extended_user.open_requests),1)
self.assertEqual(extended_user.open_requests[0].org_id, ion_org._id)
self.assertEqual(extended_user.open_requests[0].user_id, user_info_id)
self.assertEqual(extended_user.open_requests[0].request_type, OT.RequestRoleProposal)
self.assertEqual(len(extended_user.closed_requests),0)
self.assertEqual(extended_user.open_requests[0]._id, extended_user.open_requests[0].negotiation_id)
neg = self.resource_registry.read(object_id=extended_user.open_requests[0].negotiation_id)
sap_response = Negotiation.create_counter_proposal(neg, ProposalStatusEnum.ACCEPTED, ProposalOriginatorEnum.PROVIDER)
sap_response2 = self.org_client.negotiate(sap_response)
#Now check the user after the negotiation has been accepted and the role granted
extended_user = self.identity_management_service.get_user_info_extension(user_info_id, org_id=ion_org._id)
self.assertEqual(user_info_obj.type_,extended_user.resource.type_)
self.assertEqual(len(extended_user.roles),2)
示例5: test_user_role_cache
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [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)
示例6: TestObservatoryManagementServiceIntegration
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [as 别名]
#.........这里部分代码省略.........
geo_index_obj.geospatial_latitude_limit_north = 30.0
geo_index_obj.geospatial_latitude_limit_south = 20.0
platformsite_obj.constraint_list = [geo_index_obj]
update_result = self.OMS.update_platform_site(platformsite_obj)
# now get the dp back to see if it was updated
platformsite_obj = self.OMS.read_platform_site(platformsite_id)
self.assertEquals('some old TestPlatformSite', platformsite_obj.description)
self.assertAlmostEqual(25.0, platformsite_obj.geospatial_point_center.lat, places=1)
self.OMS.force_delete_platform_site(platformsite_id)
#@unittest.skip("targeting")
def _do_test_find_observatory_org(self, resources):
log.debug("Make TestOrg")
org_obj = IonObject(RT.Org,
name='TestOrg',
description='some new mf org')
org_id = self.OMS.create_marine_facility(org_obj)
log.debug("Make Observatory")
observatory_obj = IonObject(RT.Observatory,
name='TestObservatory',
description='some new obs')
observatory_id = self.OMS.create_observatory(observatory_obj)
log.debug("assign observatory to org")
self.OMS.assign_resource_to_observatory_org(observatory_id, org_id)
log.debug("verify assigment")
org_objs = self.OMS.find_org_by_observatory(observatory_id)
self.assertEqual(1, len(org_objs))
self.assertEqual(org_id, org_objs[0]._id)
log.debug("org_id=<" + org_id + ">")
log.debug("create a subsite with parent Observatory")
subsite_obj = IonObject(RT.Subsite,
name= 'TestSubsite',
description = 'sample subsite')
subsite_id = self.OMS.create_subsite(subsite_obj, observatory_id)
self.assertIsNotNone(subsite_id, "Subsite not created.")
log.debug("verify that Subsite is linked to Observatory")
mf_subsite_assoc = self.RR.get_association(observatory_id, PRED.hasSite, subsite_id)
self.assertIsNotNone(mf_subsite_assoc, "Subsite not connected to Observatory.")
log.debug("add the Subsite as a resource of this Observatory")
self.OMS.assign_resource_to_observatory_org(resource_id=subsite_id, org_id=org_id)
log.debug("verify that Subsite is linked to Org")
org_subsite_assoc = self.RR.get_association(org_id, PRED.hasResource, subsite_id)
self.assertIsNotNone(org_subsite_assoc, "Subsite not connected as resource to Org.")
log.debug("create a logical platform with parent Subsite")
platform_site_obj = IonObject(RT.PlatformSite,
name= 'TestPlatformSite',
description = 'sample logical platform')
platform_site_id = self.OMS.create_platform_site(platform_site_obj, subsite_id)
self.assertIsNotNone(platform_site_id, "PlatformSite not created.")
log.debug("verify that PlatformSite is linked to Site")
site_lp_assoc = self.RR.get_association(subsite_id, PRED.hasSite, platform_site_id)
示例7: TestObservatoryManagementServiceIntegration
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [as 别名]
#.........这里部分代码省略.........
ret.deployment_id = deployment_id
return ret
#@unittest.skip("targeting")
def test_create_observatory(self):
observatory_obj = IonObject(RT.Observatory,
name='TestFacility',
description='some new mf')
observatory_id = self.OMS.create_observatory(observatory_obj)
self.OMS.force_delete_observatory(observatory_id)
#@unittest.skip("targeting")
def test_find_observatory_org(self):
org_obj = IonObject(RT.Org,
name='TestOrg',
description='some new mf org')
org_id = self.OMS.create_marine_facility(org_obj)
observatory_obj = IonObject(RT.Observatory,
name='TestObservatory',
description='some new obs')
observatory_id = self.OMS.create_observatory(observatory_obj)
#make association
self.OMS.assign_resource_to_observatory_org(observatory_id, org_id)
#find association
org_objs = self.OMS.find_org_by_observatory(observatory_id)
self.assertEqual(1, len(org_objs))
self.assertEqual(org_id, org_objs[0]._id)
print("org_id=<" + org_id + ">")
#create a subsite with parent Observatory
subsite_obj = IonObject(RT.Subsite,
name= 'TestSubsite',
description = 'sample subsite')
subsite_id = self.OMS.create_subsite(subsite_obj, observatory_id)
self.assertIsNotNone(subsite_id, "Subsite not created.")
# verify that Subsite is linked to Observatory
mf_subsite_assoc = self.RR.get_association(observatory_id, PRED.hasSite, subsite_id)
self.assertIsNotNone(mf_subsite_assoc, "Subsite not connected to Observatory.")
# add the Subsite as a resource of this Observatory
self.OMS.assign_resource_to_observatory_org(resource_id=subsite_id, org_id=org_id)
# verify that Subsite is linked to Org
org_subsite_assoc = self.RR.get_association(org_id, PRED.hasResource, subsite_id)
self.assertIsNotNone(org_subsite_assoc, "Subsite not connected as resource to Org.")
#create a logical platform with parent Subsite
platform_site_obj = IonObject(RT.PlatformSite,
name= 'TestPlatformSite',
description = 'sample logical platform')
platform_site_id = self.OMS.create_platform_site(platform_site_obj, subsite_id)
self.assertIsNotNone(platform_site_id, "PlatformSite not created.")
# verify that PlatformSite is linked to Site
site_lp_assoc = self.RR.get_association(subsite_id, PRED.hasSite, platform_site_id)
示例8: TestOrgManagementServiceInt
# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import find_org [as 别名]
class TestOrgManagementServiceInt(IonIntegrationTestCase):
def setUp(self):
# Start container
self._start_container()
self.container.start_rel_from_url('res/deploy/r2coi.yml')
self.org_management_service = OrgManagementServiceClient(node=self.container.node)
def test_org_crud(self):
with self.assertRaises(BadRequest) as br:
self.org_management_service.create_org(IonObject("Org", {"name": "Test Facility"}))
self.assertTrue("can only contain alphanumeric and underscore characters" in br.exception.message)
org_obj = IonObject("Org", {"name": "TestFacility"})
org_id = self.org_management_service.create_org(org_obj)
self.assertNotEqual(org_id, None)
org = None
org = self.org_management_service.read_org(org_id)
self.assertNotEqual(org, None)
#Check that the roles got associated to them
role_list = self.org_management_service.find_org_roles(org_id)
self.assertEqual(len(role_list),2 )
org.name = 'Updated_TestFacility'
self.org_management_service.update_org(org)
org = None
org = self.org_management_service.read_org(org_id)
self.assertNotEqual(org, None)
self.assertEqual(org.name, 'Updated_TestFacility')
self.org_management_service.delete_org(org_id)
with self.assertRaises(NotFound) as cm:
self.org_management_service.read_org(org_id)
self.assertIn("does not exist", cm.exception.message)
with self.assertRaises(NotFound) as cm:
self.org_management_service.delete_org(org_id)
self.assertIn("does not exist", cm.exception.message)
def test_org_affiliation(self):
root_org = None
root_org = self.org_management_service.find_org()
self.assertNotEqual(root_org, None)
org_obj = IonObject("Org", {"name": "TestFacility"})
org_id = self.org_management_service.create_org(org_obj)
self.assertNotEqual(org_id, None)
ret = self.org_management_service.affiliate_org(root_org._id, org_id)
self.assertTrue(ret)
ret = self.org_management_service.unaffiliate_org(root_org._id, org_id)
self.assertTrue(ret)