From 4e95dd6578d6288c5f31a62c347916b5dfc43c96 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Wed, 6 Jan 2021 11:17:41 -0500 Subject: [PATCH] Simple test of the Python part of searching LDAP for users --- tests/test_sanity.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_sanity.py b/tests/test_sanity.py index c5e51f5..090c370 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -1,4 +1,5 @@ import os +import json from werkzeug.datastructures import MultiDict @@ -9,6 +10,7 @@ import random import string from pb import app, db, session from pb.forms import StudyForm, StudySponsorForm +from pb.ldap.ldap_service import LdapService from pb.models import Study, RequiredDocument, Sponsor, StudySponsor from example_data import ExampleDataLoader @@ -130,3 +132,13 @@ class Sanity_Check_Test(unittest.TestCase): self.assertGreater(len(study_sponsors_after), 0) self.assertEqual(len(study_sponsors_after), num_sponsors) + def test_ldap_search(self): + needle = 'funk' + result = LdapService.users_as_json(needle) + users = json.loads(result) + print(f'len of users: {len(users)}') + # self.assertEqual(2, len(users)) + uids = [] + for user in users: + uids.append(user['uid']) + self.assertIn('dhf8r', uids)