| @@ 26-110 (lines=85) @@ | ||
| 23 | from gvm.protocols.gmpv208 import InfoType |
|
| 24 | ||
| 25 | ||
| 26 | class GmpGetInfoListTestCase: |
|
| 27 | def test_get_info_list(self): |
|
| 28 | self.gmp.get_info_list(InfoType.CERT_BUND_ADV) |
|
| 29 | ||
| 30 | self.connection.send.has_been_called_with( |
|
| 31 | '<get_info type="CERT_BUND_ADV"/>' |
|
| 32 | ) |
|
| 33 | ||
| 34 | self.gmp.get_info_list(InfoType.CPE) |
|
| 35 | ||
| 36 | self.connection.send.has_been_called_with('<get_info type="CPE"/>') |
|
| 37 | ||
| 38 | self.gmp.get_info_list(info_type=InfoType.CPE) |
|
| 39 | ||
| 40 | self.connection.send.has_been_called_with('<get_info type="CPE"/>') |
|
| 41 | ||
| 42 | self.gmp.get_info_list(InfoType.CVE) |
|
| 43 | ||
| 44 | self.connection.send.has_been_called_with('<get_info type="CVE"/>') |
|
| 45 | ||
| 46 | self.gmp.get_info_list(InfoType.DFN_CERT_ADV) |
|
| 47 | ||
| 48 | self.connection.send.has_been_called_with( |
|
| 49 | '<get_info type="DFN_CERT_ADV"/>' |
|
| 50 | ) |
|
| 51 | ||
| 52 | self.gmp.get_info_list(InfoType.OVALDEF) |
|
| 53 | ||
| 54 | self.connection.send.has_been_called_with('<get_info type="OVALDEF"/>') |
|
| 55 | ||
| 56 | self.gmp.get_info_list(InfoType.NVT) |
|
| 57 | ||
| 58 | self.connection.send.has_been_called_with('<get_info type="NVT"/>') |
|
| 59 | ||
| 60 | with self.assertRaises(AttributeError): |
|
| 61 | self.gmp.get_info_list( |
|
| 62 | InfoType.ALLINFO # pylint: disable=no-member |
|
| 63 | ) |
|
| 64 | ||
| 65 | def test_get_info_list_missing_info_type(self): |
|
| 66 | with self.assertRaises(RequiredArgument): |
|
| 67 | self.gmp.get_info_list(info_type=None) |
|
| 68 | ||
| 69 | with self.assertRaises(RequiredArgument): |
|
| 70 | self.gmp.get_info_list(info_type='') |
|
| 71 | ||
| 72 | with self.assertRaises(RequiredArgument): |
|
| 73 | self.gmp.get_info_list('') |
|
| 74 | ||
| 75 | def test_get_info_list_invalid_info_type(self): |
|
| 76 | with self.assertRaises(InvalidArgumentType): |
|
| 77 | self.gmp.get_info_list(info_type='foo') |
|
| 78 | ||
| 79 | def test_get_info_list_with_filter(self): |
|
| 80 | self.gmp.get_info_list(InfoType.CPE, filter='foo=bar') |
|
| 81 | ||
| 82 | self.connection.send.has_been_called_with( |
|
| 83 | '<get_info type="CPE" filter="foo=bar"/>' |
|
| 84 | ) |
|
| 85 | ||
| 86 | def test_get_info_list_with_filter_id(self): |
|
| 87 | self.gmp.get_info_list(info_type=InfoType.CPE, filter_id='f1') |
|
| 88 | ||
| 89 | self.connection.send.has_been_called_with( |
|
| 90 | '<get_info type="CPE" filt_id="f1"/>' |
|
| 91 | ) |
|
| 92 | ||
| 93 | def test_get_info_list_with_name(self): |
|
| 94 | self.gmp.get_info_list(info_type=InfoType.CPE, name='foo') |
|
| 95 | ||
| 96 | self.connection.send.has_been_called_with( |
|
| 97 | '<get_info type="CPE" name="foo"/>' |
|
| 98 | ) |
|
| 99 | ||
| 100 | def test_get_info_list_with_details(self): |
|
| 101 | self.gmp.get_info_list(info_type=InfoType.CPE, details=True) |
|
| 102 | ||
| 103 | self.connection.send.has_been_called_with( |
|
| 104 | '<get_info type="CPE" details="1"/>' |
|
| 105 | ) |
|
| 106 | ||
| 107 | self.gmp.get_info_list(info_type=InfoType.CPE, details=False) |
|
| 108 | ||
| 109 | self.connection.send.has_been_called_with( |
|
| 110 | '<get_info type="CPE" details="0"/>' |
|
| 111 | ) |
|
| 112 | ||
| 113 | ||
| @@ 26-109 (lines=84) @@ | ||
| 23 | from gvm.protocols.gmpv7 import InfoType |
|
| 24 | ||
| 25 | ||
| 26 | class GmpGetInfoListTestCase: |
|
| 27 | def test_get_info_list(self): |
|
| 28 | self.gmp.get_info_list(InfoType.CERT_BUND_ADV) |
|
| 29 | ||
| 30 | self.connection.send.has_been_called_with( |
|
| 31 | '<get_info type="CERT_BUND_ADV"/>' |
|
| 32 | ) |
|
| 33 | ||
| 34 | self.gmp.get_info_list(InfoType.CPE) |
|
| 35 | ||
| 36 | self.connection.send.has_been_called_with('<get_info type="CPE"/>') |
|
| 37 | ||
| 38 | self.gmp.get_info_list(info_type=InfoType.CPE) |
|
| 39 | ||
| 40 | self.connection.send.has_been_called_with('<get_info type="CPE"/>') |
|
| 41 | ||
| 42 | self.gmp.get_info_list(InfoType.CVE) |
|
| 43 | ||
| 44 | self.connection.send.has_been_called_with('<get_info type="CVE"/>') |
|
| 45 | ||
| 46 | self.gmp.get_info_list(InfoType.DFN_CERT_ADV) |
|
| 47 | ||
| 48 | self.connection.send.has_been_called_with( |
|
| 49 | '<get_info type="DFN_CERT_ADV"/>' |
|
| 50 | ) |
|
| 51 | ||
| 52 | self.gmp.get_info_list(InfoType.OVALDEF) |
|
| 53 | ||
| 54 | self.connection.send.has_been_called_with('<get_info type="OVALDEF"/>') |
|
| 55 | ||
| 56 | self.gmp.get_info_list(InfoType.NVT) |
|
| 57 | ||
| 58 | self.connection.send.has_been_called_with('<get_info type="NVT"/>') |
|
| 59 | ||
| 60 | self.gmp.get_info_list(InfoType.ALLINFO) |
|
| 61 | ||
| 62 | self.connection.send.has_been_called_with('<get_info type="ALLINFO"/>') |
|
| 63 | ||
| 64 | def test_get_info_list_missing_info_type(self): |
|
| 65 | with self.assertRaises(RequiredArgument): |
|
| 66 | self.gmp.get_info_list(info_type=None) |
|
| 67 | ||
| 68 | with self.assertRaises(RequiredArgument): |
|
| 69 | self.gmp.get_info_list(info_type='') |
|
| 70 | ||
| 71 | with self.assertRaises(RequiredArgument): |
|
| 72 | self.gmp.get_info_list('') |
|
| 73 | ||
| 74 | def test_get_info_list_invalid_info_type(self): |
|
| 75 | with self.assertRaises(InvalidArgumentType): |
|
| 76 | self.gmp.get_info_list(info_type='foo') |
|
| 77 | ||
| 78 | def test_get_info_list_with_filter(self): |
|
| 79 | self.gmp.get_info_list(InfoType.CPE, filter='foo=bar') |
|
| 80 | ||
| 81 | self.connection.send.has_been_called_with( |
|
| 82 | '<get_info type="CPE" filter="foo=bar"/>' |
|
| 83 | ) |
|
| 84 | ||
| 85 | def test_get_info_list_with_filter_id(self): |
|
| 86 | self.gmp.get_info_list(info_type=InfoType.CPE, filter_id='f1') |
|
| 87 | ||
| 88 | self.connection.send.has_been_called_with( |
|
| 89 | '<get_info type="CPE" filt_id="f1"/>' |
|
| 90 | ) |
|
| 91 | ||
| 92 | def test_get_info_list_with_name(self): |
|
| 93 | self.gmp.get_info_list(info_type=InfoType.CPE, name='foo') |
|
| 94 | ||
| 95 | self.connection.send.has_been_called_with( |
|
| 96 | '<get_info type="CPE" name="foo"/>' |
|
| 97 | ) |
|
| 98 | ||
| 99 | def test_get_info_list_with_details(self): |
|
| 100 | self.gmp.get_info_list(info_type=InfoType.CPE, details=True) |
|
| 101 | ||
| 102 | self.connection.send.has_been_called_with( |
|
| 103 | '<get_info type="CPE" details="1"/>' |
|
| 104 | ) |
|
| 105 | ||
| 106 | self.gmp.get_info_list(info_type=InfoType.CPE, details=False) |
|
| 107 | ||
| 108 | self.connection.send.has_been_called_with( |
|
| 109 | '<get_info type="CPE" details="0"/>' |
|
| 110 | ) |
|
| 111 | ||
| 112 | ||