Add LDAP tests

This commit is contained in:
crudo 2017-12-23 17:10:15 +01:00
parent 774a12f523
commit cdc55411b5
3 changed files with 29 additions and 2 deletions

17
test/conftest.py Normal file
View 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()

View File

@ -1,2 +0,0 @@
def test_dummy():
assert True

12
test/test_ldap.py Normal file
View 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'