Skip to content
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

Update Newtonsoft.Json to 13.0.3 across the board #1371

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Polly" Version="8.3.1" />
<PackageReference Include="SharpCompress" Version="0.37.2" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<PackageReference Include="Microsoft.Web.Deployment" Version="4.0.5" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
30 changes: 25 additions & 5 deletions source/Calamari.AzureWebApp.Tests/DeployAzureWebCommandFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -107,7 +110,7 @@ public async Task Setup()
Tier = "PremiumV3"
}
};

TestContext.WriteLine($"Creating app service plan {resourceGroupResource.Data.Name}");

var servicePlanResponse = await resourceGroupResource.GetAppServicePlans()
Expand All @@ -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()
Expand All @@ -145,15 +148,15 @@ 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);
}

[OneTimeTearDown]
public virtual async Task Cleanup()
{
TestContext.WriteLine($"Deleting resource group {resourceGroupResource.Data.Name}");

await resourceGroupResource.DeleteAsync(WaitUntil.Started, cancellationToken: cancellationToken);
}

Expand All @@ -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<string, string>
{
["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<DeployAzureWebCommand, Program>()
.WithArrange(context =>
{
context
.WithArg($"--sensitiveVariables={sensitiveVariablesFilePath}")
.WithArg($"--sensitiveVariablesPassword={encryptionPassword}");

AddDefaults(context);

context.WithFilesToCopy(tempPath.DirectoryPath);
Expand Down
7 changes: 6 additions & 1 deletion source/Calamari.CloudAccounts/AwsEnvironmentGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ async Task<bool> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<ItemGroup>
<PackageReference Include="AWSSDK.Core" Version="3.3.104.14" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.3.4.34" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.65.0" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23" />
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.37.1" />
Expand Down
1 change: 1 addition & 0 deletions source/Calamari.Common/Calamari.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<PackageReference Include="Globfish" Version="1.0.4" />
<PackageReference Include="JavaPropertiesParser" Version="0.2.1" />
<PackageReference Include="Microsoft.Web.Xdt" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Octopus.Versioning" Version="5.1.876" />
<PackageReference Include="Octopus.TinyTypes" Version="2.2.1156" />
<PackageReference Include="Octopus.CoreUtilities" Version="2.1.449" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="2.10.0" />
</ItemGroup>

Expand Down
3 changes: 3 additions & 0 deletions source/Calamari.Testing/CommandTestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ List<string> GetArgs(string workingPath)

context.Variables.Save(varPath);
args.Add($"--variables={varPath}");

//add any extra args
args.AddRange(context.Args);

return args;
}
Expand Down
8 changes: 8 additions & 0 deletions source/Calamari.Testing/CommandTestBuilderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class CommandTestBuilderContext

public VariableDictionary Variables { get; } = new VariableDictionary();

public IList<string> Args { get; } = new List<string>();

public CommandTestBuilderContext WithStagedPackageArgument()
{
withStagedPackageArgument = true;
Expand Down Expand Up @@ -58,5 +60,11 @@ public CommandTestBuilderContext WithTool(IDeploymentTool tool)
Tools.Add(tool);
return this;
}

public CommandTestBuilderContext WithArg(string arg)
{
Args.Add(arg);
return this;
}
}
}
1 change: 0 additions & 1 deletion source/Calamari/Calamari.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Web.Administration" Version="11.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Octodiff" Version="1.1.2" />
<PackageReference Include="FSharp.Compiler.Tools" Version="4.0.0.1" />
<PackageReference Include="Octopus.Versioning" Version="5.1.876" />
Expand Down