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