From 5100c36c06f6ef97e2ee468144b22a4a774c3712 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 22 Apr 2019 16:45:50 +0900 Subject: [PATCH] Uncomment google/amazon code, just disable it in the service registration --- BTCPayServer.Tests/StorageTests.cs | 34 +++++------ .../Controllers/ServerController.Storage.cs | 38 ++++++------ .../Storage/Models/StorageProvider.cs | 6 +- .../AmazonS3FileProviderService.cs | 54 ++++++++--------- .../GoogleCloudStorageFileProviderService.cs | 60 +++++++++---------- 5 files changed, 96 insertions(+), 96 deletions(-) diff --git a/BTCPayServer.Tests/StorageTests.cs b/BTCPayServer.Tests/StorageTests.cs index c20647228..f069e5757 100644 --- a/BTCPayServer.Tests/StorageTests.cs +++ b/BTCPayServer.Tests/StorageTests.cs @@ -57,23 +57,23 @@ namespace BTCPayServer.Tests Assert.Equal(nameof(ServerController.StorageProvider), localResult.ActionName); Assert.Equal(StorageProvider.FileSystem.ToString(), localResult.RouteValues["provider"]); -// -// var AmazonS3result = Assert -// .IsType(controller.Storage(new StorageSettings() -// { -// Provider = StorageProvider.AmazonS3 -// })); -// Assert.Equal(nameof(ServerController.StorageProvider), AmazonS3result.ActionName); -// Assert.Equal(StorageProvider.AmazonS3.ToString(), AmazonS3result.RouteValues["provider"]); -// -// var GoogleResult = Assert -// .IsType(controller.Storage(new StorageSettings() -// { -// Provider = StorageProvider.GoogleCloudStorage -// })); -// Assert.Equal(nameof(ServerController.StorageProvider), GoogleResult.ActionName); -// Assert.Equal(StorageProvider.GoogleCloudStorage.ToString(), GoogleResult.RouteValues["provider"]); -// + + var AmazonS3result = Assert + .IsType(controller.Storage(new StorageSettings() + { + Provider = StorageProvider.AmazonS3 + })); + Assert.Equal(nameof(ServerController.StorageProvider), AmazonS3result.ActionName); + Assert.Equal(StorageProvider.AmazonS3.ToString(), AmazonS3result.RouteValues["provider"]); + + var GoogleResult = Assert + .IsType(controller.Storage(new StorageSettings() + { + Provider = StorageProvider.GoogleCloudStorage + })); + Assert.Equal(nameof(ServerController.StorageProvider), GoogleResult.ActionName); + Assert.Equal(StorageProvider.GoogleCloudStorage.ToString(), GoogleResult.RouteValues["provider"]); + var AzureResult = Assert .IsType(controller.Storage(new StorageSettings() diff --git a/BTCPayServer/Controllers/ServerController.Storage.cs b/BTCPayServer/Controllers/ServerController.Storage.cs index 8bbf2348a..b0288bf9e 100644 --- a/BTCPayServer/Controllers/ServerController.Storage.cs +++ b/BTCPayServer/Controllers/ServerController.Storage.cs @@ -224,13 +224,13 @@ namespace BTCPayServer.Controllers return View(nameof(EditAzureBlobStorageStorageProvider), fileProviderService.GetProviderConfiguration(data)); -// case AmazonS3FileProviderService fileProviderService: -// return View(nameof(EditAmazonS3StorageProvider), -// fileProviderService.GetProviderConfiguration(data)); -// -// case GoogleCloudStorageFileProviderService fileProviderService: -// return View(nameof(EditGoogleCloudStorageStorageProvider), -// fileProviderService.GetProviderConfiguration(data)); + case AmazonS3FileProviderService fileProviderService: + return View(nameof(EditAmazonS3StorageProvider), + fileProviderService.GetProviderConfiguration(data)); + + case GoogleCloudStorageFileProviderService fileProviderService: + return View(nameof(EditGoogleCloudStorageStorageProvider), + fileProviderService.GetProviderConfiguration(data)); case FileSystemFileProviderService fileProviderService: return View(nameof(EditFileSystemStorageProvider), @@ -247,18 +247,18 @@ namespace BTCPayServer.Controllers return await SaveStorageProvider(viewModel, BTCPayServer.Storage.Models.StorageProvider.AzureBlobStorage); } -// [HttpPost("server/storage/AmazonS3")] -// public async Task EditAmazonS3StorageProvider(AmazonS3StorageConfiguration viewModel) -// { -// return await SaveStorageProvider(viewModel, BTCPayServer.Storage.Models.StorageProvider.AmazonS3); -// } -// -// [HttpPost("server/storage/GoogleCloudStorage")] -// public async Task EditGoogleCloudStorageStorageProvider( -// GoogleCloudStorageConfiguration viewModel) -// { -// return await SaveStorageProvider(viewModel, BTCPayServer.Storage.Models.StorageProvider.GoogleCloudStorage); -// } + [HttpPost("server/storage/AmazonS3")] + public async Task EditAmazonS3StorageProvider(AmazonS3StorageConfiguration viewModel) + { + return await SaveStorageProvider(viewModel, BTCPayServer.Storage.Models.StorageProvider.AmazonS3); + } + + [HttpPost("server/storage/GoogleCloudStorage")] + public async Task EditGoogleCloudStorageStorageProvider( + GoogleCloudStorageConfiguration viewModel) + { + return await SaveStorageProvider(viewModel, BTCPayServer.Storage.Models.StorageProvider.GoogleCloudStorage); + } [HttpPost("server/storage/FileSystem")] public async Task EditFileSystemStorageProvider(FileSystemStorageConfiguration viewModel) diff --git a/BTCPayServer/Storage/Models/StorageProvider.cs b/BTCPayServer/Storage/Models/StorageProvider.cs index 0858513d3..5071f6b5b 100644 --- a/BTCPayServer/Storage/Models/StorageProvider.cs +++ b/BTCPayServer/Storage/Models/StorageProvider.cs @@ -3,8 +3,8 @@ public enum StorageProvider { AzureBlobStorage=0, -// AmazonS3 =1, -// GoogleCloudStorage =2, + AmazonS3 =1, + GoogleCloudStorage =2, FileSystem =3 } -} \ No newline at end of file +} diff --git a/BTCPayServer/Storage/Services/Providers/AmazonS3Storage/AmazonS3FileProviderService.cs b/BTCPayServer/Storage/Services/Providers/AmazonS3Storage/AmazonS3FileProviderService.cs index 59b17f467..defabf29b 100644 --- a/BTCPayServer/Storage/Services/Providers/AmazonS3Storage/AmazonS3FileProviderService.cs +++ b/BTCPayServer/Storage/Services/Providers/AmazonS3Storage/AmazonS3FileProviderService.cs @@ -1,27 +1,27 @@ -//using System.Threading.Tasks; -//using BTCPayServer.Storage.Models; -//using BTCPayServer.Storage.Services.Providers.AmazonS3Storage.Configuration; -//using TwentyTwenty.Storage; -//using TwentyTwenty.Storage.Amazon; -// -//namespace BTCPayServer.Storage.Services.Providers.AmazonS3Storage -//{ -// public class -// AmazonS3FileProviderService : BaseTwentyTwentyStorageFileProviderServiceBase -// { -// public override StorageProvider StorageProvider() -// { -// return Storage.Models.StorageProvider.AmazonS3; -// } -// -// public override AmazonS3StorageConfiguration GetProviderConfiguration(StorageSettings configuration) -// { -// return configuration.Configuration.ParseAmazonS3StorageConfiguration(); -// } -// -// protected override Task GetStorageProvider(AmazonS3StorageConfiguration configuration) -// { -// return Task.FromResult(new AmazonStorageProvider(configuration)); -// } -// } -//} +using System.Threading.Tasks; +using BTCPayServer.Storage.Models; +using BTCPayServer.Storage.Services.Providers.AmazonS3Storage.Configuration; +using TwentyTwenty.Storage; +using TwentyTwenty.Storage.Amazon; + +namespace BTCPayServer.Storage.Services.Providers.AmazonS3Storage +{ + public class + AmazonS3FileProviderService : BaseTwentyTwentyStorageFileProviderServiceBase + { + public override StorageProvider StorageProvider() + { + return Storage.Models.StorageProvider.AmazonS3; + } + + public override AmazonS3StorageConfiguration GetProviderConfiguration(StorageSettings configuration) + { + return configuration.Configuration.ParseAmazonS3StorageConfiguration(); + } + + protected override Task GetStorageProvider(AmazonS3StorageConfiguration configuration) + { + return Task.FromResult(new AmazonStorageProvider(configuration)); + } + } +} diff --git a/BTCPayServer/Storage/Services/Providers/GoogleCloudStorage/GoogleCloudStorageFileProviderService.cs b/BTCPayServer/Storage/Services/Providers/GoogleCloudStorage/GoogleCloudStorageFileProviderService.cs index d6fef8d1d..7ba8a0afd 100644 --- a/BTCPayServer/Storage/Services/Providers/GoogleCloudStorage/GoogleCloudStorageFileProviderService.cs +++ b/BTCPayServer/Storage/Services/Providers/GoogleCloudStorage/GoogleCloudStorageFileProviderService.cs @@ -1,30 +1,30 @@ -//using System.Threading.Tasks; -//using BTCPayServer.Storage.Models; -//using BTCPayServer.Storage.Services.Providers.GoogleCloudStorage.Configuration; -//using Google.Apis.Auth.OAuth2; -//using TwentyTwenty.Storage; -//using TwentyTwenty.Storage.Google; -// -//namespace BTCPayServer.Storage.Services.Providers.GoogleCloudStorage -//{ -// public class -// GoogleCloudStorageFileProviderService : BaseTwentyTwentyStorageFileProviderServiceBase< -// GoogleCloudStorageConfiguration> -// { -// public override StorageProvider StorageProvider() -// { -// return Storage.Models.StorageProvider.GoogleCloudStorage; -// } -// -// public override GoogleCloudStorageConfiguration GetProviderConfiguration(StorageSettings configuration) -// { -// return configuration.Configuration.ParseGoogleCloudStorageConfiguration(); -// } -// -// protected override Task GetStorageProvider( -// GoogleCloudStorageConfiguration configuration) -// { -// return Task.FromResult(new GoogleStorageProvider(GoogleCredential.FromJson(configuration.JsonCredentials), configuration)); -// } -// } -//} +using System.Threading.Tasks; +using BTCPayServer.Storage.Models; +using BTCPayServer.Storage.Services.Providers.GoogleCloudStorage.Configuration; +using Google.Apis.Auth.OAuth2; +using TwentyTwenty.Storage; +using TwentyTwenty.Storage.Google; + +namespace BTCPayServer.Storage.Services.Providers.GoogleCloudStorage +{ + public class + GoogleCloudStorageFileProviderService : BaseTwentyTwentyStorageFileProviderServiceBase< + GoogleCloudStorageConfiguration> + { + public override StorageProvider StorageProvider() + { + return Storage.Models.StorageProvider.GoogleCloudStorage; + } + + public override GoogleCloudStorageConfiguration GetProviderConfiguration(StorageSettings configuration) + { + return configuration.Configuration.ParseGoogleCloudStorageConfiguration(); + } + + protected override Task GetStorageProvider( + GoogleCloudStorageConfiguration configuration) + { + return Task.FromResult(new GoogleStorageProvider(GoogleCredential.FromJson(configuration.JsonCredentials), configuration)); + } + } +}