mirror of
https://github.com/jdupouy/radicale3-auth-ldap.git
synced 2024-10-27 19:14:00 +00:00
update tests to unittest library
This commit is contained in:
parent
063f3a42d2
commit
3867236b2c
16
test/configuration.py
Normal file
16
test/configuration.py
Normal file
@ -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'
|
26
test/integration_tests.py
Normal file
26
test/integration_tests.py
Normal file
@ -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()
|
@ -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()
|
Loading…
Reference in New Issue
Block a user