| @@ 194-219 (lines=26) @@ | ||
| 191 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 192 | ) |
|
| 193 | ||
| 194 | def test_get_vts_filter_negative(self): |
|
| 195 | daemon = DummyWrapper([]) |
|
| 196 | daemon.add_vt( |
|
| 197 | '1.2.3.4', |
|
| 198 | 'A vulnerability test', |
|
| 199 | vt_params="a", |
|
| 200 | vt_modification_time='19000202', |
|
| 201 | ) |
|
| 202 | fs = FakeStream() |
|
| 203 | daemon.handle_command( |
|
| 204 | '<get_vts filter="modification_time<19000203"></get_vts>', fs, |
|
| 205 | ) |
|
| 206 | response = fs.get_response() |
|
| 207 | ||
| 208 | self.assertEqual(response.get('status'), '200') |
|
| 209 | ||
| 210 | vts = response.find('vts') |
|
| 211 | ||
| 212 | vt = vts.find('vt') |
|
| 213 | self.assertIsNotNone(vt) |
|
| 214 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 215 | ||
| 216 | modification_time = response.findall('vts/vt/modification_time') |
|
| 217 | self.assertEqual( |
|
| 218 | '<modification_time>19000202</modification_time>', |
|
| 219 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 220 | ) |
|
| 221 | ||
| 222 | def test_get_vts_bad_filter(self): |
|
| @@ 166-191 (lines=26) @@ | ||
| 163 | ||
| 164 | self.assertEqual(response.get('status'), '200') |
|
| 165 | ||
| 166 | def test_get_vts_filter_positive(self): |
|
| 167 | daemon = DummyWrapper([]) |
|
| 168 | daemon.add_vt( |
|
| 169 | '1.2.3.4', |
|
| 170 | 'A vulnerability test', |
|
| 171 | vt_params="a", |
|
| 172 | vt_modification_time='19000202', |
|
| 173 | ) |
|
| 174 | fs = FakeStream() |
|
| 175 | ||
| 176 | daemon.handle_command( |
|
| 177 | '<get_vts filter="modification_time>19000201"></get_vts>', fs |
|
| 178 | ) |
|
| 179 | response = fs.get_response() |
|
| 180 | ||
| 181 | self.assertEqual(response.get('status'), '200') |
|
| 182 | vts = response.find('vts') |
|
| 183 | ||
| 184 | vt = vts.find('vt') |
|
| 185 | self.assertIsNotNone(vt) |
|
| 186 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 187 | ||
| 188 | modification_time = response.findall('vts/vt/modification_time') |
|
| 189 | self.assertEqual( |
|
| 190 | '<modification_time>19000202</modification_time>', |
|
| 191 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 192 | ) |
|
| 193 | ||
| 194 | def test_get_vts_filter_negative(self): |
|