# 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
        admin_pages = [
            "/create_account/",
            "/thanks/",
            "/account_create_error/",
            "/change_password/done/",
            "/password_reset/",
            "/password_reset_done/",
            "/login/",
           
        ]
        for page in admin_pages:
            logger.info('testing GET page %s',page)
            response = self.client.get(page)
            self.assertEqual(response.status_code, 200)
      
        response= self.client.get("/logout/")
        self.assertEqual(response.status_code, 302)
    
    
    
          
    def test_All(self):
        self.Test_create_client()
        self.Test_passwordChange()
        self.Test_all_pages()
        
    
    def tearDown(self):
        logger.info('test teardown CreateAccount')
        removeFromLDAPGroup(testuser,'active')

# 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

        admin_pages = [
            "/create_account/",
            "/thanks/",
            "/account_create_error/",
            "/change_password/done/",
            "/password_reset/",
            "/password_reset_done/",
            "/login/",
           
        ]
        for page in admin_pages:
            logger.info('testing GET page %s',page)
            response = self.client.get(page)
            self.assertEqual(response.status_code, 200)
      
        response= self.client.get("/logout/")
        self.assertEqual(response.status_code, 302)
    
    
    
          
    def test_All(self):
        self.Test_create_client()
        self.Test_passwordChange()
        self.Test_all_pages()
        
    
    def tearDown(self):
        logger.info('test teardown CreateAccount')
        removeFromLDAPGroup(testuser,'active')

        removeFromLDAPGroup(testuser,'editor')