Skip to content

Commit

Permalink
Add tests für ldap connection configuration
Browse files Browse the repository at this point in the history
This patch adds tests to check the configuration of the ldap connection.

Signed-off-by: Sven Haardiek <[email protected]>
  • Loading branch information
shaardie committed Jun 16, 2023
1 parent ee913b2 commit 97cbdf8
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/satosa/micro_services/test_ldap_attribute_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from copy import deepcopy

from ldap3 import AUTO_BIND_NO_TLS, MOCK_SYNC

from satosa.internal import AuthenticationInformation
from satosa.internal import InternalData
from satosa.micro_services.ldap_attribute_store import LdapAttributeStore
Expand Down Expand Up @@ -107,3 +109,60 @@ def test_attributes_general(self, ldap_attribute_store):
internal_attr = ldap_to_internal_map[ldap_attr]
response_attr = response.attributes[internal_attr]
assert(ldap_value in response_attr)

@pytest.mark.parametrize(
'config,connection_attributes',
[
(
{
'auto_bind': 'AUTO_BIND_NO_TLS',
'client_strategy': 'MOCK_SYNC',
'ldap_url': 'ldap://satosa.example.com',
'bind_dn': 'uid=readonly_user,ou=system,dc=example,dc=com',
'bind_password': 'password',
},
{
'user': 'uid=readonly_user,ou=system,dc=example,dc=com',
'password': 'password',
'auto_bind': AUTO_BIND_NO_TLS,
'strategy_type': MOCK_SYNC,
'read_only': True,
'version': 3,
'pool_size': 10,
'pool_keepalive': 10,
'pool_lifetime': None,
},
),
(
{
'auto_bind': 'AUTO_BIND_NO_TLS',
'client_strategy': 'MOCK_SYNC',
'ldap_url': 'ldap://satosa.example.com',
'bind_dn': 'uid=readonly_user,ou=system,dc=example,dc=com',
'bind_password': 'password',
'pool_size': 40,
'pool_keepalive': 41,
'pool_lifetime': 42,
},
{
'user': 'uid=readonly_user,ou=system,dc=example,dc=com',
'password': 'password',
'auto_bind': AUTO_BIND_NO_TLS,
'strategy_type': MOCK_SYNC,
'read_only': True,
'version': 3,
'pool_size': 40,
'pool_keepalive': 41,
'pool_lifetime': 42,
},
),
]
)
def test_connection_config(self, config, connection_attributes):
ldapAttributeStore = LdapAttributeStore({'default': config},
name="test_ldap_attribute_store",
base_url="https://satosa.example.com")
connection = ldapAttributeStore.config['default']['connection']

for k, v in connection_attributes.items():
assert getattr(connection, k) == v

0 comments on commit 97cbdf8

Please sign in to comment.