コード例 #1
0
        public WebAppWithDockerFileTests()
        {
            _httpHelper = new HttpHelper();

            var cloudFormationClient = new AmazonCloudFormationClient();

            _cloudFormationHelper = new CloudFormationHelper(cloudFormationClient);

            var ecsClient = new AmazonECSClient();

            _ecsHelper = new ECSHelper(ecsClient);

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddCustomServices();
            serviceCollection.AddTestServices();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            _app = serviceProvider.GetService <App>();
            Assert.NotNull(_app);

            _interactiveService = serviceProvider.GetService <InMemoryInteractiveService>();
            Assert.NotNull(_interactiveService);

            _testAppManager = new TestAppManager();
        }
コード例 #2
0
        public async Task GetRecommendationsWithEncryptedCredentials()
        {
            var projectPath = _testAppManager.GetProjectPath(Path.Combine("testapps", "WebAppNoDockerFile", "WebAppNoDockerFile.csproj"));
            var portNumber  = 4000;

            var aes = Aes.Create();

            aes.GenerateKey();
            aes.GenerateIV();

            using var httpClient = ServerModeHttpClientFactory.ConstructHttpClient(ResolveCredentials, aes);

            InMemoryInteractiveService interactiveService = new InMemoryInteractiveService();
            var keyInfo = new EncryptionKeyInfo
            {
                Version = EncryptionKeyInfo.VERSION_1_0,
                Key     = Convert.ToBase64String(aes.Key),
                IV      = Convert.ToBase64String(aes.IV)
            };
            var keyInfoStdin = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(keyInfo)));
            await interactiveService.StdInWriter.WriteAsync(keyInfoStdin);

            await interactiveService.StdInWriter.FlushAsync();

            var serverCommand = new ServerModeCommand(interactiveService, portNumber, null, false);
            var cancelSource  = new CancellationTokenSource();

            var serverTask = serverCommand.ExecuteAsync(cancelSource.Token);

            try
            {
                var restClient = new RestAPIClient($"http://localhost:{portNumber}/", httpClient);
                await WaitTillServerModeReady(restClient);

                var startSessionOutput = await restClient.StartDeploymentSessionAsync(new StartDeploymentSessionInput
                {
                    AwsRegion   = _awsRegion,
                    ProjectPath = projectPath
                });

                var sessionId = startSessionOutput.SessionId;
                Assert.NotNull(sessionId);

                var getRecommendationOutput = await restClient.GetRecommendationsAsync(sessionId);

                Assert.NotEmpty(getRecommendationOutput.Recommendations);
                Assert.Equal("AspNetAppElasticBeanstalkLinux", getRecommendationOutput.Recommendations.FirstOrDefault().RecipeId);

                var listDeployStdOut = interactiveService.StdOutReader.ReadAllLines();
                Assert.Contains("Waiting on symmetric key from stdin", listDeployStdOut);
                Assert.Contains("Encryption provider enabled", listDeployStdOut);
            }
            finally
            {
                cancelSource.Cancel();
            }
        }
コード例 #3
0
        public async Task AuthEncryptionWithInvalidVersion()
        {
            InMemoryInteractiveService interactiveService = new InMemoryInteractiveService();

            var portNumber = 4010;

            var aes = Aes.Create();

            aes.GenerateKey();
            aes.GenerateIV();

            var keyInfo = new EncryptionKeyInfo
            {
                Version = "not-valid",
                Key     = Convert.ToBase64String(aes.Key),
                IV      = Convert.ToBase64String(aes.IV)
            };
            var keyInfoStdin = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(keyInfo)));
            await interactiveService.StdInWriter.WriteAsync(keyInfoStdin);

            await interactiveService.StdInWriter.FlushAsync();

            var serverCommand = new ServerModeCommand(interactiveService, portNumber, null, false);


            var       cancelSource    = new CancellationTokenSource();
            Exception actualException = null;

            try
            {
                await serverCommand.ExecuteAsync(cancelSource.Token);
            }
            catch (InvalidEncryptionKeyInfoException e)
            {
                actualException = e;
            }
            finally
            {
                cancelSource.Cancel();
            }

            Assert.NotNull(actualException);
            Assert.Equal("Unsupported symmetric key not-valid", actualException.Message);
        }
コード例 #4
0
        public BlazorWasmTests()
        {
            _httpHelper = new HttpHelper();

            _cloudFormationHelper = new CloudFormationHelper(new AmazonCloudFormationClient());
            _cloudFrontHelper     = new CloudFrontHelper(new Amazon.CloudFront.AmazonCloudFrontClient());

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddCustomServices();
            serviceCollection.AddTestServices();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            _app = serviceProvider.GetService <App>();
            Assert.NotNull(_app);

            _interactiveService = serviceProvider.GetService <InMemoryInteractiveService>();
            Assert.NotNull(_interactiveService);

            _testAppManager = new TestAppManager();
        }
コード例 #5
0
        public ElasticBeanStalkDeploymentTest()
        {
            _httpHelper = new HttpHelper();

            var cloudFormationClient = new AmazonCloudFormationClient();

            _cloudFormationHelper = new CloudFormationHelper(cloudFormationClient);

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddCustomServices();
            serviceCollection.AddTestServices();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            _app = serviceProvider.GetService <App>();
            Assert.NotNull(_app);

            _interactiveService = serviceProvider.GetService <InMemoryInteractiveService>();
            Assert.NotNull(_interactiveService);

            _testAppManager = new TestAppManager();
        }