-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAdv_AD2012_domain.py
127 lines (94 loc) · 3.01 KB
/
Adv_AD2012_domain.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
125
126
127
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
# Config settings and group stings for Active Directory 2012
AD12usr = [
["tqadmin", "ChangeMePlease!", "linux-admins"],
["contributor", "ChangeMePlease!", "primary-contributor"],
["maintenance", "ChangeMePlease!", "tq-maintenance"],
["readonly", "ChangeMePlease!", "read-only"]
]
AD12svr = ["@threatq.com", "tqad-east.threatq.com", "389", "tqadmin",
"ChangeMePlease!", "DC=threatq,DC=com", "dn", "", "",
"tqusers", "memberof", "sAMAccountName", "uid"
]
# Run test steps here
login.login(logger, host, driver, usr=CONFIG.USER[0], pssword=CONFIG.USER[1], SAML=CONFIG.SAML)
logger.info('Start LDAP config test.')
time.sleep(5)
driver.get(host + "config/ldap")
try:
# Active Directory 2012 options.
LDAPconfig.setup(driver, logger,
AD12svr[0],
AD12svr[1],
AD12svr[2],
AD12svr[3],
AD12svr[4],
AD12svr[5],
AD12svr[6],
AD12svr[7],
AD12svr[8],
AD12svr[9],
AD12svr[10],
AD12svr[11],
AD12svr[12],
AD12usr[0][2],
AD12usr[1][2],
AD12usr[2][2],
AD12usr[3][2],
SSL=False,
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)
try:
LDAPconfig.list_groups(driver, "56")
except Exception as e:
print e
time.sleep(3)
try:
LDAPconfig.list_users(driver, "34")
except Exception as e:
print e
login.logout(logger, wdriver=driver)
for user in AD12usr:
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()