Skip to content

Commit 97cbdf8

Browse files
committed
Add tests für ldap connection configuration
This patch adds tests to check the configuration of the ldap connection. Signed-off-by: Sven Haardiek <[email protected]>
1 parent ee913b2 commit 97cbdf8

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/satosa/micro_services/test_ldap_attribute_store.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from copy import deepcopy
44

5+
from ldap3 import AUTO_BIND_NO_TLS, MOCK_SYNC
6+
57
from satosa.internal import AuthenticationInformation
68
from satosa.internal import InternalData
79
from satosa.micro_services.ldap_attribute_store import LdapAttributeStore
@@ -107,3 +109,60 @@ def test_attributes_general(self, ldap_attribute_store):
107109
internal_attr = ldap_to_internal_map[ldap_attr]
108110
response_attr = response.attributes[internal_attr]
109111
assert(ldap_value in response_attr)
112+
113+
@pytest.mark.parametrize(
114+
'config,connection_attributes',
115+
[
116+
(
117+
{
118+
'auto_bind': 'AUTO_BIND_NO_TLS',
119+
'client_strategy': 'MOCK_SYNC',
120+
'ldap_url': 'ldap://satosa.example.com',
121+
'bind_dn': 'uid=readonly_user,ou=system,dc=example,dc=com',
122+
'bind_password': 'password',
123+
},
124+
{
125+
'user': 'uid=readonly_user,ou=system,dc=example,dc=com',
126+
'password': 'password',
127+
'auto_bind': AUTO_BIND_NO_TLS,
128+
'strategy_type': MOCK_SYNC,
129+
'read_only': True,
130+
'version': 3,
131+
'pool_size': 10,
132+
'pool_keepalive': 10,
133+
'pool_lifetime': None,
134+
},
135+
),
136+
(
137+
{
138+
'auto_bind': 'AUTO_BIND_NO_TLS',
139+
'client_strategy': 'MOCK_SYNC',
140+
'ldap_url': 'ldap://satosa.example.com',
141+
'bind_dn': 'uid=readonly_user,ou=system,dc=example,dc=com',
142+
'bind_password': 'password',
143+
'pool_size': 40,
144+
'pool_keepalive': 41,
145+
'pool_lifetime': 42,
146+
},
147+
{
148+
'user': 'uid=readonly_user,ou=system,dc=example,dc=com',
149+
'password': 'password',
150+
'auto_bind': AUTO_BIND_NO_TLS,
151+
'strategy_type': MOCK_SYNC,
152+
'read_only': True,
153+
'version': 3,
154+
'pool_size': 40,
155+
'pool_keepalive': 41,
156+
'pool_lifetime': 42,
157+
},
158+
),
159+
]
160+
)
161+
def test_connection_config(self, config, connection_attributes):
162+
ldapAttributeStore = LdapAttributeStore({'default': config},
163+
name="test_ldap_attribute_store",
164+
base_url="https://satosa.example.com")
165+
connection = ldapAttributeStore.config['default']['connection']
166+
167+
for k, v in connection_attributes.items():
168+
assert getattr(connection, k) == v

0 commit comments

Comments
 (0)