Code Duplication    Length = 20-24 lines in 2 locations

tests/test_scan_and_result.py 2 locations

@@ 335-358 (lines=24) @@
332
        params = response.findall('vts/vt/params/param')
333
        self.assertEqual(2, len(params))
334
335
    def test_get_vts_vts_with_refs(self):
336
        daemon = DummyWrapper([])
337
        daemon.add_vt(
338
            '1.2.3.4',
339
            'A vulnerability test',
340
            vt_params="a",
341
            custom="b",
342
            vt_refs="c",
343
        )
344
        response = secET.fromstring(
345
            daemon.handle_command('<get_vts vt_id="1.2.3.4"></get_vts>')
346
        )
347
        # The status of the response must be success (i.e. 200)
348
        self.assertEqual(response.get('status'), '200')
349
        # The response root element must have the correct name
350
        self.assertEqual(response.tag, 'get_vts_response')
351
        # The response must contain a 'vts' element
352
        self.assertIsNotNone(response.find('vts'))
353
        vt_params = response[0][0].findall('params')
354
        self.assertEqual(1, len(vt_params))
355
        custom = response[0][0].findall('custom')
356
        self.assertEqual(1, len(custom))
357
        refs = response.findall('vts/vt/refs/ref')
358
        self.assertEqual(2, len(refs))
359
360
    def test_get_vts_vts_with_dependencies(self):
361
        daemon = DummyWrapper([])
@@ 314-333 (lines=20) @@
311
        custom = response.findall('vts/vt/custom')
312
        self.assertEqual(3, len(custom))
313
314
    def test_get_vts_vts_with_params(self):
315
        daemon = DummyWrapper([])
316
        daemon.add_vt(
317
            '1.2.3.4', 'A vulnerability test', vt_params="a", custom="b"
318
        )
319
        response = secET.fromstring(
320
            daemon.handle_command('<get_vts vt_id="1.2.3.4"></get_vts>')
321
        )
322
        # The status of the response must be success (i.e. 200)
323
        self.assertEqual(response.get('status'), '200')
324
        # The response root element must have the correct name
325
        self.assertEqual(response.tag, 'get_vts_response')
326
        # The response must contain a 'scanner_params' element
327
        self.assertIsNotNone(response.find('vts'))
328
        vt_params = response[0][0].findall('params')
329
        self.assertEqual(1, len(vt_params))
330
        custom = response[0][0].findall('custom')
331
        self.assertEqual(1, len(custom))
332
        params = response.findall('vts/vt/params/param')
333
        self.assertEqual(2, len(params))
334
335
    def test_get_vts_vts_with_refs(self):
336
        daemon = DummyWrapper([])