File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1+ #
2+ # Copyright (c) nexB Inc. and others. All rights reserved.
3+ # VulnerableCode is a trademark of nexB Inc.
4+ # SPDX-License-Identifier: Apache-2.0
5+ # See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+ # See https://github.com/nexB/vulnerablecode for support or download.
7+ # See https://aboutcode.org for more information about nexB OSS projects.
8+ #
9+
10+ from django .test import TestCase
11+
12+ from vulnerabilities .forms import CVEForm
13+ from vulnerabilities .models import Vulnerability
14+
15+
16+ class TestCVEForm (TestCase ):
17+ def setUp (self ) -> None :
18+ vuln1 = Vulnerability .objects .create (summary = "test-vuln1" , vulnerability_id = "VCID-1234" )
19+ self .id = vuln1 .id
20+
21+ def test_cve_form (self ):
22+ form = CVEForm (data = {"vuln_id" : "vcid-1234" })
23+ assert form .is_valid ()
24+
25+ def test_client (self ):
26+ response = self .client .get (f"/vulnerabilities/{ self .id } ?vuln_id=vcid-1234" )
27+ self .assertContains (response , "test-vuln1" , status_code = 200 )
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ def request_to_vulnerabilities(request):
199199 vuln_id = request .GET ["vuln_id" ]
200200 return list (
201201 models .Vulnerability .objects .filter (
202- Q (vulnerability_id = vuln_id ) | Q (aliases__alias__icontains = vuln_id )
202+ Q (vulnerability_id__iexact = vuln_id ) | Q (aliases__alias__icontains = vuln_id )
203203 )
204204 .order_by ("vulnerability_id" )
205205 .annotate (
You can’t perform that action at this time.
0 commit comments