ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: подтверждение файловых загрузок через внутренний storage

This commit is contained in:
DCCONSTRUCTIONS
2026-04-27 13:47:03 +03:00
parent 490aa1bc04
commit 3e328531ec
3 changed files with 64 additions and 7 deletions
@@ -204,3 +204,49 @@ class TestS3StorageSignedURLExpiration:
mock_s3_client.generate_presigned_url.assert_called_once()
call_kwargs = mock_s3_client.generate_presigned_url.call_args[1]
assert call_kwargs["ExpiresIn"] == 120
@patch.dict(
os.environ,
{
"AWS_ACCESS_KEY_ID": "test-key",
"AWS_SECRET_ACCESS_KEY": "test-secret",
"AWS_S3_BUCKET_NAME": "test-bucket",
"AWS_REGION": "us-east-1",
"AWS_S3_ENDPOINT_URL": "http://plane-minio:9000",
"USE_MINIO": "1",
},
clear=True,
)
@patch("plane.settings.storage.boto3")
def test_minio_request_uses_request_host_for_browser_urls(self, mock_boto3):
"""Test that browser-facing MinIO URLs keep using the request host"""
request = Mock(scheme="http")
request.get_host.return_value = "localhost:8090"
S3Storage(request=request)
call_kwargs = mock_boto3.client.call_args[1]
assert call_kwargs["endpoint_url"] == "http://localhost:8090"
@patch.dict(
os.environ,
{
"AWS_ACCESS_KEY_ID": "test-key",
"AWS_SECRET_ACCESS_KEY": "test-secret",
"AWS_S3_BUCKET_NAME": "test-bucket",
"AWS_REGION": "us-east-1",
"AWS_S3_ENDPOINT_URL": "http://plane-minio:9000",
"USE_MINIO": "1",
},
clear=True,
)
@patch("plane.settings.storage.boto3")
def test_minio_server_mode_uses_internal_endpoint_with_request(self, mock_boto3):
"""Test that server-side MinIO operations use the internal endpoint"""
request = Mock(scheme="http")
request.get_host.return_value = "localhost:8090"
S3Storage(request=request, is_server=True)
call_kwargs = mock_boto3.client.call_args[1]
assert call_kwargs["endpoint_url"] == "http://plane-minio:9000"