Skip to content

Commit

Permalink
Adding AWS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Piedone committed Jan 24, 2024
1 parent dbcae3a commit e41bc2a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using SixLabors.ImageSharp.Web.Tests.TestUtilities;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Web.Tests.Processing;

public class AWSS3StorageCacheCacheFolderServerTests : ServerTestBase<AWSS3StorageCacheCacheFolderTestServerFixture>
{
public AWSS3StorageCacheCacheFolderServerTests(AWSS3StorageCacheCacheFolderTestServerFixture fixture, ITestOutputHelper outputHelper)
: base(fixture, outputHelper, TestConstants.AWSTestImage)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using Amazon.S3;
using Microsoft.Extensions.DependencyInjection;
using SixLabors.ImageSharp.Web.Caching.AWS;
using SixLabors.ImageSharp.Web.DependencyInjection;
using SixLabors.ImageSharp.Web.Providers.AWS;

namespace SixLabors.ImageSharp.Web.Tests.TestUtilities;

public class AWSS3StorageCacheCacheFolderTestServerFixture : TestServerFixture
{
protected override void ConfigureCustomServices(IServiceCollection services, IImageSharpBuilder builder)
=> builder
.Configure<AWSS3StorageImageProviderOptions>(o =>
o.S3Buckets.Add(
new AWSS3BucketClientOptions
{
Endpoint = TestConstants.AWSEndpoint,
BucketName = TestConstants.AWSBucketName,
AccessKey = TestConstants.AWSAccessKey,
AccessSecret = TestConstants.AWSAccessSecret,
Region = TestConstants.AWSRegion,
Timeout = TestConstants.AWSTimeout,
}))
.AddProvider(AWSS3StorageImageProviderFactory.Create)
.Configure<AWSS3StorageCacheOptions>(o =>
{
o.Endpoint = TestConstants.AWSEndpoint;
o.BucketName = TestConstants.AWSCacheBucketName;
o.AccessKey = TestConstants.AWSAccessKey;
o.AccessSecret = TestConstants.AWSAccessSecret;
o.Region = TestConstants.AWSRegion;
o.Timeout = TestConstants.AWSTimeout;
o.CacheFolder = TestConstants.AWSCacheFolder;

AWSS3StorageCache.CreateIfNotExists(o, S3CannedACL.Private);
})
.SetCache<AWSS3StorageCache>();
}
1 change: 1 addition & 0 deletions tests/ImageSharp.Web.Tests/TestUtilities/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static class TestConstants
public const string AWSCacheBucketName = "aws-cache";
public const string AWSAccessKey = "";
public const string AWSAccessSecret = "";
public const string AWSCacheFolder = "cache/folder";
public const string ImagePath = "SubFolder/sîxläbörs.îmägéshärp.wéb.png";
public const string PhysicalTestImage = "http://localhost/" + ImagePath;
public const string AzureTestImage = "http://localhost/" + AzureContainerName + "/" + ImagePath;
Expand Down

0 comments on commit e41bc2a

Please sign in to comment.