Пример #1
0
 def test_queued_account_gets_added_to_ldap(self):
     vars.QUEUEDUSER.save()
     activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertTrue(
         ldap_users(vars.QUEUEDUSER.username,
                    directory=self.ldapobj.directory))
     ldap_account = ldap_users(vars.QUEUEDUSER.username,
                               directory=self.ldapobj.directory)[1]
     self.assertEqual(ldap_account['objectClass'],
                      settings.AUTH_LDAP_USER_OBJECTCLASS)
     self.assertEqual(ldap_account['sn'][0], vars.QUEUEDUSER.last_name)
     self.assertEqual(
         ldap_account['cn'][0],
         '%s %s' % (vars.QUEUEDUSER.first_name, vars.QUEUEDUSER.last_name))
     self.assertTrue(
         ldap_md5_crypt.verify(vars.QUEUEDUSER.password,
                               ldap_account['userPassword'][0]))
     self.assertEqual(ldap_account['givenName'][0],
                      vars.QUEUEDUSER.first_name)
     self.assertEqual(ldap_account['mail'][0], vars.QUEUEDUSER.email)
     self.assertEqual(ldap_account['uid'][0], vars.QUEUEDUSER.username)
     self.assertEqual(ldap_account['uidNumber'][0], '1002')
     self.assertEqual(ldap_account['gidNumber'][0], '100')
     self.assertEqual(
         ldap_account['gecos'][0],
         '%s %s' % (vars.QUEUEDUSER.first_name, vars.QUEUEDUSER.last_name))
     self.assertEqual(ldap_account['homeDirectory'][0],
                      '/home/%s' % vars.QUEUEDUSER.username)
     self.assertEqual(ldap_account['gentooACL'][0], 'user.group')
Пример #2
0
 def test_add_first_user_in_empty_ldap_directory(self):
     vars.QUEUEDUSER.save()
     activate_url = "/activate/%s/" % vars.QUEUEDUSER.encrypted_id
     self.ldapobj.directory = ldap_users(clean=True)
     request = set_request(activate_url, messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertTrue(ldap_users(vars.QUEUEDUSER.username, directory=self.ldapobj.directory))
     self.assertEqual(ldap_users(vars.QUEUEDUSER.username, directory=self.ldapobj.directory)[1]["uidNumber"][0], "1")
Пример #3
0
 def test_add_first_user_in_empty_ldap_directory(self):
     vars.QUEUEDUSER.save()
     activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
     self.ldapobj.directory = ldap_users(clean=True)
     request = set_request(activate_url, messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertTrue(
         ldap_users(vars.QUEUEDUSER.username,
                    directory=self.ldapobj.directory))
     self.assertEqual(
         ldap_users(vars.QUEUEDUSER.username,
                    directory=self.ldapobj.directory)[1]['uidNumber'][0],
         '1')
Пример #4
0
 def test_no_ldap_connection_raises_error_in_activation(self):
     vars.QUEUEDUSER.save()
     activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertMessage(response, "Can't contact LDAP server", 40)
Пример #5
0
 def test_add_queued_account_to_ldap_prints_success_message(self):
     vars.QUEUEDUSER.save()
     activate_url = "/activate/%s/" % vars.QUEUEDUSER.encrypted_id
     request = set_request(uri=activate_url, messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertMessage(response, "Your account has been activated successfully", 25)
Пример #6
0
 def test_no_ldap_connection_raises_error_in_activation(self):
     vars.QUEUEDUSER.save()
     activate_url = "/activate/%s/" % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertMessage(response, "Can't contact LDAP server", 40)
Пример #7
0
 def test_add_queued_account_to_ldap_prints_success_message(self):
     vars.QUEUEDUSER.save()
     activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
     request = set_request(uri=activate_url, messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertMessage(response,
                        'Your account has been activated successfully', 25)
Пример #8
0
 def test_queued_account_gets_added_to_ldap(self):
     vars.QUEUEDUSER.save()
     activate_url = "/activate/%s/" % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertTrue(ldap_users(vars.QUEUEDUSER.username, directory=self.ldapobj.directory))
     ldap_account = ldap_users(vars.QUEUEDUSER.username, directory=self.ldapobj.directory)[1]
     self.assertEqual(ldap_account["objectClass"], settings.AUTH_LDAP_USER_OBJECTCLASS)
     self.assertEqual(ldap_account["sn"][0], vars.QUEUEDUSER.last_name)
     self.assertEqual(ldap_account["cn"][0], "%s %s" % (vars.QUEUEDUSER.first_name, vars.QUEUEDUSER.last_name))
     self.assertTrue(ldap_md5_crypt.verify(vars.QUEUEDUSER.password, ldap_account["userPassword"][0]))
     self.assertEqual(ldap_account["givenName"][0], vars.QUEUEDUSER.first_name)
     self.assertEqual(ldap_account["mail"][0], vars.QUEUEDUSER.email)
     self.assertEqual(ldap_account["uid"][0], vars.QUEUEDUSER.username)
     self.assertEqual(ldap_account["uidNumber"][0], "1002")
     self.assertEqual(ldap_account["gidNumber"][0], "100")
     self.assertEqual(ldap_account["gecos"][0], "%s %s" % (vars.QUEUEDUSER.first_name, vars.QUEUEDUSER.last_name))
     self.assertEqual(ldap_account["homeDirectory"][0], "/home/%s" % vars.QUEUEDUSER.username)
     self.assertEqual(ldap_account["gentooACL"][0], "user.group")
Пример #9
0
 def test_no_ldap_connection_sends_notification_mail_in_activation(self):
     vars.QUEUEDUSER.save()
     activate_url = "/activate/%s/" % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertEqual(len(mail.outbox), 1)
     self.assertEqual(
         mail.outbox[0].subject, "%sERROR: {'desc': \"Can't contact LDAP server\"}" % settings.EMAIL_SUBJECT_PREFIX
     )
Пример #10
0
 def test_no_ldap_connection_sends_notification_mail_in_activation(self):
     vars.QUEUEDUSER.save()
     activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertEqual(len(mail.outbox), 1)
     self.assertEqual(
         mail.outbox[0].subject,
         '%sERROR: {\'desc\': "Can\'t contact LDAP server"}' %
         settings.EMAIL_SUBJECT_PREFIX)
Пример #11
0
 def test_wrong_activaltion_link_raises_invalid_url(self):
     request = set_request(uri='/activate/invalidurl', messages=True)
     response = activate(request, 'invalidurl')
     response.context = RequestContext(request)
     self.assertMessage(response, 'Invalid URL', 40)
Пример #12
0
 def test_no_database_connection_sends_notificationmail_in_activation(self):
     request = set_request('/activate/test', messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertEqual(len(mail.outbox), 1)
     self.assertTrue(mail.outbox[0].subject.startswith(
         '%sERROR:' % settings.EMAIL_SUBJECT_PREFIX))
Пример #13
0
 def test_no_database_connection_raises_error_in_activation(self):
     request = set_request('/activate/test', messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertMessage(response, "Can't contact the database", 40)
Пример #14
0
 def test_no_database_connection_sends_notificationmail_in_activation(self):
     request = set_request("/activate/test", messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertEqual(len(mail.outbox), 1)
     self.assertTrue(mail.outbox[0].subject.startswith("%sERROR:" % settings.EMAIL_SUBJECT_PREFIX))
Пример #15
0
 def test_add_queued_account_remove_from_queue(self):
     vars.QUEUEDUSER.save()
     activate_url = "/activate/%s/" % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertEqual(Queue.objects.count(), 0)
Пример #16
0
 def test_wrong_activaltion_link_raises_invalid_url(self):
     request = set_request(uri="/activate/invalidurl", messages=True)
     response = activate(request, "invalidurl")
     response.context = RequestContext(request)
     self.assertMessage(response, "Invalid URL", 40)
Пример #17
0
 def test_add_queued_account_remove_from_queue(self):
     vars.QUEUEDUSER.save()
     activate_url = '/activate/%s/' % vars.QUEUEDUSER.encrypted_id
     request = set_request(activate_url, messages=True)
     activate(request, vars.QUEUEDUSER.encrypted_id)
     self.assertEqual(Queue.objects.count(), 0)
Пример #18
0
 def test_no_database_connection_raises_error_in_activation(self):
     request = set_request("/activate/test", messages=True)
     response = activate(request, vars.QUEUEDUSER.encrypted_id)
     response.context = RequestContext(request)
     self.assertMessage(response, "Can't contact the database", 40)