(self)
| 165 | obj.execute('rm %s' % (remote_temp_path)) |
| 166 | |
| 167 | def test_upload_blind(self): |
| 168 | |
| 169 | obj, data = self._get_detection_obj_data( |
| 170 | self.url_blind % '', |
| 171 | technique = 'T' |
| 172 | ) |
| 173 | self.assertEqual(data, self.expected_data_blind) |
| 174 | |
| 175 | if not EXTRA_UPLOAD_BLIND: |
| 176 | return |
| 177 | |
| 178 | # Send file without --force-overwrite, should fail |
| 179 | remote_temp_path = '/tmp/tplmap_%s.tmp' % rand.randstr_n(10) |
| 180 | obj.write('AAAA', remote_temp_path) |
| 181 | self.assertFalse(os.path.exists(remote_temp_path)) |
| 182 | |
| 183 | # Now set --force-overwrite and retry |
| 184 | obj.channel.args['force_overwrite'] = True |
| 185 | |
| 186 | # Send long binary |
| 187 | data = open('/bin/ls', 'rb').read() |
| 188 | obj.write(data, remote_temp_path) |
| 189 | |
| 190 | # Since it's blind, read md5 from disk |
| 191 | checkdata = open(remote_temp_path, 'rb').read() |
| 192 | self.assertEqual(strings.md5(checkdata), strings.md5(data)) |
| 193 | os.unlink(remote_temp_path) |
| 194 | |
| 195 | remote_temp_path = '/tmp/tplmap_%s.tmp' % rand.randstr_n(10) |
| 196 | # Send short ASCII data |
| 197 | data = 'SHORT ASCII DATA' |
| 198 | obj.write(data, remote_temp_path) |
| 199 | |
| 200 | checkdata = open(remote_temp_path, 'rb').read() |
| 201 | self.assertEqual(strings.md5(checkdata), strings.md5(data)) |
| 202 | os.unlink(remote_temp_path) |
nothing calls this directly
no test coverage detected