| @@ 232-256 (lines=25) @@ | ||
| 229 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 230 | ) |
|
| 231 | ||
| 232 | def test_get_vts_filter_negative(self): |
|
| 233 | self.daemon.add_vt( |
|
| 234 | '1.2.3.4', |
|
| 235 | 'A vulnerability test', |
|
| 236 | vt_params="a", |
|
| 237 | vt_modification_time='19000202', |
|
| 238 | ) |
|
| 239 | fs = FakeStream() |
|
| 240 | self.daemon.handle_command( |
|
| 241 | '<get_vts filter="modification_time<19000203"></get_vts>', fs, |
|
| 242 | ) |
|
| 243 | response = fs.get_response() |
|
| 244 | ||
| 245 | self.assertEqual(response.get('status'), '200') |
|
| 246 | ||
| 247 | vts = response.find('vts') |
|
| 248 | ||
| 249 | vt = vts.find('vt') |
|
| 250 | self.assertIsNotNone(vt) |
|
| 251 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 252 | ||
| 253 | modification_time = response.findall('vts/vt/modification_time') |
|
| 254 | self.assertEqual( |
|
| 255 | '<modification_time>19000202</modification_time>', |
|
| 256 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 257 | ) |
|
| 258 | ||
| 259 | def test_get_vts_bad_filter(self): |
|
| @@ 205-229 (lines=25) @@ | ||
| 202 | ||
| 203 | self.assertEqual(response.get('status'), '200') |
|
| 204 | ||
| 205 | def test_get_vts_filter_positive(self): |
|
| 206 | self.daemon.add_vt( |
|
| 207 | '1.2.3.4', |
|
| 208 | 'A vulnerability test', |
|
| 209 | vt_params="a", |
|
| 210 | vt_modification_time='19000202', |
|
| 211 | ) |
|
| 212 | fs = FakeStream() |
|
| 213 | ||
| 214 | self.daemon.handle_command( |
|
| 215 | '<get_vts filter="modification_time>19000201"></get_vts>', fs |
|
| 216 | ) |
|
| 217 | response = fs.get_response() |
|
| 218 | ||
| 219 | self.assertEqual(response.get('status'), '200') |
|
| 220 | vts = response.find('vts') |
|
| 221 | ||
| 222 | vt = vts.find('vt') |
|
| 223 | self.assertIsNotNone(vt) |
|
| 224 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 225 | ||
| 226 | modification_time = response.findall('vts/vt/modification_time') |
|
| 227 | self.assertEqual( |
|
| 228 | '<modification_time>19000202</modification_time>', |
|
| 229 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 230 | ) |
|
| 231 | ||
| 232 | def test_get_vts_filter_negative(self): |
|