Add more ldap auth tests for ZD-2993

This commit is contained in:
Daniel A. Wozniak 2018-12-05 12:55:26 -07:00
parent 055a8d5d74
commit 91f50a4ce7
No known key found for this signature in database
GPG key ID: 166B9D2C06C82D61

View file

@ -90,6 +90,22 @@ class LDAPAuthTestCase(TestCase):
self.assertIn('saltusers', salt.auth.ldap.groups('saltuser', password='password'))
def test_auth_nopass(self):
with patch.dict(salt.auth.ldap.__opts__, self.opts):
opts = self.opts.copy()
opts['auth.ldap.bindpw'] = 'p@ssw0rd!'
with patch.dict(salt.auth.ldap.__opts__, opts):
with patch('salt.auth.ldap._bind_for_search', return_value=Bind):
assert salt.auth.ldap.auth('foo', None) == False
def test_auth_nouser(self):
opts = self.opts.copy()
opts['auth.ldap.bindpw'] = 'p@ssw0rd!'
with patch.dict(salt.auth.ldap.__opts__, opts):
with patch('salt.auth.ldap._bind_for_search', return_value=Bind):
assert salt.auth.ldap.auth(None, 'foo') == False
def test_auth_nouserandpass(self):
opts = self.opts.copy()
opts['auth.ldap.bindpw'] = 'p@ssw0rd!'
with patch.dict(salt.auth.ldap.__opts__, opts):
with patch('salt.auth.ldap._bind_for_search', return_value=Bind):
assert salt.auth.ldap.auth(None, None) == False