-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcheckXLDPermissions_old.py
41 lines (40 loc) · 1.46 KB
/
checkXLDPermissions_old.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
import httplib
import base64
import json
def hasPermission(t):
de = t.pythonScript.getProperty("deploymentEnvironment")
if de != None:
u = t.pythonScript.getProperty("username")
p = t.pythonScript.getProperty("password")
dp = t.pythonScript.getProperty("deploymentPackage")
s = t.pythonScript.getProperty("server")
if u == None:
u = s.username
if p == None:
p = s.password
conn = httplib.HTTPConnection(s.url.split("//")[1])
authcode = str("Basic " + base64.b64encode(str(u) + ":" + str(p)))
headers = {"Authorization": authcode}
conn.request("GET", "/deployit/security/check/deploy%23initial/Environments/"+ de, headers=headers)
res = conn.getresponse()
if res.status == 200:
res_text = res.read()
if res_text.find("false") > -1:
return False
else:
return True
else:
return False
else :
return False
finalState = True
print "Phase Name|XL Deploy Task Title| Environment | Creds can Deploy (Y/N)"
print "---|---|---|---"
for p in release.phases:
for t in p.tasks:
if str(t.taskType) == "xldeploy.Deploy":
status = hasPermission(t)
print "%s|%s|%s|%s" % (p.title,t.title ,t.pythonScript.getProperty("deploymentEnvironment"), status)
finalState = finalState and status
if finalState == False:
raise ValueError("Some Credentials need to be corrected")