1- using System ;
2- using Amazon ;
3- using Amazon . S3 ;
4- using FluentAssertions ;
5- using ManagedCode . Storage . Aws ;
6- using ManagedCode . Storage . Aws . Extensions ;
7- using ManagedCode . Storage . Aws . Options ;
8- using ManagedCode . Storage . Core ;
9- using ManagedCode . Storage . Core . Exceptions ;
10- using Microsoft . Extensions . DependencyInjection ;
11- using Testcontainers . LocalStack ;
12- using Xunit ;
13-
14- namespace ManagedCode . Storage . Tests . AWS ;
15-
16- public class AWSStorageTests : StorageBaseTests
17- {
18- protected override ServiceProvider ConfigureServices ( )
19- {
20-
21-
22- var services = new ServiceCollection ( ) ;
23-
24- // AWS library overwrites property values. you should only create configurations this way.
25- var awsConfig = new AmazonS3Config
26- {
27- RegionEndpoint = RegionEndpoint . EUWest1 ,
28- ForcePathStyle = true ,
29- UseHttp = true ,
30- ServiceURL = "http://localhost:4566" // this is the default port for the aws s3 emulator, must be last in the list
31- } ;
32-
33- services . AddAWSStorageAsDefault ( opt =>
34- {
35- opt . PublicKey = "localkey" ;
36- opt . SecretKey = "localsecret" ;
37- opt . Bucket = "managed-code-bucket" ;
38- opt . OriginalOptions = awsConfig ;
39- } ) ;
40-
41- services . AddAWSStorage ( new AWSStorageOptions
42- {
43- PublicKey = "localkey" ,
44- SecretKey = "localsecret" ,
45- Bucket = "managed-code-bucket" ,
46- OriginalOptions = awsConfig
47- } ) ;
48- return services . BuildServiceProvider ( ) ;
49- }
50-
51- [ Fact ]
52- public void BadConfigurationForStorage_WithoutPublicKey_ThrowException ( )
53- {
54- var services = new ServiceCollection ( ) ;
55-
56- Action action = ( ) => services . AddAWSStorage ( opt =>
57- {
58- opt . SecretKey = "localsecret" ;
59- opt . Bucket = "managed-code-bucket" ;
60- } ) ;
61-
62- action . Should ( ) . Throw < BadConfigurationException > ( ) ;
63- }
64-
65- [ Fact ]
66- public void BadConfigurationForStorage_WithoutSecretKey_ThrowException ( )
67- {
68- var services = new ServiceCollection ( ) ;
69-
70- Action action = ( ) => services . AddAWSStorageAsDefault ( opt =>
71- {
72- opt . PublicKey = "localkey" ;
73- opt . Bucket = "managed-code-bucket" ;
74- } ) ;
75-
76- action . Should ( ) . Throw < BadConfigurationException > ( ) ;
77- }
78-
79- [ Fact ]
80- public void BadConfigurationForStorage_WithoutBucket_ThrowException ( )
81- {
82- var services = new ServiceCollection ( ) ;
83-
84- Action action = ( ) => services . AddAWSStorageAsDefault ( new AWSStorageOptions
85- {
86- PublicKey = "localkey" ,
87- SecretKey = "localsecret"
88- } ) ;
89-
90- action . Should ( ) . Throw < BadConfigurationException > ( ) ;
91- }
92-
93- [ Fact ]
94- public void StorageAsDefaultTest ( )
95- {
96- var storage = ServiceProvider . GetService < IAWSStorage > ( ) ;
97- var defaultStorage = ServiceProvider . GetService < IStorage > ( ) ;
98- storage ? . GetType ( ) . FullName . Should ( ) . Be ( defaultStorage ? . GetType ( ) . FullName ) ;
99- }
100- }
1+ // using System;
2+ // using Amazon;
3+ // using Amazon.S3;
4+ // using FluentAssertions;
5+ // using ManagedCode.Storage.Aws;
6+ // using ManagedCode.Storage.Aws.Extensions;
7+ // using ManagedCode.Storage.Aws.Options;
8+ // using ManagedCode.Storage.Core;
9+ // using ManagedCode.Storage.Core.Exceptions;
10+ // using Microsoft.Extensions.DependencyInjection;
11+ // using Testcontainers.LocalStack;
12+ // using Xunit;
13+ //
14+ // namespace ManagedCode.Storage.Tests.AWS;
15+ //
16+ // public class AWSStorageTests : StorageBaseTests
17+ // {
18+ // protected override ServiceProvider ConfigureServices()
19+ // {
20+ //
21+ //
22+ // var services = new ServiceCollection();
23+ //
24+ // // AWS library overwrites property values. you should only create configurations this way.
25+ // var awsConfig = new AmazonS3Config
26+ // {
27+ // RegionEndpoint = RegionEndpoint.EUWest1,
28+ // ForcePathStyle = true,
29+ // UseHttp = true,
30+ // ServiceURL = "http://localhost:4566" // this is the default port for the aws s3 emulator, must be last in the list
31+ // };
32+ //
33+ // services.AddAWSStorageAsDefault(opt =>
34+ // {
35+ // opt.PublicKey = "localkey";
36+ // opt.SecretKey = "localsecret";
37+ // opt.Bucket = "managed-code-bucket";
38+ // opt.OriginalOptions = awsConfig;
39+ // });
40+ //
41+ // services.AddAWSStorage(new AWSStorageOptions
42+ // {
43+ // PublicKey = "localkey",
44+ // SecretKey = "localsecret",
45+ // Bucket = "managed-code-bucket",
46+ // OriginalOptions = awsConfig
47+ // });
48+ // return services.BuildServiceProvider();
49+ // }
50+ //
51+ // [Fact]
52+ // public void BadConfigurationForStorage_WithoutPublicKey_ThrowException()
53+ // {
54+ // var services = new ServiceCollection();
55+ //
56+ // Action action = () => services.AddAWSStorage(opt =>
57+ // {
58+ // opt.SecretKey = "localsecret";
59+ // opt.Bucket = "managed-code-bucket";
60+ // });
61+ //
62+ // action.Should().Throw<BadConfigurationException>();
63+ // }
64+ //
65+ // [Fact]
66+ // public void BadConfigurationForStorage_WithoutSecretKey_ThrowException()
67+ // {
68+ // var services = new ServiceCollection();
69+ //
70+ // Action action = () => services.AddAWSStorageAsDefault(opt =>
71+ // {
72+ // opt.PublicKey = "localkey";
73+ // opt.Bucket = "managed-code-bucket";
74+ // });
75+ //
76+ // action.Should().Throw<BadConfigurationException>();
77+ // }
78+ //
79+ // [Fact]
80+ // public void BadConfigurationForStorage_WithoutBucket_ThrowException()
81+ // {
82+ // var services = new ServiceCollection();
83+ //
84+ // Action action = () => services.AddAWSStorageAsDefault(new AWSStorageOptions
85+ // {
86+ // PublicKey = "localkey",
87+ // SecretKey = "localsecret"
88+ // });
89+ //
90+ // action.Should().Throw<BadConfigurationException>();
91+ // }
92+ //
93+ // [Fact]
94+ // public void StorageAsDefaultTest()
95+ // {
96+ // var storage = ServiceProvider.GetService<IAWSStorage>();
97+ // var defaultStorage = ServiceProvider.GetService<IStorage>();
98+ // storage?.GetType().FullName.Should().Be(defaultStorage?.GetType().FullName);
99+ // }
100+ // }
0 commit comments