Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues #70

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion faassupervisor/storage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def upload_output(self, output_dir_path):
provider_type = StrUtils.get_storage_type(output['storage_provider'])
provider_id = StrUtils.get_storage_id(output['storage_provider'])
for file_path in output_files:
file_name = file_path.replace(f'{output_dir_path}/', '')
# Make sure the file name does not contain new lines or starting slashes
file_name = file_path.replace(f'{output_dir_path}/', '').strip().lstrip('/')
prefix_ok = False
suffix_ok = False
# Check prefixes
Expand Down
4 changes: 2 additions & 2 deletions faassupervisor/storage/providers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
related with the S3 storage provider. """

import boto3
from requests.packages import urllib3
import urllib3
from faassupervisor.logger import get_logger
from faassupervisor.storage.providers import DefaultStorageProvider, \
get_bucket_name, get_file_key
from faassupervisor.utils import SysUtils

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

class S3(DefaultStorageProvider):
"""Class that manages downloads and uploads from S3."""
Expand Down
9 changes: 6 additions & 3 deletions test/unit/faassupervisor/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ def test_upload_output(self, mock_minio, mock_s3, mock_get_files):
'/tmp/test/result-file.txt',
'/tmp/test/result-file.out',
'/tmp/test/file2.txt',
'/tmp/test/file2.out'
'/tmp/test/file2.out',
'/tmp/test/\n/file3.out'
]
mock_get_files.return_value = files
StorageConfig().upload_output('/tmp/test')
Expand All @@ -268,10 +269,12 @@ def test_upload_output(self, mock_minio, mock_s3, mock_get_files):
call('/tmp/test/result-file.txt',
'result-file.txt',
'bucket'))
self.assertEqual(mock_s3.call_count, 6)
for i, f in enumerate(files):
self.assertEqual(mock_s3.call_count, 7)
for i, f in enumerate(files[:-1]):
self.assertEqual(mock_s3.call_args_list[i],
call(f, f.split('/')[3], 'bucket/folder'))
self.assertEqual(mock_s3.call_args_list[6],
call('/tmp/test/\n/file3.out', 'file3.out', 'bucket/folder'))

# def test_upload_real_output(self):
# with mock.patch.dict('os.environ',
Expand Down
Loading