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