|
2 | 2 |
|
3 | 3 | from copy import deepcopy
|
4 | 4 |
|
| 5 | +from ldap3 import AUTO_BIND_NO_TLS, MOCK_SYNC |
| 6 | + |
5 | 7 | from satosa.internal import AuthenticationInformation
|
6 | 8 | from satosa.internal import InternalData
|
7 | 9 | from satosa.micro_services.ldap_attribute_store import LdapAttributeStore
|
@@ -107,3 +109,60 @@ def test_attributes_general(self, ldap_attribute_store):
|
107 | 109 | internal_attr = ldap_to_internal_map[ldap_attr]
|
108 | 110 | response_attr = response.attributes[internal_attr]
|
109 | 111 | 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