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')
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")
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')
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)
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)
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)
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)
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")
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 )
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)
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)
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))
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)
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))
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)
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)
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)
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)