Add LDAP tests
This commit is contained in:
parent
774a12f523
commit
cdc55411b5
17
test/conftest.py
Normal file
17
test/conftest.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import pytest
|
||||
import phi.ldap.client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ldap_client():
|
||||
client = phi.ldap.client.Client(
|
||||
host='localhost', port=389,
|
||||
encryption='TLSv1.2', ciphers='HIGH',
|
||||
validate=False,
|
||||
username='uid=phi,ou=Services,dc=unit,dc=macaomilano,dc=org',
|
||||
password='phi',
|
||||
base_dn='dc=unit,dc=macaomilano,dc=org',
|
||||
attribute_id='uid', attribute_mail='mail')
|
||||
client.open()
|
||||
yield client
|
||||
client.close()
|
|
@ -1,2 +0,0 @@
|
|||
def test_dummy():
|
||||
assert True
|
12
test/test_ldap.py
Normal file
12
test/test_ldap.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from phi.ldap.user import get_user_by_uid
|
||||
|
||||
|
||||
def test_connection(ldap_client):
|
||||
assert ldap_client.connection.closed is False
|
||||
assert ldap_client.connection.bound is True
|
||||
|
||||
|
||||
def test_get_user_by_id(ldap_client):
|
||||
entry = get_user_by_uid(ldap_client, 'conte_mascetti')
|
||||
assert entry['uid'] == 'conte_mascetti'
|
||||
assert entry['mail'] == 'rmascetti@autistici.org'
|
Loading…
Reference in New Issue
Block a user