本文整理汇总了Python中interface.services.coi.iidentity_management_service.IdentityManagementServiceClient.check_authentication_token方法的典型用法代码示例。如果您正苦于以下问题:Python IdentityManagementServiceClient.check_authentication_token方法的具体用法?Python IdentityManagementServiceClient.check_authentication_token怎么用?Python IdentityManagementServiceClient.check_authentication_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.coi.iidentity_management_service.IdentityManagementServiceClient
的用法示例。
在下文中一共展示了IdentityManagementServiceClient.check_authentication_token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestIdentityManagementServiceInt
# 需要导入模块: from interface.services.coi.iidentity_management_service import IdentityManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iidentity_management_service.IdentityManagementServiceClient import check_authentication_token [as 别名]
#.........这里部分代码省略.........
# Try merging the account again
with self.assertRaises(BadRequest):
self.identity_management_service.complete_account_merge(token, headers={'ion-actor-id':id})
# Signon again and verify the two accounts have been merged
id, valid_until, registered = self.identity_management_service.signon(certificate, True)
self.assertTrue(registered)
id_2, valid_until_2, registered_2 = self.identity_management_service.signon(certificate_2, True)
self.assertTrue(registered_2)
# Validate the two accounts are the same
self.assertEqual(id, id_2, "The two accounts should have the same id")
# Try to merge to your own account
with self.assertRaises(BadRequest):
token = self.identity_management_service.initiate_account_merge("[email protected]", headers={'ion-actor-id':id})
# Done testing. Delete user
self.identity_management_service.delete_user_info(user_info_id)
self.identity_management_service.unregister_user_credentials(id, subject)
self.identity_management_service.delete_actor_identity(id)
def test_auth_tokens(self):
# Note: test of service gateway token functionality is in SGS test
rr = self.resource_registry
actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})
actor_id = self.identity_management_service.create_actor_identity(actor_identity_obj)
user_info_obj = IonObject("UserInfo", {"name": "Foo"})
user_info_id = self.identity_management_service.create_user_info(actor_id, user_info_obj)
token_str = self.identity_management_service.create_authentication_token(actor_id, validity=10000)
self.assertIsInstance(token_str, str)
self.assertGreaterEqual(len(token_str), 25)
token_info = self.identity_management_service.check_authentication_token(token_str)
self.assertEquals(token_info["actor_id"], actor_id)
token_info = self.identity_management_service.check_authentication_token(token_str)
self.assertGreaterEqual(int(token_info["expiry"]), get_ion_ts_millis())
with self.assertRaises(BadRequest):
self.identity_management_service.create_authentication_token(actor_id="", validity=10000)
with self.assertRaises(BadRequest):
self.identity_management_service.create_authentication_token(user_info_id, validity=10000)
with self.assertRaises(BadRequest):
self.identity_management_service.create_authentication_token(actor_id, validity="FOO")
with self.assertRaises(BadRequest):
self.identity_management_service.create_authentication_token(actor_id, validity=-200)
cur_time = get_ion_ts_millis()
with self.assertRaises(BadRequest):
self.identity_management_service.create_authentication_token(actor_id, start_time=str(cur_time-100000), validity=50)
with self.assertRaises(BadRequest):
self.identity_management_service.create_authentication_token(actor_id, validity=35000000)
with self.assertRaises(NotFound):
self.identity_management_service.check_authentication_token("UNKNOWN")
token_str2 = self.identity_management_service.create_authentication_token(actor_id, validity=1)
token_info = self.identity_management_service.check_authentication_token(token_str2)
gevent.sleep(1.1)
with self.assertRaises(Unauthorized):
self.identity_management_service.check_authentication_token(token_str2)
token = self.identity_management_service.read_authentication_token(token_str2)
token.expires = str(cur_time + 5000)
self.identity_management_service.update_authentication_token(token)
token_info = self.identity_management_service.check_authentication_token(token_str2)
token_str3 = self.identity_management_service.create_authentication_token(actor_id, validity=2)
token_info = self.identity_management_service.check_authentication_token(token_str3)
self.identity_management_service.invalidate_authentication_token(token_str3)
with self.assertRaises(Unauthorized):
self.identity_management_service.check_authentication_token(token_str3)
token = self.identity_management_service.read_authentication_token(token_str3)
self.assertEquals(token.token_string, token_str3)
self.assertIn(token_str3, token._id)
token.status = "OPEN"
self.identity_management_service.update_authentication_token(token)
token_info = self.identity_management_service.check_authentication_token(token_str3)
# Cleanup
self.identity_management_service.delete_user_info(user_info_id)
self.identity_management_service.delete_actor_identity(actor_id)