@@ -66,10 +66,12 @@ def test_api_with_single_vulnerability(self):
6666 {
6767 "url" : f"http://testserver/api/packages/{ self .pkg1 .id } " ,
6868 "purl" : "pkg:pypi/flask@0.1.2" ,
69+ "is_vulnerable" : False ,
6970 },
7071 {
7172 "url" : f"http://testserver/api/packages/{ self .pkg2 .id } " ,
7273 "purl" : "pkg:debian/flask@0.1.2" ,
74+ "is_vulnerable" : False ,
7375 },
7476 ],
7577 "affected_packages" : [],
@@ -89,6 +91,7 @@ def test_api_with_single_vulnerability_with_filters(self):
8991 {
9092 "url" : f"http://testserver/api/packages/{ self .pkg1 .id } " ,
9193 "purl" : "pkg:pypi/flask@0.1.2" ,
94+ "is_vulnerable" : False ,
9295 },
9396 ],
9497 "affected_packages" : [],
@@ -136,6 +139,15 @@ def setUp(self):
136139 vulnerability = vuln ,
137140 fix = True ,
138141 )
142+ vuln1 = Vulnerability .objects .create (
143+ summary = "test-vuln1" ,
144+ )
145+ self .vuln1 = vuln1
146+ PackageRelatedVulnerability .objects .create (
147+ package = self .package ,
148+ vulnerability = vuln1 ,
149+ fix = False ,
150+ )
139151
140152 def test_api_status (self ):
141153 response = self .csrf_client .get ("/api/packages/" , format = "json" )
@@ -156,7 +168,15 @@ def test_api_with_single_vulnerability_and_fixed_package(self):
156168 "version" : "11" ,
157169 "qualifiers" : {},
158170 "subpath" : "" ,
159- "affected_by_vulnerabilities" : [],
171+ "affected_by_vulnerabilities" : [
172+ {
173+ "url" : f"http://testserver/api/vulnerabilities/{ self .vuln1 .id } " ,
174+ "vulnerability_id" : f"VULCOID-{ int_to_base36 (self .vuln1 .id ).upper ()} " ,
175+ "summary" : "test-vuln1" ,
176+ "references" : [],
177+ "fixed_packages" : [],
178+ }
179+ ],
160180 "fixing_vulnerabilities" : [
161181 {
162182 "url" : f"http://testserver/api/vulnerabilities/{ self .vuln .id } " ,
@@ -167,11 +187,20 @@ def test_api_with_single_vulnerability_and_fixed_package(self):
167187 {
168188 "url" : f"http://testserver/api/packages/{ self .package .id } " ,
169189 "purl" : "pkg:generic/nginx/test@11" ,
190+ "is_vulnerable" : True ,
170191 }
171192 ],
172193 },
173194 ],
174- "unresolved_vulnerabilities" : [],
195+ "unresolved_vulnerabilities" : [
196+ {
197+ "url" : f"http://testserver/api/vulnerabilities/{ self .vuln1 .id } " ,
198+ "vulnerability_id" : f"VULCOID-{ int_to_base36 (self .vuln1 .id ).upper ()} " ,
199+ "summary" : "test-vuln1" ,
200+ "references" : [],
201+ "fixed_packages" : [],
202+ }
203+ ],
175204 }
176205
177206 def test_api_with_single_vulnerability_and_vulnerable_package (self ):
@@ -195,6 +224,7 @@ def test_api_with_single_vulnerability_and_vulnerable_package(self):
195224 {
196225 "url" : f"http://testserver/api/packages/{ self .package .id } " ,
197226 "purl" : "pkg:generic/nginx/test@11" ,
227+ "is_vulnerable" : True ,
198228 }
199229 ],
200230 }
@@ -210,6 +240,7 @@ def test_api_with_single_vulnerability_and_vulnerable_package(self):
210240 {
211241 "url" : f"http://testserver/api/packages/{ self .package .id } " ,
212242 "purl" : "pkg:generic/nginx/test@11" ,
243+ "is_vulnerable" : True ,
213244 }
214245 ],
215246 }
0 commit comments