# Path: stack_configs/ldap_functions.py
# def getLDAPConn():
#     #ldap3
#     dn=settings.AUTH_LDAP_BIND_DN
#     password= settings.AUTH_LDAP_BIND_PASSWORD
#     conn=getLDAPConnWithUser(dn, password)
#     return conn
# 
# def removeFromLDAPGroup(user_name,group_name):
#     #this is used in testing
#     #returns true or false uses LDAP3  
#     con= getLDAPConn()
#     group_dn= str("cn=")+str(group_name)+str(",")+str(settings.AUTH_LDAP_GROUPS_OU_DN)
#     result=con.modify(group_dn,
#                       {'memberUid': (MODIFY_DELETE, [user_name])
#     })
#     
#     logger.info ("remove %s from group %s result is %s", user_name, group_name, result )
#     con.unbind()
#     return result


from django.test import TestCase,Client
from django.conf import settings
from stack_configs.ldap_functions import getLDAPConn,removeFromLDAPGroup
import logging
        self.assertEqual(response.status_code, 200)
        #ensure cant login with email that already exists
        logger.info('test trying to create username with email which already exists')
        response=self.client.post('/create_account/', {'username': 'differenttestuser', 'password': 'secret', 'first_name':'fred','last_name':'test', 'email':testuseremail})
        self.assertEqual(response.status_code, 200)
        
    def Test_passwordChange(self):
        
        
        logger.info('test starting test password change')
        logger.info('test logging in')
        response= self.client.login(username=testuser, password='secret')
        logger.info('test post to change password')
        response=self.client.post('/change_password/', {'old_password': 'secret', 'new_password1': 'verysecret', 'new_password2':'verysecret'})
        self.assertRedirects(response, '/change_password/done/')
        logger.info('test logging out')
        response=self.client.get('/logout/')
        self.assertRedirects(response, '/login/')
        logger.info('test get login page')
        response=self.client.get('/login/')
        self.assertEqual(response.status_code, 200)
        logger.info('test login with new password')
        response= self.client.login(username=testuser, password='verysecret')
             
    def Test_all_pages(self):
        #get all pages
        response= self.client.login(username=testuser, password='verysecret')
        
        #make sure user has permissions, in zibawa and ldap!
        admin_pages = [

# Path: stack_configs/ldap_functions.py
# def getLDAPConn():
#     #ldap3
#     dn=settings.AUTH_LDAP_BIND_DN
#     password= settings.AUTH_LDAP_BIND_PASSWORD
#     conn=getLDAPConnWithUser(dn, password)
#     return conn
# 
# def removeFromLDAPGroup(user_name,group_name):
#     #this is used in testing
#     #returns true or false uses LDAP3  
#     con= getLDAPConn()
#     group_dn= str("cn=")+str(group_name)+str(",")+str(settings.AUTH_LDAP_GROUPS_OU_DN)
#     result=con.modify(group_dn,
#                       {'memberUid': (MODIFY_DELETE, [user_name])
#     })
#     
#     logger.info ("remove %s from group %s result is %s", user_name, group_name, result )
#     con.unbind()
#     return result


# Path: front/tests.py
from django.test import TestCase,Client
from django.conf import settings
from stack_configs.ldap_functions import getLDAPConn,removeFromLDAPGroup
import logging

        self.assertEqual(response.status_code, 200)
        #ensure cant login with email that already exists
        logger.info('test trying to create username with email which already exists')
        response=self.client.post('/create_account/', {'username': 'differenttestuser', 'password': 'secret', 'first_name':'fred','last_name':'test', 'email':testuseremail})
        self.assertEqual(response.status_code, 200)
        
    def Test_passwordChange(self):
        
        
        logger.info('test starting test password change')
        logger.info('test logging in')
        response= self.client.login(username=testuser, password='secret')
        logger.info('test post to change password')
        response=self.client.post('/change_password/', {'old_password': 'secret', 'new_password1': 'verysecret', 'new_password2':'verysecret'})
        self.assertRedirects(response, '/change_password/done/')
        logger.info('test logging out')
        response=self.client.get('/logout/')
        self.assertRedirects(response, '/login/')
        logger.info('test get login page')
        response=self.client.get('/login/')
        self.assertEqual(response.status_code, 200)
        logger.info('test login with new password')
        response= self.client.login(username=testuser, password='verysecret')
             
    def Test_all_pages(self):
        #get all pages
        response= self.client.login(username=testuser, password='verysecret')
        
        #make sure user has permissions, in zibawa and ldap!
        admin_pages = [

            "/create_account/",