Skip to content

Commit e41bc2a

Browse files
committed
Adding AWS tests
1 parent dbcae3a commit e41bc2a

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
using SixLabors.ImageSharp.Web.Tests.TestUtilities;
5+
using Xunit.Abstractions;
6+
7+
namespace SixLabors.ImageSharp.Web.Tests.Processing;
8+
9+
public class AWSS3StorageCacheCacheFolderServerTests : ServerTestBase<AWSS3StorageCacheCacheFolderTestServerFixture>
10+
{
11+
public AWSS3StorageCacheCacheFolderServerTests(AWSS3StorageCacheCacheFolderTestServerFixture fixture, ITestOutputHelper outputHelper)
12+
: base(fixture, outputHelper, TestConstants.AWSTestImage)
13+
{
14+
}
15+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
using Amazon.S3;
5+
using Microsoft.Extensions.DependencyInjection;
6+
using SixLabors.ImageSharp.Web.Caching.AWS;
7+
using SixLabors.ImageSharp.Web.DependencyInjection;
8+
using SixLabors.ImageSharp.Web.Providers.AWS;
9+
10+
namespace SixLabors.ImageSharp.Web.Tests.TestUtilities;
11+
12+
public class AWSS3StorageCacheCacheFolderTestServerFixture : TestServerFixture
13+
{
14+
protected override void ConfigureCustomServices(IServiceCollection services, IImageSharpBuilder builder)
15+
=> builder
16+
.Configure<AWSS3StorageImageProviderOptions>(o =>
17+
o.S3Buckets.Add(
18+
new AWSS3BucketClientOptions
19+
{
20+
Endpoint = TestConstants.AWSEndpoint,
21+
BucketName = TestConstants.AWSBucketName,
22+
AccessKey = TestConstants.AWSAccessKey,
23+
AccessSecret = TestConstants.AWSAccessSecret,
24+
Region = TestConstants.AWSRegion,
25+
Timeout = TestConstants.AWSTimeout,
26+
}))
27+
.AddProvider(AWSS3StorageImageProviderFactory.Create)
28+
.Configure<AWSS3StorageCacheOptions>(o =>
29+
{
30+
o.Endpoint = TestConstants.AWSEndpoint;
31+
o.BucketName = TestConstants.AWSCacheBucketName;
32+
o.AccessKey = TestConstants.AWSAccessKey;
33+
o.AccessSecret = TestConstants.AWSAccessSecret;
34+
o.Region = TestConstants.AWSRegion;
35+
o.Timeout = TestConstants.AWSTimeout;
36+
o.CacheFolder = TestConstants.AWSCacheFolder;
37+
38+
AWSS3StorageCache.CreateIfNotExists(o, S3CannedACL.Private);
39+
})
40+
.SetCache<AWSS3StorageCache>();
41+
}

tests/ImageSharp.Web.Tests/TestUtilities/TestConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static class TestConstants
1515
public const string AWSCacheBucketName = "aws-cache";
1616
public const string AWSAccessKey = "";
1717
public const string AWSAccessSecret = "";
18+
public const string AWSCacheFolder = "cache/folder";
1819
public const string ImagePath = "SubFolder/sîxläbörs.îmägéshärp.wéb.png";
1920
public const string PhysicalTestImage = "http://localhost/" + ImagePath;
2021
public const string AzureTestImage = "http://localhost/" + AzureContainerName + "/" + ImagePath;

0 commit comments

Comments
 (0)