@@ -327,6 +327,39 @@ def test_hostnames(self, host_with_hostnames, test_client, session,
327327 assert set (res .json ['hostnames' ]) == {hostname .name for hostname in
328328 host_with_hostnames .hostnames }
329329
330+ def test_wont_get_vulns_from_inactive_workspace (self , vulnerability_factory , second_workspace , test_client , session ):
331+ vulns = VulnerabilityWeb .query .all ()
332+ for vuln in vulns :
333+ session .delete (vuln )
334+ session .commit ()
335+
336+ vulns = Vulnerability .query .all ()
337+ for vuln in vulns :
338+ session .delete (vuln )
339+ session .commit ()
340+
341+ vulns_unconfirmed = vulnerability_factory .create_batch (4 , confirmed = False ,
342+ workspace = self .workspace ,
343+ status = 'open' ,
344+ severity = 'critical' )
345+
346+ vulns_high = vulnerability_factory .create_batch (4 ,
347+ confirmed = True ,
348+ workspace = second_workspace ,
349+ status = 'open' ,
350+ severity = 'high' )
351+ session .add_all (vulns_unconfirmed + vulns_high )
352+ session .commit ()
353+
354+ response = test_client .get (f'{ self .url ()} /filter' )
355+ assert response .status_code == 200
356+ assert response .json ['count' ] == 8
357+
358+ second_workspace .active = False
359+ response = test_client .get (f'{ self .url ()} /filter' )
360+ assert response .status_code == 200
361+ assert response .json ['count' ] == 4
362+
330363 def test_histogram_creation (self , vulnerability_factory , second_workspace , test_client , session ):
331364 """
332365 This one should only check basic vuln properties
0 commit comments