diff options
author | Marco Huenseler <marcoh.huenseler+git@gmail.com> | 2017-12-03 20:24:43 +0100 |
---|---|---|
committer | Marco Huenseler <marcoh.huenseler+git@gmail.com> | 2017-12-03 20:24:43 +0100 |
commit | 3867236b2cb020756b5c8c19a8542cca658a2f49 (patch) | |
tree | 086bb046615734a1d888c76898e00d659a347e30 | |
parent | add simple integration test (diff) | |
download | radicale_auth_ldap-3867236b2cb020756b5c8c19a8542cca658a2f49.tar.gz radicale_auth_ldap-3867236b2cb020756b5c8c19a8542cca658a2f49.tar.bz2 radicale_auth_ldap-3867236b2cb020756b5c8c19a8542cca658a2f49.zip |
update tests to unittest library
-rw-r--r-- | test/configuration.py | 16 | ||||
-rw-r--r-- | test/integration_tests.py | 26 | ||||
-rw-r--r-- | test/test_configuration_working.py | 17 |
3 files changed, 42 insertions, 17 deletions
diff --git a/test/configuration.py b/test/configuration.py new file mode 100644 index 0000000..31a40ba --- /dev/null +++ b/test/configuration.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +TEST_CONFIGURATION = { + 'auth': { + 'ldap_url': 'ldap://', + 'ldap_base': 'ou=xxx,dc=xxx,dc=xx', + 'ldap_attribute': 'uid', + 'ldap_filter': '(objectClass=person)', + 'ldap_binddn': 'cn=xxx,dc=xxx,dc=xx', + 'ldap_password': '', + 'ldap_scope': 'LEVEL' + } +} + +VALID_USER = 'xxx' +VALID_PASS = 'xxx' diff --git a/test/integration_tests.py b/test/integration_tests.py new file mode 100644 index 0000000..f6f8820 --- /dev/null +++ b/test/integration_tests.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import logging +import unittest + +import radicale_auth_ldap +from test.configuration import TEST_CONFIGURATION, VALID_USER, VALID_PASS +from test.util import ConfigMock + + +class Authentication(unittest.TestCase): + configuration = None + logger = None + + @classmethod + def setUpClass(cls): + cls.configuration = ConfigMock(TEST_CONFIGURATION) + cls.logger = logging.getLogger(__name__) + + def test_authentication_works(self): + auth = radicale_auth_ldap.Auth(self.__class__.configuration, self.__class__.logger) + self.assertTrue(auth.is_authenticated(VALID_USER, VALID_PASS)) + + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_configuration_working.py b/test/test_configuration_working.py deleted file mode 100644 index 9bbe2c7..0000000 --- a/test/test_configuration_working.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- - -import logging - -import radicale_auth_ldap -from test.configuration import TEST_CONFIGURATION, VALID_USER, VALID_PASS -from test.util import ConfigMock - - -def main(): - configuration = ConfigMock(TEST_CONFIGURATION) - logger = logging.getLogger(__name__) - auth = radicale_auth_ldap.Auth(configuration, logger) - assert auth.is_authenticated(VALID_USER, VALID_PASS) - -if __name__ == '__main__': - main() |