Merge pull request #344 from sartography/ldap-issues-394
Ldap issues #394
This commit is contained in:
commit
52ce171a8a
|
@ -51,7 +51,16 @@ supervisor_info = ldap(supervisor_uid) // Sets the supervisor information to l
|
||||||
uid = UserService.current_user().uid
|
uid = UserService.current_user().uid
|
||||||
else:
|
else:
|
||||||
uid = args[0]
|
uid = args[0]
|
||||||
|
|
||||||
|
try:
|
||||||
user_info = LdapService.user_info(uid)
|
user_info = LdapService.user_info(uid)
|
||||||
|
except ApiError as ae:
|
||||||
|
app.logger.info(ae)
|
||||||
|
return {}
|
||||||
|
except Exception as e:
|
||||||
|
app.logger.info(e)
|
||||||
|
return {}
|
||||||
|
else:
|
||||||
user_info_dict = {
|
user_info_dict = {
|
||||||
"display_name": user_info.display_name,
|
"display_name": user_info.display_name,
|
||||||
"given_name": user_info.given_name,
|
"given_name": user_info.given_name,
|
||||||
|
@ -64,5 +73,4 @@ supervisor_info = ldap(supervisor_uid) // Sets the supervisor information to l
|
||||||
"uid": user_info.uid,
|
"uid": user_info.uid,
|
||||||
"proper_name": user_info.proper_name()
|
"proper_name": user_info.proper_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
return user_info_dict
|
return user_info_dict
|
||||||
|
|
|
@ -58,6 +58,7 @@ class LdapService(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def user_info(uva_uid):
|
def user_info(uva_uid):
|
||||||
|
uva_uid = uva_uid.lower()
|
||||||
user_info = db.session.query(LdapModel).filter(LdapModel.uid == uva_uid).first()
|
user_info = db.session.query(LdapModel).filter(LdapModel.uid == uva_uid).first()
|
||||||
if not user_info:
|
if not user_info:
|
||||||
app.logger.info("No cache for " + uva_uid)
|
app.logger.info("No cache for " + uva_uid)
|
||||||
|
|
|
@ -45,8 +45,8 @@ class TestLdapLookupScript(BaseTest):
|
||||||
}
|
}
|
||||||
|
|
||||||
script = Ldap()
|
script = Ldap()
|
||||||
with(self.assertRaises(ApiError)):
|
|
||||||
user_details = script.do_task(task, workflow.study_id, workflow.id, "PIComputingID")
|
user_details = script.do_task(task, workflow.study_id, workflow.id, "PIComputingID")
|
||||||
|
self.assertEqual({}, user_details)
|
||||||
|
|
||||||
def test_get_current_user_details(self):
|
def test_get_current_user_details(self):
|
||||||
self.load_example_data()
|
self.load_example_data()
|
||||||
|
|
|
@ -31,3 +31,8 @@ class TestLdapService(BaseTest):
|
||||||
self.assertFalse(True, "An API error should be raised.")
|
self.assertFalse(True, "An API error should be raised.")
|
||||||
except ApiError as ae:
|
except ApiError as ae:
|
||||||
self.assertEqual("missing_ldap_record", ae.code)
|
self.assertEqual("missing_ldap_record", ae.code)
|
||||||
|
|
||||||
|
def test_get_user_with_caps(self):
|
||||||
|
user_info = LdapService.user_info("LB3DP")
|
||||||
|
self.assertIsNotNone(user_info)
|
||||||
|
self.assertEqual("lb3dp", user_info.uid)
|
||||||
|
|
Loading…
Reference in New Issue