-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Cache folder configuration for Azure and AWS Image Caches (Lombiq Technologies: OCORE-136) #353
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
98a43eb
Adding CacheFolder config to AzureBlobStorageCache
Piedone 5ff144c
Grammar
Piedone 40b5b8c
Adding CacheFolder config to AWSS3StorageCache
Piedone 9db0e6b
Code styling
Piedone 408610b
DRY
Piedone dbcae3a
Adding Azure CacheFolder tests
Piedone e41bc2a
Adding AWS tests
Piedone ff7fdc4
The CacheFolder properties should actually be nullabe
Piedone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/ImageSharp.Web.Tests/Processing/AWSS3StorageCacheCacheFolderServerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/ImageSharp.Web.Tests/Processing/AzureBlobStorageCacheCacheFolderServerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 AzureBlobStorageCacheCacheFolderServerTests : ServerTestBase<AzureBlobStorageCacheCacheFolderTestServerFixture> | ||
{ | ||
public AzureBlobStorageCacheCacheFolderServerTests(AzureBlobStorageCacheCacheFolderTestServerFixture fixture, ITestOutputHelper outputHelper) | ||
: base(fixture, outputHelper, TestConstants.AzureTestImage) | ||
{ | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageCacheCacheFolderTestServerFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} |
33 changes: 33 additions & 0 deletions
33
...s/ImageSharp.Web.Tests/TestUtilities/AzureBlobStorageCacheCacheFolderTestServerFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using Azure.Storage.Blobs.Models; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using SixLabors.ImageSharp.Web.Caching.Azure; | ||
using SixLabors.ImageSharp.Web.DependencyInjection; | ||
using SixLabors.ImageSharp.Web.Providers.Azure; | ||
|
||
namespace SixLabors.ImageSharp.Web.Tests.TestUtilities; | ||
|
||
public class AzureBlobStorageCacheCacheFolderTestServerFixture : TestServerFixture | ||
{ | ||
protected override void ConfigureCustomServices(IServiceCollection services, IImageSharpBuilder builder) | ||
=> builder | ||
.Configure<AzureBlobStorageImageProviderOptions>(o => | ||
o.BlobContainers.Add( | ||
new AzureBlobContainerClientOptions | ||
{ | ||
ConnectionString = TestConstants.AzureConnectionString, | ||
ContainerName = TestConstants.AzureContainerName | ||
})) | ||
.AddProvider(AzureBlobStorageImageProviderFactory.Create) | ||
.Configure<AzureBlobStorageCacheOptions>(o => | ||
{ | ||
o.ConnectionString = TestConstants.AzureConnectionString; | ||
o.ContainerName = TestConstants.AzureCacheContainerName; | ||
o.CacheFolder = TestConstants.AzureCacheFolder; | ||
|
||
AzureBlobStorageCache.CreateIfNotExists(o, PublicAccessType.None); | ||
}) | ||
.SetCache<AzureBlobStorageCache>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I DRY this into a helper class, not to copy it between the two cache implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave as is and keep them separate. They're two separate assemblies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then.