test that you can't be someone not in ldap

This commit is contained in:
alicia pritchett 2021-11-09 11:08:55 -05:00
parent 024a63b725
commit cd889c5b67
1 changed files with 14 additions and 1 deletions

View File

@ -7,7 +7,7 @@ class TestLdapApi(BaseTest):
def test_get_ldap(self):
"""
Test to make sure that LDAP api point returns a 200 code
Test to make sure that LDAP api returns a real user
"""
self.load_example_data()
rv = self.app.get('/v1.0/ldap?query=dhf',
@ -21,5 +21,18 @@ class TestLdapApi(BaseTest):
self.assertEqual(data[0]['given_name'], 'Dan')
self.assertEqual(data[0]['affiliation'], 'faculty')
def test_not_in_ldap(self):
"""
Test to make sure the LDAP api doesn't return a nonexistent user
"""
self.load_example_data()
rv = self.app.get('/v1.0/ldap?query=atp',
follow_redirects=True,
content_type="application/json", headers=self.logged_in_headers())
# Should still successfully perform lookup
self.assertTrue(rv.status_code == 200)
data = json.loads(rv.data)
# Should not return any users
self.assertEqual(len(data), 0)