aboutsummaryrefslogtreecommitdiff
path: root/okupy
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2013-08-24 22:27:10 +0200
committerTheo Chatzimichos <tampakrap@gentoo.org>2013-08-24 22:27:10 +0200
commit4a471626bd7306b26d49591b71b834e6d96e7ab5 (patch)
tree2247267c4a893b48eaf908b70a948ecbd07da353 /okupy
parentMerge pull request #78 from tampakrap/settings (diff)
downloadidentity.gentoo.org-4a471626bd7306b26d49591b71b834e6d96e7ab5.tar.gz
identity.gentoo.org-4a471626bd7306b26d49591b71b834e6d96e7ab5.tar.bz2
identity.gentoo.org-4a471626bd7306b26d49591b71b834e6d96e7ab5.zip
Remove search_s.seed, as it is now covered by mockldap
Diffstat (limited to 'okupy')
-rw-r--r--okupy/tests/integration/test_index.py1
-rw-r--r--okupy/tests/integration/test_lists.py3
-rw-r--r--okupy/tests/integration/test_login.py5
-rw-r--r--okupy/tests/integration/test_signup.py11
-rw-r--r--okupy/tests/unit/test_auth.py7
-rw-r--r--okupy/tests/unit/test_index.py4
-rw-r--r--okupy/tests/unit/test_lists.py10
-rw-r--r--okupy/tests/unit/test_login.py6
-rw-r--r--okupy/tests/unit/test_secondary_password.py9
-rw-r--r--okupy/tests/unit/test_signup.py25
-rw-r--r--okupy/tests/vars.py4
11 files changed, 12 insertions, 73 deletions
diff --git a/okupy/tests/integration/test_index.py b/okupy/tests/integration/test_index.py
index af6cb3a..8650860 100644
--- a/okupy/tests/integration/test_index.py
+++ b/okupy/tests/integration/test_index.py
@@ -26,7 +26,6 @@ class IndexIntegrationTests(OkupyTestCase):
self.assertRedirects(response, '/login/?next=/')
def test_index_page_uses_correct_template(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
response = self.client.post('/login/', {'username': 'alice', 'password': 'ldaptest'})
response = self.client.get('/')
self.assertTemplateUsed(response, 'base.html')
diff --git a/okupy/tests/integration/test_lists.py b/okupy/tests/integration/test_lists.py
index 1c854c2..f75bd78 100644
--- a/okupy/tests/integration/test_lists.py
+++ b/okupy/tests/integration/test_lists.py
@@ -24,19 +24,16 @@ class ListsIntegrationTests(TestCase):
self.mockldap.stop()
def test_devlist_page_uses_correct_template(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='developer.group'))([ldap_users('alice'), ldap_users('jack')])
response = self.client.get('/devlist/')
self.assertTemplateUsed(response, 'base.html')
self.assertTemplateUsed(response, 'devlist.html')
def test_former_devlist_page_uses_correct_template(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='retired.group'))([ldap_users('john'), ldap_users('matt')])
response = self.client.get('/former-devlist/')
self.assertTemplateUsed(response, 'base.html')
self.assertTemplateUsed(response, 'former-devlist.html')
def test_foundation_members_page_uses_correct_template(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='foundation.group'))([ldap_users('bob'), ldap_users('jack')])
response = self.client.get('/foundation-members/')
self.assertTemplateUsed(response, 'base.html')
self.assertTemplateUsed(response, 'foundation-members.html')
diff --git a/okupy/tests/integration/test_login.py b/okupy/tests/integration/test_login.py
index ef399ad..9ab30df 100644
--- a/okupy/tests/integration/test_login.py
+++ b/okupy/tests/integration/test_login.py
@@ -29,20 +29,17 @@ class LoginIntegrationTests(TestCase):
self.assertTemplateUsed(response, 'login.html')
def test_correct_user_post_login_redirect(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
account = vars.LOGIN_ALICE.copy()
account['next'] = ''
response = self.client.post('/login/', account)
self.assertRedirects(response, '/', 302, 200)
def test_already_authenticated_user_redirects_to_index(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
self.client.post('/login/', vars.LOGIN_ALICE)
response = self.client.get('/login/')
self.assertRedirects(response, '/')
def test_logout_for_logged_in_user_redirects_to_login(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
self.client.post('/login/', vars.LOGIN_ALICE)
response = self.client.get('/logout/')
self.assertRedirects(response, '/login/')
@@ -52,7 +49,6 @@ class LoginIntegrationTests(TestCase):
self.assertRedirects(response, '/login/')
def test_logout_no_ldap_doesnt_raise_exception(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
self.client.post('/login/', vars.LOGIN_ALICE)
self.mockldap.stop()
response = self.client.get('/logout/')
@@ -60,6 +56,5 @@ class LoginIntegrationTests(TestCase):
self.mockldap.start()
def test_redirect_to_requested_page_after_login(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
response = self.client.post('/login/?next=/otp-setup/', vars.LOGIN_ALICE)
self.assertRedirects(response, '/otp-setup/', 302, 200)
diff --git a/okupy/tests/integration/test_signup.py b/okupy/tests/integration/test_signup.py
index acd894e..b6e641d 100644
--- a/okupy/tests/integration/test_signup.py
+++ b/okupy/tests/integration/test_signup.py
@@ -6,8 +6,6 @@ from django.test.client import Client
from mockldap import MockLdap
from .. import vars
-from ...accounts.models import LDAPUser
-from ...common.test_helpers import set_search_seed, ldap_users
class SignupIntegrationTests(TestCase):
@@ -33,23 +31,18 @@ class SignupIntegrationTests(TestCase):
self.assertRedirects(response, '/login/', 302, 200)
def test_valid_data_to_signup_redirects_to_login(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', attr='mail'))(LDAPUser.DoesNotExist)
response = self.client.post('/signup/', vars.SIGNUP_TESTUSER)
self.assertRedirects(response, '/login/', 302, 200)
def test_logged_in_user_signup_url_redirects_to_index(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
- self.client.post('/login/', {'username': 'alice', 'password': 'ldaptest'})
+ self.client.post('/login/', vars.LOGIN_ALICE)
response = self.client.get('/signup/')
self.assertRedirects(response, '/', 302, 200)
def test_logged_in_user_activate_url_redirects_to_index(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed())(ldap_users(all=True))
vars.QUEUEDUSER.save()
activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
- self.client.post('/login/', {'username': 'alice', 'password': 'ldaptest'})
+ self.client.post('/login/', vars.LOGIN_ALICE)
response = self.client.get(activate_url)
self.assertRedirects(response, '/', 302, 200)
diff --git a/okupy/tests/unit/test_auth.py b/okupy/tests/unit/test_auth.py
index 5793d53..27e6618 100644
--- a/okupy/tests/unit/test_auth.py
+++ b/okupy/tests/unit/test_auth.py
@@ -6,7 +6,7 @@ from django.conf import settings
from django.contrib.auth import authenticate
from .. import vars
-from ...common.test_helpers import OkupyTestCase, set_request, ldap_users, set_search_seed
+from ...common.test_helpers import OkupyTestCase, set_request
class AuthUnitTests(OkupyTestCase):
@@ -26,7 +26,6 @@ class AuthUnitTests(OkupyTestCase):
request.META['SSL_CLIENT_VERIFY'] = 'SUCCESS'
request.META['SSL_CLIENT_RAW_CERT'] = vars.TEST_CERTIFICATE
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice@test.com', 'mail'))([ldap_users('alice')])
u = authenticate(request=request)
self.assertEqual(u.username, vars.LOGIN_ALICE['username'])
@@ -36,8 +35,6 @@ class AuthUnitTests(OkupyTestCase):
request.META['SSL_CLIENT_RAW_CERT'] = (
vars.TEST_CERTIFICATE_WITH_TWO_EMAIL_ADDRESSES)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', 'mail'))([])
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice@test.com', 'mail'))([ldap_users('alice')])
u = authenticate(request=request)
self.assertEqual(u.username, vars.LOGIN_ALICE['username'])
@@ -53,7 +50,6 @@ class AuthUnitTests(OkupyTestCase):
request.META['SSL_CLIENT_VERIFY'] = 'FAILURE'
request.META['SSL_CLIENT_RAW_CERT'] = vars.TEST_CERTIFICATE
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice@test.com', 'mail'))([ldap_users('alice')])
u = authenticate(request=request)
self.assertIs(u, None)
@@ -62,6 +58,5 @@ class AuthUnitTests(OkupyTestCase):
request.META['SSL_CLIENT_VERIFY'] = 'SUCCESS'
request.META['SSL_CLIENT_RAW_CERT'] = vars.TEST_CERTIFICATE_WRONG_EMAIL
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('wrong@test.com', 'mail'))([])
u = authenticate(request=request)
self.assertIs(u, None)
diff --git a/okupy/tests/unit/test_index.py b/okupy/tests/unit/test_index.py
index 7e4a8eb..eb6861e 100644
--- a/okupy/tests/unit/test_index.py
+++ b/okupy/tests/unit/test_index.py
@@ -8,7 +8,7 @@ from mockldap import MockLdap
from .. import vars
from ...accounts.views import index
-from ...common.test_helpers import set_request, ldap_users, set_search_seed
+from ...common.test_helpers import set_request
class IndexUnitTests(TestCase):
@@ -28,13 +28,11 @@ class IndexUnitTests(TestCase):
self.assertEqual(found.func, index)
def test_index_page_returns_200_for_logged_in(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
request = set_request(uri='/', user=vars.USER_ALICE)
response = index(request)
self.assertEqual(response.status_code, 200)
def test_rendered_index_page(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
request = set_request(uri='/', user=vars.USER_ALICE)
response = index(request)
nickname_html = '<tr class="even"><th>Nickname</th><td>alice</td></tr>'
diff --git a/okupy/tests/unit/test_lists.py b/okupy/tests/unit/test_lists.py
index 55a302b..04803f9 100644
--- a/okupy/tests/unit/test_lists.py
+++ b/okupy/tests/unit/test_lists.py
@@ -7,7 +7,7 @@ from mockldap import MockLdap
from .. import vars
from ...accounts.views import lists
-from ...common.test_helpers import OkupyTestCase, set_request, set_search_seed, ldap_users
+from ...common.test_helpers import OkupyTestCase, set_request
class ListsUnitTests(OkupyTestCase):
@@ -27,13 +27,11 @@ class ListsUnitTests(OkupyTestCase):
self.assertEqual(found.func, lists)
def test_devlist_page_returns_200(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='developer.group'))([ldap_users('alice'), ldap_users('jack')])
request = set_request(uri='/devlist')
response = lists(request, 'devlist')
self.assertEqual(response.status_code, 200)
def test_rendered_devlist_page(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='developer.group'))([ldap_users('alice'), ldap_users('jack')])
request = set_request(uri='/devlist')
response = lists(request, 'devlist')
page_part = '<tr>\n <td class="devname"><b>alice</b></td>\n <td>Alice Adams</td>\n <td><a href="http://maps.google.com/maps?q=City1, Country1">City1, Country1</a></td>\n <td class="tableinfo">kde, qt, cluster</td>\n </tr>'
@@ -44,16 +42,14 @@ class ListsUnitTests(OkupyTestCase):
self.assertEqual(found.func, lists)
def test_former_devlist_page_returns_200(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='retired.group'))([ldap_users('john'), ldap_users('matt')])
request = set_request(uri='/former-devlist')
response = lists(request, 'former-devlist')
self.assertEqual(response.status_code, 200)
def test_rendered_former_devlist_page(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='retired.group'))([ldap_users('john'), ldap_users('matt')])
request = set_request(uri='/former-devlist')
response = lists(request, 'former-devlist')
- page_part = '<tr>\n <td class="devname"><b>john</b></td>\n <td>John Smith</td>\n <td><a href="http://maps.google.com/maps?q=City3, Country3">City3, Country3</a></td>\n <td class="tableinfo">kernel, security</td>\n </tr>\n \n <tr>'
+ page_part = '<tr>\n <td class="devname"><b>john</b></td>\n <td>John Smith</td>\n <td><a href="http://maps.google.com/maps?q=City3, Country3">City3, Country3</a></td>\n <td class="tableinfo">kernel, security</td>\n </tr>'
self.assertIn(page_part, response.content)
def test_foundation_members_list_url_resolves_to_lists_view(self):
@@ -61,13 +57,11 @@ class ListsUnitTests(OkupyTestCase):
self.assertEqual(found.func, lists)
def test_foundation_members_page_returns_200(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='foundation.group'))([ldap_users('bob'), ldap_users('jack')])
request = set_request(uri='/foundation-members')
response = lists(request, 'foundation-members')
self.assertEqual(response.status_code, 200)
def test_rendered_foundation_members_page(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed(attr='gentooACL', value='foundation.group'))([ldap_users('bob'), ldap_users('jack')])
request = set_request(uri='/foundation-members')
response = lists(request, 'foundation-members')
page_part = '<tr>\n <td style="color:#5c4f85;"><b>bob</b></td>\n <td>Robert Barker</td>\n <td><a href="http://maps.google.com/maps?q=City2, Country2">City2, Country2</a></td>\n </tr>'
diff --git a/okupy/tests/unit/test_login.py b/okupy/tests/unit/test_login.py
index 8aaf2c1..d674150 100644
--- a/okupy/tests/unit/test_login.py
+++ b/okupy/tests/unit/test_login.py
@@ -15,7 +15,7 @@ from mockldap import MockLdap
from .. import vars
from ...accounts.views import login, logout
from ...accounts.forms import LoginForm
-from ...common.test_helpers import OkupyTestCase, set_request, no_database, ldap_users, set_search_seed
+from ...common.test_helpers import OkupyTestCase, set_request, no_database, ldap_users
from ...crypto.ciphers import cipher
@@ -64,20 +64,17 @@ class LoginUnitTests(OkupyTestCase):
self.assertTrue(mail.outbox[0].subject.startswith('%sERROR:' % settings.EMAIL_SUBJECT_PREFIX))
def test_correct_user_gets_transferred_in_db(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
request = set_request(uri='/login', post=vars.LOGIN_ALICE)
login(request)
self.assertEqual(User.objects.count(), 1)
def test_authenticate_account_that_is_already_in_db(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
vars.USER_ALICE.save()
request = set_request(uri='/login', post=vars.LOGIN_ALICE)
login(request)
self.assertEqual(User.objects.count(), 1)
def test_secondary_password_is_added_in_login(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
request = set_request(uri='/login', post=vars.LOGIN_ALICE)
login(request)
self.assertEqual(len(ldap_users('alice', directory=self.ldapobject.directory)[1]['userPassword']), 2)
@@ -87,7 +84,6 @@ class LoginUnitTests(OkupyTestCase):
secondary_password = Random.get_random_bytes(48)
secondary_password_crypt = ldap_md5_crypt.encrypt(b64encode(secondary_password))
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(secondary_password_crypt)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice', directory=self.ldapobject.directory)])
request = set_request(uri='/login', post=vars.LOGIN_ALICE, user=vars.USER_ALICE)
request.session['secondary_password'] = cipher.encrypt(secondary_password)
logout(request)
diff --git a/okupy/tests/unit/test_secondary_password.py b/okupy/tests/unit/test_secondary_password.py
index baef415..885c3cb 100644
--- a/okupy/tests/unit/test_secondary_password.py
+++ b/okupy/tests/unit/test_secondary_password.py
@@ -27,13 +27,11 @@ class SecondaryPassword(TestCase):
self.mockldap.stop()
def test_secondary_password_gets_added_in_session(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
request = set_request(uri='/', user=vars.USER_ALICE)
set_secondary_password(request, 'ldaptest')
self.assertEqual(len(request.session['secondary_password']), 48)
def test_secondary_password_gets_added_in_ldap(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
request = set_request(uri='/', user=vars.USER_ALICE)
self.assertEqual(len(ldap_users('alice')[1]['userPassword']), 1)
set_secondary_password(request, 'ldaptest')
@@ -42,7 +40,6 @@ class SecondaryPassword(TestCase):
def test_remove_leftovers_before_adding_secondary_password(self):
leftover = ldap_md5_crypt.encrypt('leftover_password')
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(leftover)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice', directory=self.ldapobject.directory)])
request = set_request(uri='/', user=vars.USER_ALICE)
set_secondary_password(request, 'ldaptest')
self.assertNotIn(leftover, ldap_users('alice', directory=self.ldapobject.directory)[1]['userPassword'])
@@ -50,7 +47,6 @@ class SecondaryPassword(TestCase):
def test_dont_remove_primary_password_while_cleaning_leftovers(self):
leftover = ldap_md5_crypt.encrypt('leftover_password')
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(leftover)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice', directory=self.ldapobject.directory)])
request = set_request(uri='/', user=vars.USER_ALICE)
set_secondary_password(request, 'ldaptest')
self.assertTrue(ldap_md5_crypt.verify('ldaptest', ldap_users('alice', directory=self.ldapobject.directory)[1]['userPassword'][0]))
@@ -60,13 +56,11 @@ class SecondaryPassword(TestCase):
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(leftover)
leftover2 = 'plain_leftover2'
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(leftover2)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice', directory=self.ldapobject.directory)])
request = set_request(uri='/', user=vars.USER_ALICE)
set_secondary_password(request, 'ldaptest')
self.assertIn(leftover2, ldap_users('alice', directory=self.ldapobject.directory)[1]['userPassword'])
def test_session_and_ldap_secondary_passwords_match(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
request = set_request(uri='/', user=vars.USER_ALICE)
set_secondary_password(request, 'ldaptest')
self.assertTrue(ldap_md5_crypt.verify(b64encode(cipher.decrypt(request.session['secondary_password'], 48)), ldap_users('alice', directory=self.ldapobject.directory)[1]['userPassword'][1]))
@@ -75,7 +69,6 @@ class SecondaryPassword(TestCase):
secondary_password = Random.get_random_bytes(48)
secondary_password_crypt = ldap_md5_crypt.encrypt(b64encode(secondary_password))
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(secondary_password_crypt)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice', directory=self.ldapobject.directory)])
request = set_request(uri='/', user=vars.USER_ALICE)
request.session['secondary_password'] = cipher.encrypt(secondary_password)
remove_secondary_password(request)
@@ -85,7 +78,6 @@ class SecondaryPassword(TestCase):
secondary_password = Random.get_random_bytes(48)
secondary_password_crypt = ldap_md5_crypt.encrypt(b64encode(secondary_password))
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(secondary_password_crypt)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice', directory=self.ldapobject.directory)])
request = set_request(uri='/', user=vars.USER_ALICE)
request.session['secondary_password'] = cipher.encrypt(secondary_password)
remove_secondary_password(request)
@@ -96,7 +88,6 @@ class SecondaryPassword(TestCase):
secondary_password_crypt = ldap_md5_crypt.encrypt(b64encode(secondary_password))
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append('unknown_hash')
self.ldapobject.directory[ldap_users('alice')[0]]['userPassword'].append(secondary_password_crypt)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice', directory=self.ldapobject.directory)])
request = set_request(uri='/', user=vars.USER_ALICE)
request.session['secondary_password'] = cipher.encrypt(secondary_password)
remove_secondary_password(request)
diff --git a/okupy/tests/unit/test_signup.py b/okupy/tests/unit/test_signup.py
index e1f4d2b..2f4485d 100644
--- a/okupy/tests/unit/test_signup.py
+++ b/okupy/tests/unit/test_signup.py
@@ -12,7 +12,7 @@ from .. import vars
from ...accounts.forms import SignupForm
from ...accounts.models import LDAPUser, Queue
from ...accounts.views import signup, activate
-from ...common.test_helpers import OkupyTestCase, set_request, set_search_seed, ldap_users, no_database
+from ...common.test_helpers import OkupyTestCase, set_request, no_database, ldap_users
class SignupUnitTests(OkupyTestCase):
@@ -28,7 +28,6 @@ class SignupUnitTests(OkupyTestCase):
self.mockldap.stop()
def test_username_already_exists_in_ldap(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice'))([ldap_users('alice')])
_form = vars.SIGNUP_TESTUSER.copy()
_form['username'] = 'alice'
request = set_request(uri='/signup', post=_form, messages=True)
@@ -37,8 +36,6 @@ class SignupUnitTests(OkupyTestCase):
self.assertMessage(response, 'Username already exists', 40)
def test_email_already_exists_in_ldap(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('alice@test.com', attr='mail'))([ldap_users('alice')])
_form = vars.SIGNUP_TESTUSER.copy()
_form['email'] = 'alice@test.com'
request = set_request(uri='/signup', post=_form, messages=True)
@@ -49,8 +46,6 @@ class SignupUnitTests(OkupyTestCase):
def test_username_already_pending_activation(self):
_form = vars.SIGNUP_TESTUSER.copy()
_form['username'] = 'queueduser'
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('queueduser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', attr='mail'))(LDAPUser.DoesNotExist)
vars.QUEUEDUSER.save()
request = set_request(uri='/signup', post=_form, messages=True)
response = signup(request)
@@ -60,8 +55,6 @@ class SignupUnitTests(OkupyTestCase):
def test_email_already_pending_activation(self):
_form = vars.SIGNUP_TESTUSER.copy()
_form['email'] = 'queued_user@test.com'
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('queued_user@test.com', attr='mail'))(LDAPUser.DoesNotExist)
vars.QUEUEDUSER.save()
request = set_request(uri='/signup', post=_form, messages=True)
response = signup(request)
@@ -69,7 +62,6 @@ class SignupUnitTests(OkupyTestCase):
self.assertMessage(response, 'Account is already pending activation', 40)
def test_add_queued_account_to_ldap_prints_success_message(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed())(ldap_users(all=True))
vars.QUEUEDUSER.save()
activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
request = set_request(uri=activate_url, messages=True)
@@ -78,7 +70,6 @@ class SignupUnitTests(OkupyTestCase):
self.assertMessage(response, 'Your account has been activated successfully', 25)
def test_queued_account_gets_added_to_ldap(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed())(ldap_users(all=True))
vars.QUEUEDUSER.save()
activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
request = set_request(activate_url, messages=True)
@@ -99,7 +90,6 @@ class SignupUnitTests(OkupyTestCase):
self.assertEqual(ldap_account['gentooACL'][0], 'user.group')
def test_add_queued_account_remove_from_queue(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed())(ldap_users(all=True))
vars.QUEUEDUSER.save()
activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
request = set_request(activate_url, messages=True)
@@ -107,16 +97,12 @@ class SignupUnitTests(OkupyTestCase):
self.assertEqual(Queue.objects.count(), 0)
def test_valid_data_to_signup_form_prints_info_message(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', attr='mail'))(LDAPUser.DoesNotExist)
request = set_request(uri='/signup', post=vars.SIGNUP_TESTUSER, messages=True)
response = signup(request)
response.context = RequestContext(request)
self.assertMessage(response, 'You will shortly receive an activation mail', 20)
def test_valid_data_to_signup_form_sends_activation_mail(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', attr='mail'))(LDAPUser.DoesNotExist)
request = set_request(uri='/signup', post=vars.SIGNUP_TESTUSER, messages=True)
response = signup(request)
response.context = RequestContext(request)
@@ -124,8 +110,6 @@ class SignupUnitTests(OkupyTestCase):
self.assertEqual(mail.outbox[0].subject, '%sAccount Activation' % settings.EMAIL_SUBJECT_PREFIX)
def test_valid_data_to_signup_form_adds_user_to_queue(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', attr='mail'))(LDAPUser.DoesNotExist)
request = set_request(uri='/signup', post=vars.SIGNUP_TESTUSER, messages=True)
response = signup(request)
response.context = RequestContext(request)
@@ -141,8 +125,6 @@ class SignupUnitTests(OkupyTestCase):
@no_database()
def test_no_database_connection_raises_error_in_signup(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', attr='mail'))(LDAPUser.DoesNotExist)
request = set_request(uri='/signup', post=vars.SIGNUP_TESTUSER, messages=True)
response = signup(request)
response.context = RequestContext(request)
@@ -150,8 +132,6 @@ class SignupUnitTests(OkupyTestCase):
@no_database()
def test_no_database_connection_sends_notification_mail_in_signup(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('testuser'))(LDAPUser.DoesNotExist)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed('test@test.com', attr='mail'))(LDAPUser.DoesNotExist)
request = set_request(uri='/signup', post=vars.SIGNUP_TESTUSER, messages=True)
response = signup(request)
response.context = RequestContext(request)
@@ -160,7 +140,6 @@ class SignupUnitTests(OkupyTestCase):
@no_database()
def test_no_database_connection_raises_error_in_activation(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed())(ldap_users(all=True))
request = set_request('/activate/test', messages=True)
response = activate(request, vars.QUEUEDUSER.encrypted_id)
response.context = RequestContext(request)
@@ -168,7 +147,6 @@ class SignupUnitTests(OkupyTestCase):
@no_database()
def test_no_database_connection_sends_notification_mail_in_activation(self):
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed())(ldap_users(all=True))
request = set_request('/activate/test', messages=True)
activate(request, vars.QUEUEDUSER.encrypted_id)
self.assertEqual(len(mail.outbox), 1)
@@ -178,7 +156,6 @@ class SignupUnitTests(OkupyTestCase):
vars.QUEUEDUSER.save()
activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
self.ldapobject.directory = ldap_users(clean=True)
- self.ldapobject.search_s.seed(settings.AUTH_LDAP_USER_BASE_DN, 2, set_search_seed())(ldap_users(all=True, directory=self.ldapobject.directory))
request = set_request(activate_url, messages=True)
activate(request, vars.QUEUEDUSER.encrypted_id)
self.assertTrue(ldap_users(vars.QUEUEDUSER.username, directory=self.ldapobject.directory))
diff --git a/okupy/tests/vars.py b/okupy/tests/vars.py
index 60a8ffb..44270a6 100644
--- a/okupy/tests/vars.py
+++ b/okupy/tests/vars.py
@@ -49,16 +49,20 @@ DIRECTORY = {
},
"uid=jack,ou=people,o=test": {
"uid": ["jack"],
+ "objectClass": settings.AUTH_LDAP_USER_OBJECTCLASS +
+ settings.AUTH_LDAP_DEV_OBJECTCLASS,
"gentooACL": ["user.group", "developer.group", "foundation.group"],
},
"uid=john,ou=people,o=test": {
"uid": ["john"],
+ "objectClass": settings.AUTH_LDAP_USER_OBJECTCLASS,
"cn": ["John Smith"],
"gentooLocation": ["City3, Country3"],
"gentooRoles": ["kernel, security"],
"gentooACL": ["user.group", "retired.group"],
},
"uid=matt,ou=people,o=test": {
+ "objectClass": settings.AUTH_LDAP_USER_OBJECTCLASS,
"gentooACL": ["user.group", "retired.group"],
},
}