-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTEST_GRAPH.py
193 lines (158 loc) · 8.77 KB
/
TEST_GRAPH.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
'''
Akond Rahman
May 05, 2021
Testing for graph utilities
'''
import unittest
import TEST_CONSTANTS
import parser
import graphtaint
import scanner
class TestSecretGraphs( unittest.TestCase ):
def testHelmGraphV1(self):
oracle_value = 11
scriptName = TEST_CONSTANTS._helm_script1
_, tupleList, _, _ = scanner.scanSingleManifest(scriptName)
self.assertEqual(oracle_value, len( tupleList ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV2(self):
oracle_value = 8
scriptName = TEST_CONSTANTS._helm_script2
_, tupleList, _ , _= scanner.scanSingleManifest(scriptName)
self.assertEqual(oracle_value, len( tupleList ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV3(self):
oracle_value = 4
scriptName = TEST_CONSTANTS._helm_script3
_, tupleList, _ , _= scanner.scanSingleManifest(scriptName)
self.assertEqual(oracle_value, len( tupleList ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV4(self):
oracle_value = 4
scriptName = TEST_CONSTANTS._helm_script3
_, _, valid_taint_ls, _ = scanner.scanSingleManifest(scriptName)
self.assertEqual(oracle_value, len( valid_taint_ls ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV5(self):
oracle_value = 4
scriptName = TEST_CONSTANTS._helm_script4
_, tupList, _, _ = scanner.scanSingleManifest(scriptName)
self.assertEqual(oracle_value, len( tupList ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV6(self):
oracle_value = 4
scriptName = TEST_CONSTANTS._helm_script4
_, _, valid_taint_ls, _ = scanner.scanSingleManifest(scriptName)
self.assertEqual(oracle_value, len( valid_taint_ls ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV7(self):
oracle_value = 0
scriptName = TEST_CONSTANTS._helm_script4
within_match, _, _, _ = scanner.scanSingleManifest(scriptName)
self.assertEqual( len(within_match[0]) + len(within_match[1]) + len(within_match[2]) , oracle_value , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV8(self):
oracle_value = 1
scriptName = TEST_CONSTANTS._helm_script5
_, _, valid_taint_ls, _ = scanner.scanSingleManifest(scriptName)
self.assertEqual(oracle_value, len( valid_taint_ls ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHelmGraphV9(self):
oracle_value = 0
scriptName = TEST_CONSTANTS._helm_script5
within_match, _, _, _ = scanner.scanSingleManifest(scriptName)
self.assertEqual( len(within_match[0]) + len(within_match[1]) + len(within_match[2]) , oracle_value , TEST_CONSTANTS._common_error_string + str(oracle_value) )
class TestHTTPGraphs( unittest.TestCase ):
def testHTTPGraphV1(self):
oracle_value = 3
scriptName = TEST_CONSTANTS._http_script1
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV2(self):
oracle_value = 1
scriptName = TEST_CONSTANTS._http_script2
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV3(self):
oracle_value = 2
scriptName = TEST_CONSTANTS._http_script3
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV4(self):
oracle_value = 11
scriptName = TEST_CONSTANTS._http_script4
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV5(self):
oracle_value = 11
scriptName = TEST_CONSTANTS._http_script5
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV6(self):
oracle_value = 3
scriptName = TEST_CONSTANTS._http_script6
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV7(self):
oracle_value = 3
scriptName = TEST_CONSTANTS._http_script7
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV8(self):
oracle_value = 3
scriptName = TEST_CONSTANTS._http_script8
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV9(self):
oracle_value = 3
scriptName = TEST_CONSTANTS._http_script9
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV10(self):
oracle_value = 2
scriptName = TEST_CONSTANTS._http_script10
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV11(self):
oracle_value = 1
scriptName = TEST_CONSTANTS._http_script11 # this script is a multi doc
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV12(self):
oracle_value = 1
scriptName = TEST_CONSTANTS._http_script12
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV13(self):
oracle_value = 0
scriptName = TEST_CONSTANTS._http_script13
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV14(self):
'''
this one tests if empty lists for a HTTP_DICT is returned. If empty list, then HTTP declared but not used
'''
oracle_value = 0
scriptName = TEST_CONSTANTS._http_script14
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic[1] ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV15(self):
'''
this one tests if a list with one item for a HTTP_DICT is returned. If list with >= 1 item, then HTTP declared and used
'''
oracle_value = 1
scriptName = TEST_CONSTANTS._http_script1
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic[1] ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV16(self):
oracle_value = 1
scriptName = TEST_CONSTANTS._http_script15
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV17(self):
'''
this one tests if empty lists for a HTTP_DICT is returned. If empty list, then HTTP declared but not used
'''
oracle_value = 0
scriptName = TEST_CONSTANTS._http_script16
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic[1] ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
def testHTTPGraphV18(self):
oracle_value = 1
scriptName = TEST_CONSTANTS._http_script16
res_dic = scanner.scanForHTTP(scriptName)
self.assertEqual(oracle_value, len( res_dic ) , TEST_CONSTANTS._common_error_string + str(oracle_value) )
if __name__ == '__main__':
unittest.main()