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