예제 #1
0
    def get_dummy_file(self, filename=None, content_type=None, content=None):

        if filename is None:
            filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

        if content_type is None:
            content_type = 'application/octet'

        if content is None:
            content = "ANTANI"

        temporary_file = GLSecureTemporaryFile(GLSetting.tmp_upload_path)

        temporary_file.write(content)
        temporary_file.avoid_delete()

        dummy_file = {
            'body': temporary_file,
            'body_len': len(content),
            'body_filepath': temporary_file.filepath,
            'filename': filename,
            'content_type': content_type,
        }

        return dummy_file
예제 #2
0
    def get_dummy_file(self, filename=None, content_type=None, content=None):

        if filename is None:
            filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

        if content_type is None:
            content_type = 'application/octet'

        if content is None:
            content = "ANTANI"

        temporary_file = GLSecureTemporaryFile(GLSetting.tmp_upload_path)

        temporary_file.write(content)
        temporary_file.avoid_delete()

        dummy_file = {
            'body': temporary_file,
            'body_len': len(content),
            'body_filepath': temporary_file.filepath,
            'filename': filename,
            'content_type': content_type,
        }

        return dummy_file
예제 #3
0
    def get_dummy_file(self, filename=None, content_type=None, content=None):
        if filename is None:
            filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

        if content_type is None:
            content_type = 'application/octet'

        if content is None:
            content = 'LA VEDI LA SUPERCAZZOLA ? PREMATURA ? unicode €'

        temporary_file = GLSecureTemporaryFile(GLSettings.tmp_upload_path)

        temporary_file.write(content)
        temporary_file.avoid_delete()

        dummy_file = {
            'body': temporary_file,
            'body_len': len(content),
            'body_filepath': temporary_file.filepath,
            'filename': filename,
            'content_type': content_type,
            'submission': False
        }

        return dummy_file
예제 #4
0
 def test_004_temporary_file_lost_key_due_to_eventual_bug_or_reboot(self):
     a = GLSecureTemporaryFile(GLSetting.tmp_upload_path)
     a.avoid_delete()
     antani = "0123456789" * 10000
     a.write(antani)
     a.close()
     self.assertTrue(os.path.exists(a.filepath))
     os.remove(a.keypath)
     self.assertRaises(IOError, GLSecureFile, a.filepath)
예제 #5
0
 def test_003_temporary_file_avoid_delete(self):
     a = GLSecureTemporaryFile(GLSetting.tmp_upload_path)
     a.avoid_delete()
     antani = "0123456789" * 10000
     a.write(antani)
     a.close()
     self.assertTrue(os.path.exists(a.filepath))
     b = GLSecureFile(a.filepath)
     self.assertTrue(antani == b.read())
예제 #6
0
def get_dummy_file(filename=None, content_type=None, content=None):
    filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

    content_type = 'application/octet'

    content = ''.join(unichr(x) for x in range(0x400, 0x40A))

    temporary_file = GLSecureTemporaryFile(GLSettings.tmp_upload_path)

    temporary_file.write(content)
    temporary_file.avoid_delete()

    return {
        'body': temporary_file,
        'body_len': len(content),
        'body_filepath': temporary_file.filepath,
        'filename': filename,
        'content_type': content_type,
        'submission': False
    }
예제 #7
0
파일: helpers.py 프로젝트: Taipo/GlobaLeaks
def get_dummy_file(filename=None, content_type=None, content=None):
    filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

    content_type = 'application/octet'

    content = ''.join(unichr(x) for x in range(0x400, 0x40A))

    temporary_file = GLSecureTemporaryFile(GLSettings.tmp_upload_path)

    temporary_file.write(content)
    temporary_file.avoid_delete()

    return {
        'body': temporary_file,
        'body_len': len(content),
        'body_filepath': temporary_file.filepath,
        'filename': filename,
        'content_type': content_type,
        'submission': False
    }
예제 #8
0
    def test_post(self):

        temporary_file = GLSecureTemporaryFile(GLSetting.tmp_upload_path)
        temporary_file.write("ANTANI")
        temporary_file.avoid_delete()

        request_body = {
            'body': temporary_file,
            'body_len': len("ANTANI"),
            'body_filepath': temporary_file.filepath,
            'filename': 'en.json',
            'content_type': 'application/json'
        }

        handler = self.request({}, role='admin', kwargs={'path': GLSetting.static_path}, body=request_body)

        yield handler.post(lang='en')

        self.assertTrue(isinstance(self.responses, list))
        self.assertEqual(len(self.responses), 1)
        self._handler.validate_message(json.dumps(self.responses[0]), requests.staticFile)
예제 #9
0
def get_dummy_file(filename=None, content_type=None, content=None):
    global files_count
    files_count += 1
    filename = ''.join(unichr(x) for x in range(0x400, 0x40A)).join('-%d' % files_count)

    content_type = 'application/octet'

    content = ''.join(unichr(x) for x in range(0x400, 0x40A))

    temporary_file = GLSecureTemporaryFile(GLSettings.tmp_upload_path)

    temporary_file.write(content)
    temporary_file.avoid_delete()

    return {
        'name': filename,
        'description': 'description',
        'body': temporary_file,
        'size': len(content),
        'path': temporary_file.filepath,
        'type': content_type,
        'submission': False
    }
예제 #10
0
def get_dummy_file(filename=None, content_type=None, content=None):
    global files_count
    files_count += 1
    filename = ''.join(unichr(x) for x in range(0x400, 0x40A)).join('-%d' % files_count)

    content_type = 'application/octet'

    content = ''.join(unichr(x) for x in range(0x400, 0x40A))

    temporary_file = GLSecureTemporaryFile(GLSettings.tmp_upload_path)

    temporary_file.write(content)
    temporary_file.avoid_delete()

    return {
        'name': filename,
        'description': 'description',
        'body': temporary_file,
        'size': len(content),
        'path': temporary_file.filepath,
        'type': content_type,
        'submission': False
    }