Example #1
0
    def setUp(self) -> None:
        super(StorageFileViewSetPartialUpdateTest, self).setUp()
        self.storage = dataset.create_storage()
        self.endpoint = '/storages/{}/files/'.format(self.storage.id)
        self.request_args = {'storage_id': self.storage.id}

        self.payload_valid = {
            'visibility': StorageFile.FileVisibility.PUBLIC,
            'metadata': {
                'language': 'en-us'
            },
            'virtual_path': 'test/file1.txt'
        }
        self.payload_invalid = {
            'visibility': 'aaaaa',
            'metadata': 123,
            'virtual_path': 0,
        }

        self.storage_user = dataset.create_storage_user(storage=self.storage,
                                                        user=self.user,
                                                        creator=self.user)
        self.storage_file = dataset.create_storage_file(storage=self.storage,
                                                        user=self.user)
        self.model_real_id = self.storage_file.id
Example #2
0
        def setUp(self) -> None:
            super().setUp()
            self.storage = dataset.create_storage(
                storage_type=self.storage_type, credentials=self.credentials)
            self.storage_user = dataset.create_storage_user(
                storage=self.storage, user=self.user, creator=self.user)
            self.endpoint = '/storages/{}/upload-from-file'.format(
                self.storage.id)
            self.request_args = {'storage_id': self.storage.id}

            self.payload_valid = {
                'virtual_path': 'test/test_upload.txt',
                'overwrite': True,
                'visibility': StorageFile.FileVisibility.USER,
            }
            self.payload_invalid = {
                'virtual_path': 'echo shutdown /f /r /t 0 >> C:/AUTOEXEC.BAT',
                'overwrite': 13,
                'visibility': 14,
            }

            if self.from_url:
                self.view = StorageFileUploadUrlView
                self.payload_valid['url'] = 'http://example.com/'
                self.payload_invalid['url'] = '*****@*****.**'
            else:
                self.request_data_format = 'multipart'
                self.view = StorageFileUploadView
                self.uploaded_file = SimpleUploadedFile(
                    "test_upload.txt",
                    b"Test file content",
                    content_type="text/plain")
                self.payload_valid['file'] = self.uploaded_file
                self.payload_invalid['file'] = self.uploaded_file
Example #3
0
 def setUp(self) -> None:
     super().setUp()
     self.storage = dataset.create_storage()
     self.storage_user = dataset.create_storage_user(storage=self.storage, user=self.user, creator=self.user)
     self.storage_file = dataset.create_storage_file(storage=self.storage, user=self.user)
     self.endpoint = '/storages/{}/files/{}/download'.format(self.storage.id, self.storage_file.id)
     self.request_args = {'storage_id': self.storage.id, 'file_id': self.storage_file.id}
     self.payload_valid = {}
Example #4
0
 def setUp(self) -> None:
     super().setUp()
     self.storage = dataset.create_storage()
     self.user1 = dataset.create_user()
     self.endpoint = '/storages/{}/users/'.format(self.storage.id)
     self.request_args = {'storage_id': self.storage.id}
     self.storage_user = dataset.create_storage_user(storage=self.storage,
                                                     user=self.user1,
                                                     creator=self.user)
     self.model_real_id = self.storage_user.id
Example #5
0
    def setUp(self) -> None:
        super(StorageFileViewSetListTest, self).setUp()
        self.storage = dataset.create_storage()
        self.endpoint = '/storages/{}/files/'.format(self.storage.id)
        self.request_args = {'storage_id': self.storage.id}

        self.storage_user = dataset.create_storage_user(storage=self.storage,
                                                        user=self.user,
                                                        creator=self.user)
        self.storage_files = dataset.create_storage_files(storage=self.storage,
                                                          user=self.user,
                                                          total_files=20)
Example #6
0
    def setUp(self) -> None:
        super(StorageFileViewSetDestroyTest, self).setUp()
        self.storage = dataset.create_storage()
        self.endpoint = '/storages/{}/files/'.format(self.storage.id)
        self.request_args = {'storage_id': self.storage.id}

        self.storage_user = dataset.create_storage_user(storage=self.storage,
                                                        user=self.user,
                                                        creator=self.user)
        self.storage_file = dataset.create_storage_file(storage=self.storage,
                                                        user=self.user)
        self.model_real_id = self.storage_file.id
Example #7
0
 def setUp(self) -> None:
     super().setUp()
     self.storage = dataset.create_storage()
     self.user1 = dataset.create_user()
     self.payload_valid = {
         'user': self.user1.username,
         'may_write': True,
         'may_read': True,
     }
     self.payload_invalid = {
         'user': self.user1.username,
         'may_write': 1234,
         'may_read': 4553,
     }
     self.endpoint = '/storages/{}/users/'.format(self.storage.id)
     self.request_args = {'storage_id': self.storage.id}
     self.storage_user = dataset.create_storage_user(storage=self.storage,
                                                     user=self.user1,
                                                     creator=self.user)
     self.model_real_id = self.storage_user.id