| @@ 159-184 (lines=26) @@ | ||
| 156 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 157 | ) |
|
| 158 | ||
| 159 | def test_get_vts_filter_negative(self): |
|
| 160 | daemon = DummyWrapper([]) |
|
| 161 | daemon.add_vt( |
|
| 162 | '1.2.3.4', |
|
| 163 | 'A vulnerability test', |
|
| 164 | vt_params="a", |
|
| 165 | vt_modification_time='19000202', |
|
| 166 | ) |
|
| 167 | ||
| 168 | response = secET.fromstring( |
|
| 169 | daemon.handle_command( |
|
| 170 | '<get_vts filter="modification_time<19000203"></get_vts>' |
|
| 171 | ) |
|
| 172 | ) |
|
| 173 | self.assertEqual(response.get('status'), '200') |
|
| 174 | ||
| 175 | vts = response.find('vts') |
|
| 176 | ||
| 177 | vt = vts.find('vt') |
|
| 178 | self.assertIsNotNone(vt) |
|
| 179 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 180 | ||
| 181 | modification_time = response.findall('vts/vt/modification_time') |
|
| 182 | self.assertEqual( |
|
| 183 | '<modification_time>19000202</modification_time>', |
|
| 184 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 185 | ) |
|
| 186 | ||
| 187 | def test_get_vtss_multiple_vts(self): |
|
| @@ 131-156 (lines=26) @@ | ||
| 128 | vt = vts.find('vt') |
|
| 129 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 130 | ||
| 131 | def test_get_vts_filter_positive(self): |
|
| 132 | daemon = DummyWrapper([]) |
|
| 133 | daemon.add_vt( |
|
| 134 | '1.2.3.4', |
|
| 135 | 'A vulnerability test', |
|
| 136 | vt_params="a", |
|
| 137 | vt_modification_time='19000202', |
|
| 138 | ) |
|
| 139 | ||
| 140 | response = secET.fromstring( |
|
| 141 | daemon.handle_command( |
|
| 142 | '<get_vts filter="modification_time>19000201"></get_vts>' |
|
| 143 | ) |
|
| 144 | ) |
|
| 145 | ||
| 146 | self.assertEqual(response.get('status'), '200') |
|
| 147 | vts = response.find('vts') |
|
| 148 | ||
| 149 | vt = vts.find('vt') |
|
| 150 | self.assertIsNotNone(vt) |
|
| 151 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 152 | ||
| 153 | modification_time = response.findall('vts/vt/modification_time') |
|
| 154 | self.assertEqual( |
|
| 155 | '<modification_time>19000202</modification_time>', |
|
| 156 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 157 | ) |
|
| 158 | ||
| 159 | def test_get_vts_filter_negative(self): |
|