def withLdapConfig(self, config: LdapConfig): """ Validates the config before continuing """ validateLdapConfig(config) self.endpoint = buildLdapEndpoint(config) self.tlsEnabled = config.isTLSEnabled() self.client_cert = config.getClientCert() self.client_key = config.getClientKey() self.ca_cert = config.getCACert() return self
def test_tls_false_should_use_ldap(self): os.environ[ldapEnableTLSKey] = str(False) endpoint = buildLdapEndpoint(LdapConfig()) self.assertEqual(ldapEndpoint, endpoint)
def test_tls_true_should_use_ldaps(self): endpoint = buildLdapEndpoint(LdapConfig()) self.assertEqual(ldapsEndpoint, endpoint)
def test_default_parameters(self): endpoint = buildLdapEndpoint() self.assertEqual("ldap://localhost:389", endpoint)
def test_returns_ldaps_when_isTLSEnabled(self): self.ldap_config.isTLSEnabled.return_value = True endpoint = buildLdapEndpoint(self.ldap_config) self.assertEqual(ldapsEndpoint, endpoint)
def test_returns_ldap_when_not_isTLSEnabled(self): endpoint = buildLdapEndpoint(self.ldap_config) self.assertEqual(ldapEndpoint, endpoint)
def test_each_config_is_called_once(self): buildLdapEndpoint(self.ldap_config) self.ldap_config.getHostname.assert_called_once() self.ldap_config.getPort.assert_called_once() self.ldap_config.isTLSEnabled.assert_called_once()