-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.py
282 lines (193 loc) · 9.51 KB
/
test.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#####################################################################################
# Pydradis: Python API Wrapper for Dradis #
# Copyright (c) 2016 Novacoast #
# Dev : Pedro M. Sosa #
#####################################################################################
# This file is part of Pydradis. #
# #
# Pydradis is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# Pydradis is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with Pydradis. If not, see <http://www.gnu.org/licenses/>. #
#####################################################################################
#BUGS FOUND ON DRADIS (as of July 2016)
#1. Nodes Endpoint: IMPORTANT: WHEN CREATING NODES YOU CAN PUT THEM WITH ANY PARENT ID (Negative numbers and non-existant nodes)
#2. Issues Endpoint: No way to change or set an issue's rating.
#3. Note Endpoint: Cant update a note with category=0. (Can create it with category = 0 however)
#An Example Usage Test for Pydradis.py
from pydradis import Pydradis
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
if __name__ == "__main__":
print("Testing PyDradis!")
pd = Pydradis("<DRADIS API KEY>","<DRADIS SERVER URL>",False,False)
#Client
print("\n<CLIENT ENDPOINT>")
print("--Get Clients"),
if (pd.get_clientlist() != None): print("PASS")
else: print("FAILED")
print("--Create Client"),
clientid = pd.create_client("Test V.1")
if (clientid != None): print("PASS")
else: print("FAILED")
print("--Update Client"),
if (pd.update_client(clientid,"Test V.1 - MOD")==clientid): print("PASS")
else: print("FAILED")
print("--Find Client"),
if (pd.find_client("Test V.1 - MOD") == clientid): print("PASS")
else: print("FAILED")
print("--Get Client"),
if (str(pd.get_client(clientid)["id"]) == str(clientid)): print("PASS")
else: print("FAILED")
#raw_input("\nYou can take this moment to manually inspect Dradis :). Then press enter to continue test...\n")
#Project
print("\n<PROJECT ENDPOINT>");
print("--Get Projects"),
if (pd.get_projectlist() != None): print("PASS")
else: print("FAILED")
print("--Create Project"),
projectid = pd.create_project("Project T",clientid);
if (projectid != None): print("PASS")
else: print("FAILED")
print("--Update Project"),
if (pd.update_project(projectid,"Project T - Mod",clientid) == projectid): print("PASS")
else: print("FAILED")
print("--Find Project"),
if (pd.find_project("Project T - Mod") == projectid): print("PASS")
else: print("FAILED")
print("--Get Project"),
if (str(pd.get_project(projectid)["id"]) == str(projectid)): print("PASS")
else: print("FAILED")
#raw_input("\nYou can take this moment to manually inspect Dradis :). Then press enter to continue test...\n")
#Nodes
print("\n<NODE ENDPOINT>")
print("--Get Nodes"),
if (pd.get_nodelist(projectid) != None): print("PASS")
else: print("FAILED")
print("--Create Node"),
nodeid = pd.create_node(projectid,"T",0,None,1);
nodeid2 = pd.create_node(projectid,"X",0,nodeid,1);
if ((nodeid != None) and (nodeid2 != None)): print("PASS")
else: print("FAILED")
print("--Update Node"),
if (pd.update_node(projectid,nodeid,"TM",1) == nodeid): print("PASS")
print("--Find Node (2)"),
if (pd.find_node(projectid,"TM") == nodeid): print("PASS 1/2"),
else: print("FAILED 1/2"),
if (pd.find_node(projectid,"TM/X") == nodeid2): print("PASS 2/2")
else: print("FAILED 2/2")
print ("--Get Node Info"),
if (str(pd.get_node(projectid,nodeid)["id"]) == str(nodeid)): print("PASS")
else: print("FAILED")
#raw_input("\nYou can take this moment to manually inspect Dradis :). Then press enter to continue test...\n")
#Issues
print("\n<ISSUE ENDPOINT>")
print("--Get Issues"),
if (pd.get_issuelist(projectid) != None): print("PASS")
else: print("FAILED")
print("--Create Issue"),
issueid = pd.create_issue(projectid,"TEST ISSUE","DESCRIPTION GOES HERE",['URGENT','ADMIN','INTERNAL'])
if (issueid != None): print("PASS")
else: print("FAILED")
print("--Updating Issue"),
if (pd.update_issue(projectid,issueid,"TEST ISSUE - MOD","SOME OTHER DESCRIPTION",["High",'ALPHA','GUEST','INTERNAL']) == issueid): print("PASS")
else: print("FAILED")
print("--Find Issue"),
if (issueid in pd.find_issue(projectid,"AlphA")[0]): print("PASS")
else: print("FAILED")
print("--Get Issue Info"),
if (str(pd.get_issue(projectid,issueid)["id"])== str(issueid)): print("PASS")
else: print("FAILED")
#raw_input("\nYou can take this moment to manually inspect Dradis :). Then press enter to continue test...\n")
#Evidence
print("\n<EVIDENCE ENDPOINT>")
print("--Get Evidence"),
if (pd.get_evidencelist(projectid,nodeid) != None): print("PASS")
else: print("FAILED")
print("--Create Evidence"),
evidenceid = pd.create_evidence(projectid,nodeid,issueid,"SOME EVIDENCE","MORE INFO",["DANGER","ZONE"])
if (evidenceid != None): print("PASS")
else: print("FAILED")
print("--Update Evidence"),
if (pd.update_evidence(projectid,nodeid,issueid,evidenceid,"SOME EXTRA EVIDENCE","MORE MORE INFO",["ARCHER"]) == evidenceid): print("PASS")
else: print("FAILED")
print("--Find Evidence"),
if (pd.find_evidence(projectid,nodeid,["EXTRA"])[0]["id"] == evidenceid): print("PASS")
else: print("FAILED")
print("--Get Evidence"),
if (str(pd.get_evidence(projectid,nodeid,evidenceid)["id"])==str(evidenceid)): print("PASS")
else: print("FAILED")
#raw_input("\nYou can take this moment to manually inspect Dradis :). Then press enter to continue test...\n")
#Notes
print ("\n<NOTE ENDPOINT>")
print("--Get Notes"),
if (pd.get_notelist(projectid,nodeid) != None): print("PASS")
else: print("FAILED")
print("--Create Note"),
noteid = pd.create_note(projectid,nodeid,"NOTE TEST","TEXT TEXT",["TAG A"])
if (noteid != None): print("PASS")
else: print("FAILED")
print("--Update Note"),
if (pd.update_note(projectid,nodeid,noteid,"TEST NOTE", "NEW TEXT",["TAGC"],1)==noteid): print("PASS")
else: print("FAILED")
print("--Find Note"),
if (noteid in pd.find_note(projectid,nodeid,"TAGC")[0]): print("PASS")
else: print("FAILED")
print("--Get Note"),
if (pd.get_note(projectid,nodeid,noteid)["id"] == noteid): print("PASS")
else: print("FAILED")
#Attachments
print ("\n<ATTACHMENT ENDPOINT>")
print ("--Get Attachments List"),
if (pd.get_attachmentlist(projectid,nodeid) != None): print("PASS")
else: print("FAILED")
print("--Upload Attachment"),
attachmentid = pd.post_attachment(projectid,nodeid,"test.py")
if (attachmentid != None): print("PASS")
else: print("FAILED")
print("--Rename Attachment"),
if (pd.rename_attachment(projectid,nodeid,attachmentid[0],"FOO.py")[0]=="FOO.py"): print("PASS")
else: print("FAILED")
print("--Download Attachment"),
if (pd.get_attachment(projectid,nodeid,"FOO.py") != None): print("PASS")
else: print("FAILED")
raw_input("\nYou can take this moment to manually inspect Dradis :). Then press enter to continue test...\n")
#<Deletions>
print("\n<<DELETING STUFF>>")
#raw_input("del_attachment?")
print("--Deleting Attachment"),
if (pd.delete_attachment(projectid,nodeid,"FOO.py") != None): print("PASS")
else: print("FAILED")
#raw_input("del_note?")
print("--Deleting Note"),
if (pd.delete_note(projectid,nodeid,noteid) == True): print("PASS")
else: print("FAILED")
#raw_input("del_evidence?")
print("--Deleting Evidence"),
if (pd.delete_evidence(projectid,nodeid,evidenceid) == True): print("PASS")
else: print("FAILED")
#raw_input("del_issue?"),
print("--Deleting Issue"),
if (pd.delete_issue(projectid,issueid) == True): print("PASS")
else: print("FAILED")
#raw_input("del_node?"),
print("--Deleting Node"),
if(pd.delete_node(projectid,nodeid) == True): print("PASS")
else: print("FAILED")
#raw_input("del_proj?"),
print("--Deleting Project"),
if(pd.delete_project(projectid) == True): print("PASS")
else: print("FAILED")
#raw_input("del_client?"),
print("--Deleting Client"),
if(pd.delete_client(clientid) == True): print("PASS")
else: print("FAILED")