-
Notifications
You must be signed in to change notification settings - Fork 2
/
Adv_OpenLDAPS.py
124 lines (90 loc) · 3.25 KB
/
Adv_OpenLDAPS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
from config import CONFIG
from selenium.webdriver.chrome.options import Options
import paramiko
import time, login, os, sys
import logging
import LDAPconfig
script = os.path.basename(sys.argv[0])
logging.basicConfig(filename='./files/test_logs/%s.log' % script, format='%(asctime)s %(message)s', level=logging.INFO)
logger = logging.getLogger('test')
if CONFIG.WEBDRIVER == "Chrome":
_chrome_options = Options()
_chrome_options.add_argument("--start-fullscreen")
driver = webdriver.Chrome(chrome_options=_chrome_options)
elif CONFIG.WEBDRIVER == "Firefox":
driver = webdriver.Firefox()
else:
print('No valid Webdrive was provided. ')
# driver.set_window_size(1440, 1200)
driver.implicitly_wait(CONFIG.waittime)
# time.sleep(2)
host = CONFIG.HOST
# copy ldap.config to server
LDAPconfig.cpy_config(logger, CONFIG.HOST, CONFIG.server, CONFIG.username)
# Config settings and group stings for OpenLDAP
openLDAPusers = [
["[email protected]", "ChangeMePlease!", "administrator"],
["[email protected]", "ChangeMePlease!", "ldapSuper"],
["[email protected]", "ChangeMePlease!", "ldapAnalyst"],
["[email protected]", "ChangeMePlease!", "ldapObserver"]
]
openLDAPserver = ["", "tqldap.threatq.com", "636", "[email protected],ou=People,dc=threatq,dc=com",
"threatquotientthreatquotient", "DC=threatq,DC=com", "dn", "objectClass=posixAccount", "objectClass=posixGroup",
"memberUid", "cn", "uid", "memberUid"
]
# Run test steps here
login.login(logger, host, driver, usr=CONFIG.TQUSER[0], pssword=CONFIG.TQUSER[1], SAML=CONFIG.SAML)
logger.info('Start LDAP config test.')
time.sleep(1)
driver.get(host + "config/ldap")
try:
# Active Directory 2012 options.
LDAPconfig.setup(driver, logger,
openLDAPserver[0],
openLDAPserver[1],
openLDAPserver[2],
openLDAPserver[3],
openLDAPserver[4],
openLDAPserver[5],
openLDAPserver[6],
openLDAPserver[7],
openLDAPserver[8],
openLDAPserver[9],
openLDAPserver[10],
openLDAPserver[11],
openLDAPserver[12],
openLDAPusers[0][2],
openLDAPusers[1][2],
openLDAPusers[2][2],
openLDAPusers[3][2],
SSL=True,
LDAP=True
) # configure the TQ server for using ldap
except Exception as e:
logger.info (e)
print (e)
try:
LDAPconfig.test_connection (driver)
except Exception as e:
print e
time.sleep(3)
LDAPconfig.list_groups(driver, "13")
time.sleep(3)
LDAPconfig.list_users(driver, "17")
login.logout(logger, wdriver=driver)
for user in openLDAPusers:
try:
login.login(logger, host, driver, usr=user[0], pssword=user[1], SAML=CONFIG.SAML)
except Exception as e:
print ("Login attempt failed for user: %s") % user[0]
time.sleep(1)
try:
login.logout(logger, wdriver=driver)
except Exception as e:
print ("logout failed, probably not needed.")
time.sleep(1)
logger.info('End LDAP config test')
driver.quit()