diff --git a/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj b/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj index 9840d4e4c..5c3ce1746 100644 --- a/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj +++ b/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj @@ -19,7 +19,6 @@ all runtime; build; native; contentfiles; analyzers - diff --git a/source/Calamari.AzureWebApp.NetCoreShim/Calamari.AzureWebApp.NetCoreShim.csproj b/source/Calamari.AzureWebApp.NetCoreShim/Calamari.AzureWebApp.NetCoreShim.csproj index 6fcdac05e..79ee2af84 100644 --- a/source/Calamari.AzureWebApp.NetCoreShim/Calamari.AzureWebApp.NetCoreShim.csproj +++ b/source/Calamari.AzureWebApp.NetCoreShim/Calamari.AzureWebApp.NetCoreShim.csproj @@ -11,6 +11,6 @@ - + diff --git a/source/Calamari.AzureWebApp.Tests/DeployAzureWebCommandFixture.cs b/source/Calamari.AzureWebApp.Tests/DeployAzureWebCommandFixture.cs index 08c7a7c32..4afe4672d 100644 --- a/source/Calamari.AzureWebApp.Tests/DeployAzureWebCommandFixture.cs +++ b/source/Calamari.AzureWebApp.Tests/DeployAzureWebCommandFixture.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Net; +using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; using Azure; @@ -15,11 +16,13 @@ using Calamari.CloudAccounts; using Calamari.Common.Features.Deployment; using Calamari.Common.Features.Scripts; +using Calamari.Common.Plumbing.Extensions; using Calamari.Common.Plumbing.FileSystem; using Calamari.Testing; using Calamari.Testing.Helpers; using Calamari.Testing.Requirements; using FluentAssertions; +using Newtonsoft.Json; using NUnit.Framework; using HttpClient = System.Net.Http.HttpClient; using KnownVariables = Calamari.Common.Plumbing.Variables.KnownVariables; @@ -80,7 +83,7 @@ public async Task Setup() var subscriptionResource = armClient.GetSubscriptionResource(SubscriptionResource.CreateResourceIdentifier(subscriptionId)); TestContext.WriteLine($"Creating resource group {resourceGroupName}"); - + var response = await subscriptionResource .GetResourceGroups() .CreateOrUpdateAsync(WaitUntil.Completed, @@ -107,7 +110,7 @@ public async Task Setup() Tier = "PremiumV3" } }; - + TestContext.WriteLine($"Creating app service plan {resourceGroupResource.Data.Name}"); var servicePlanResponse = await resourceGroupResource.GetAppServicePlans() @@ -129,7 +132,7 @@ public async Task SetUp() var newCount = Interlocked.Increment(ref webAppCount); var name = $"{resourceGroupResource.Data.Name}-{newCount}"; - + TestContext.WriteLine($"Creating web site {name}"); var webSiteResponse = await resourceGroupResource.GetWebSites() @@ -145,7 +148,7 @@ public async Task SetUp() public async Task TearDown() { TestContext.WriteLine($"Deleting Azure Web Site {webSiteResource.Data.Name}"); - + await webSiteResource.DeleteAsync(WaitUntil.Started, deleteEmptyServerFarm: false, cancellationToken: cancellationToken); } @@ -153,7 +156,7 @@ public async Task TearDown() public virtual async Task Cleanup() { TestContext.WriteLine($"Deleting resource group {resourceGroupResource.Data.Name}"); - + await resourceGroupResource.DeleteAsync(WaitUntil.Started, cancellationToken: cancellationToken); } @@ -164,10 +167,27 @@ public async Task Deploy_WebApp_Simple() const string actualText = "Hello World"; File.WriteAllText(Path.Combine(tempPath.DirectoryPath, "index.html"), actualText); + + var sensitiveVariables = new Dictionary + { + ["MyCoolSensitiveVariable"] = "i-am-a-secret", + ["Another.Secret"] = "abc123" + }; + var serialized = JsonConvert.SerializeObject(sensitiveVariables); + var encryptionPassword = AesEncryption.RandomString(10); + var aesEncryption = new AesEncryption(encryptionPassword); + var encryptedBytes = aesEncryption.Encrypt(serialized); + + var sensitiveVariablesFilePath = Path.Combine(tempPath.DirectoryPath, Path.GetRandomFileName()); + File.WriteAllBytes(sensitiveVariablesFilePath, encryptedBytes); await CommandTestBuilder.CreateAsync() .WithArrange(context => { + context + .WithArg($"--sensitiveVariables={sensitiveVariablesFilePath}") + .WithArg($"--sensitiveVariablesPassword={encryptionPassword}"); + AddDefaults(context); context.WithFilesToCopy(tempPath.DirectoryPath); diff --git a/source/Calamari.CloudAccounts/AwsEnvironmentGeneration.cs b/source/Calamari.CloudAccounts/AwsEnvironmentGeneration.cs index 6251f6157..2dbb427af 100644 --- a/source/Calamari.CloudAccounts/AwsEnvironmentGeneration.cs +++ b/source/Calamari.CloudAccounts/AwsEnvironmentGeneration.cs @@ -237,7 +237,12 @@ async Task PopulateKeysFromInstanceRole() payload = await client.GetStringAsync($"{RoleUri}{instanceRole}"); } - dynamic instanceRoleKeys = JsonConvert.DeserializeObject(payload); + var instanceRoleKeys = JsonConvert.DeserializeAnonymousType(payload, new + { + AccessKeyId = "", + SecretAccessKey = "", + Token = "" + }); EnvironmentVars["AWS_ACCESS_KEY_ID"] = instanceRoleKeys.AccessKeyId; EnvironmentVars["AWS_SECRET_ACCESS_KEY"] = instanceRoleKeys.SecretAccessKey; diff --git a/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj b/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj index d86a9c838..bf56212da 100644 --- a/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj +++ b/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj @@ -17,7 +17,6 @@ - diff --git a/source/Calamari.Common/Calamari.Common.csproj b/source/Calamari.Common/Calamari.Common.csproj index d6b323fe4..0d007f6c3 100644 --- a/source/Calamari.Common/Calamari.Common.csproj +++ b/source/Calamari.Common/Calamari.Common.csproj @@ -39,6 +39,7 @@ + diff --git a/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj b/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj index f6e60549e..562be8cc9 100644 --- a/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj +++ b/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj @@ -6,7 +6,7 @@ - + diff --git a/source/Calamari.Testing/CommandTestBuilder.cs b/source/Calamari.Testing/CommandTestBuilder.cs index ade2818d0..3dd17dab8 100644 --- a/source/Calamari.Testing/CommandTestBuilder.cs +++ b/source/Calamari.Testing/CommandTestBuilder.cs @@ -154,6 +154,9 @@ List GetArgs(string workingPath) context.Variables.Save(varPath); args.Add($"--variables={varPath}"); + + //add any extra args + args.AddRange(context.Args); return args; } diff --git a/source/Calamari.Testing/CommandTestBuilderContext.cs b/source/Calamari.Testing/CommandTestBuilderContext.cs index 4ce5d742e..55ae4873c 100644 --- a/source/Calamari.Testing/CommandTestBuilderContext.cs +++ b/source/Calamari.Testing/CommandTestBuilderContext.cs @@ -17,6 +17,8 @@ public class CommandTestBuilderContext public VariableDictionary Variables { get; } = new VariableDictionary(); + public IList Args { get; } = new List(); + public CommandTestBuilderContext WithStagedPackageArgument() { withStagedPackageArgument = true; @@ -58,5 +60,11 @@ public CommandTestBuilderContext WithTool(IDeploymentTool tool) Tools.Add(tool); return this; } + + public CommandTestBuilderContext WithArg(string arg) + { + Args.Add(arg); + return this; + } } } \ No newline at end of file diff --git a/source/Calamari/Calamari.csproj b/source/Calamari/Calamari.csproj index 43df3543a..da06e804d 100644 --- a/source/Calamari/Calamari.csproj +++ b/source/Calamari/Calamari.csproj @@ -47,7 +47,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive -