diff --git a/framework/test/Volo.Abp.BlobStoring.Aws.Tests/Volo/Abp/BlobStoring/Aws/AwsBlobProviderConfiguration_Tests.cs b/framework/test/Volo.Abp.BlobStoring.Aws.Tests/Volo/Abp/BlobStoring/Aws/AwsBlobProviderConfiguration_Tests.cs new file mode 100644 index 0000000000..2e95ed8291 --- /dev/null +++ b/framework/test/Volo.Abp.BlobStoring.Aws.Tests/Volo/Abp/BlobStoring/Aws/AwsBlobProviderConfiguration_Tests.cs @@ -0,0 +1,52 @@ +using Shouldly; +using Xunit; + +namespace Volo.Abp.BlobStoring.Aws; + +public class AwsBlobProviderConfiguration_Tests : AbpBlobStoringAwsTestCommonBase +{ + [Fact] + public void Should_Set_And_Get_ServiceURL() + { + // Arrange + var containerConfiguration = new BlobContainerConfiguration(); + var awsConfiguration = new AwsBlobProviderConfiguration(containerConfiguration); + const string serviceUrl = "https://minio.example.com:9000"; + + // Act + awsConfiguration.ServiceURL = serviceUrl; + + // Assert + awsConfiguration.ServiceURL.ShouldBe(serviceUrl); + } + + [Fact] + public void Should_Return_Null_When_ServiceURL_Not_Set() + { + // Arrange + var containerConfiguration = new BlobContainerConfiguration(); + var awsConfiguration = new AwsBlobProviderConfiguration(containerConfiguration); + + // Act & Assert + awsConfiguration.ServiceURL.ShouldBeNull(); + } + + [Fact] + public void Should_Configure_ServiceURL_Using_UseAws_Extension() + { + // Arrange + var containerConfiguration = new BlobContainerConfiguration(); + const string serviceUrl = "https://spaces.digitalocean.com"; + + // Act + containerConfiguration.UseAws(config => + { + config.ServiceURL = serviceUrl; + config.Region = "us-east-1"; + }); + + // Assert + var awsConfig = containerConfiguration.GetAwsConfiguration(); + awsConfig.ServiceURL.ShouldBe(serviceUrl); + } +} \ No newline at end of file diff --git a/framework/test/Volo.Abp.BlobStoring.Aws.Tests/Volo/Abp/BlobStoring/Aws/DefaultAmazonS3ClientFactory_Tests.cs b/framework/test/Volo.Abp.BlobStoring.Aws.Tests/Volo/Abp/BlobStoring/Aws/DefaultAmazonS3ClientFactory_Tests.cs new file mode 100644 index 0000000000..cf5b973ee0 --- /dev/null +++ b/framework/test/Volo.Abp.BlobStoring.Aws.Tests/Volo/Abp/BlobStoring/Aws/DefaultAmazonS3ClientFactory_Tests.cs @@ -0,0 +1,64 @@ +using System.Threading.Tasks; +using Amazon.S3; +using Microsoft.Extensions.DependencyInjection; +using Shouldly; +using Xunit; + +namespace Volo.Abp.BlobStoring.Aws; + +public class DefaultAmazonS3ClientFactory_Tests : AbpBlobStoringAwsTestBase +{ + private readonly IAmazonS3ClientFactory _amazonS3ClientFactory; + + public DefaultAmazonS3ClientFactory_Tests() + { + _amazonS3ClientFactory = GetRequiredService(); + } + + [Fact] + public async Task Should_Create_S3Client_With_Custom_ServiceURL() + { + // Arrange + var containerConfiguration = new BlobContainerConfiguration(); + const string serviceUrl = "https://minio.example.com:9000"; + + var awsConfiguration = new AwsBlobProviderConfiguration(containerConfiguration) + { + AccessKeyId = "test-access-key", + SecretAccessKey = "test-secret-key", + Region = "us-east-1", + ServiceURL = serviceUrl + }; + + // Act + using var s3Client = await _amazonS3ClientFactory.GetAmazonS3Client(awsConfiguration); + + // Assert + s3Client.ShouldNotBeNull(); + s3Client.Config.ServiceURL.ShouldBe(serviceUrl + "/"); // AWS SDK automatically appends trailing slash + ((AmazonS3Config)s3Client.Config).ForcePathStyle.ShouldBeTrue(); // Should be enabled for S3-compatible services + } + + [Fact] + public async Task Should_Create_S3Client_Without_Custom_ServiceURL() + { + // Arrange + var containerConfiguration = new BlobContainerConfiguration(); + + var awsConfiguration = new AwsBlobProviderConfiguration(containerConfiguration) + { + AccessKeyId = "test-access-key", + SecretAccessKey = "test-secret-key", + Region = "us-east-1" + // ServiceURL not set + }; + + // Act + using var s3Client = await _amazonS3ClientFactory.GetAmazonS3Client(awsConfiguration); + + // Assert + s3Client.ShouldNotBeNull(); + s3Client.Config.ServiceURL.ShouldBeNull(); // Should use default AWS S3 service + ((AmazonS3Config)s3Client.Config).ForcePathStyle.ShouldBeFalse(); // Should be false for AWS S3 + } +} \ No newline at end of file