Permalink
Browse files

New test.

see #870
  • Loading branch information...
tonioo committed May 3, 2016
1 parent f8f6002 commit e20b17e962b96611474b2a66fdd7aafaf4879266
Showing with 45 additions and 4 deletions.
  1. +22 −0 codecov.yml
  2. +22 −3 modoboa/core/tests.py
  3. +1 −1 test_data/base.ldif
View
@@ -0,0 +1,22 @@
comment:
layout: header, changes, diff
coverage:
ignore:
- modoboa/core/migrations/*
- modoboa/core/tests.py
- modoboa/core/dev_settings.py
- modoboa/lib/migrations/*
- modoboa/lib/tests.py
- modoboa/admin/migrations/*
- modoboa/admin/tests/*
- modoboa/limits/migrations/*
- modoboa/limits/tests.py
- modoboa/relaydomains/migrations/*
- modoboa/relaydomains/tests.py
status:
patch:
default:
target: '70'
project:
default:
target: auto
View
@@ -55,15 +55,34 @@ def setUpTestData(cls):
"AUTHENTICATION_TYPE", "ldap")
parameters.save_admin("LDAP_SERVER_PORT", "3389")
def check_created_user(self, username, group="SimpleUsers", with_mb=True):
"""Check that created user is valid."""
user = models.User.objects.get(username=username)
self.assertEqual(user.email, username)
self.assertEqual(user.group, group)
if with_mb:
self.assertEqual(user.mailbox.domain.name, "example.com")
self.assertEqual(user.mailbox.full_address, username)
def test_searchbind_authentication(self):
"""Test the bind&search method."""
self.client.logout()
parameters.save_admin("LDAP_BIND_DN", "cn=admin,dc=example,dc=com")
parameters.save_admin("LDAP_BIND_PASSWORD", "test")
parameters.save_admin("LDAP_SEARCH_BASE", "dc=example,dc=com")
self.assertTrue(
self.client.login(username="testuser@example.com", password="test")
)
username = "testuser@example.com"
self.assertTrue(self.client.login(username=username, password="test"))
self.check_created_user(username)
def test_directbind_authentication(self):
"""Test the directbind method."""
self.client.logout()
parameters.save_admin("LDAP_AUTH_METHOD", "directbind")
parameters.save_admin(
"LDAP_USER_DN_TEMPLATE", "%(user)s,dc=example,dc=com")
username = "testuser@example.com"
self.assertTrue(self.client.login(username=username, password="test"))
self.check_created_user(username)
class ProfileTestCase(ModoTestCase):
View
@@ -3,7 +3,7 @@ objectClass: dcObject
objectClass: organizationalUnit
ou: users
dn: cn=testuser,dc=example,dc=com
dn: mail=testuser@example.com,dc=example,dc=com
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person

0 comments on commit e20b17e

Please sign in to comment.