Skip to content

Commit

Permalink
merge changes from v7 and main into v8 branch. (#404)
Browse files Browse the repository at this point in the history
* chore(deps): update nuget non-major dependencies (#310)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Add [Authorize] attribute on AuthorizationController.GetCurrentParty (#339)

This means that the code won't crash with missing cookie when the cookie
exipires

* chore(deps): update nuget non-major dependencies (#330)

* chore(deps): update nuget non-major dependencies

* Fix broken test

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Vemund Gaukstad <[email protected]>

* chore(deps): update dependency moq to v4.20.70 (#371)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/setup-java action to v4 (#372)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update nuget non-major dependencies (#385)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update github/codeql-action action to v3 (#388)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/setup-dotnet action to v4 (#386)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/upload-artifact action to v4 (#387)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Support using connectionString for ApplicationInsights (#379) (#391)

This wil become a requirement from may 2025, so adding this early ensures that does not become an requirement for updating apps.

microsoft/ApplicationInsights-dotnet#2560

* chore(deps): update nuget non-major dependencies (#390)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* v7: Fix issue with non-ascii characters in code list parameters not being correctly encoded in parameter header. (#402)

Likely fix Altinn/codelists-lib-dotnet#23

* Include changes from main in v8 branch

mostly verion updates

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Vemund Gaukstad <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2024
1 parent ee15289 commit 07a7897
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -67,6 +67,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE: false
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-and-analyze-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
Expand All @@ -30,7 +30,7 @@ jobs:
reportgenerator -reports:TestResults/**/coverage.cobertura.xml -targetdir:TestResults/Output/CoverageReport -reporttypes:Cobertura
- name: Archive code coverage results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: TestResults/Output/CoverageReport/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-and-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
runs-on: windows-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
4 changes: 2 additions & 2 deletions src/Altinn.App.Api/Altinn.App.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<ItemGroup>
<PackageReference Include="Altinn.Common.PEP" Version="1.3.0" />
<PackageReference Include="Altinn.Platform.Storage.Interface" Version="3.24.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Debug'">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/Altinn.App.Api/Controllers/OptionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task<IActionResult> Get(
return NotFound();
}

HttpContext.Response.Headers.Add("Altinn-DownstreamParameters", appOptions.Parameters.ToNameValueString(','));
HttpContext.Response.Headers.Append("Altinn-DownstreamParameters", appOptions.Parameters.ToUrlEncodedNameValueString(','));

return Ok(appOptions.Options);
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public async Task<IActionResult> Get(
return NotFound();
}

HttpContext.Response.Headers.Add("Altinn-DownstreamParameters", appOptions.Parameters.ToNameValueString(','));
HttpContext.Response.Headers.Append("Altinn-DownstreamParameters", appOptions.Parameters.ToUrlEncodedNameValueString(','));

return Ok(appOptions.Options);
}
Expand Down
7 changes: 4 additions & 3 deletions src/Altinn.App.Core/Altinn.App.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
<PackageReference Include="Altinn.Common.PEP" Version="1.3.0" />
<PackageReference Include="Altinn.Platform.Models" Version="1.2.0" />
<PackageReference Include="Altinn.Platform.Storage.Interface" Version="3.24.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.57" />
<PackageReference Include="JsonPatch.Net" Version="2.1.0" />
<PackageReference Include="JWTCookieAuthentication" Version="3.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Scrutor" Version="4.2.2" />
<PackageReference Include="prometheus-net" Version="8.0.0" />
Expand Down
13 changes: 9 additions & 4 deletions src/Altinn.App.Core/Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Net;
using System.Text;

namespace Altinn.App.Core.Extensions
{
Expand All @@ -8,9 +9,9 @@ namespace Altinn.App.Core.Extensions
public static class DictionaryExtensions
{
/// <summary>
/// Converts a dictionary to a name value string on the form key1=value1,key2=value2
/// Converts a dictionary to a name value string on the form key1=value1,key2=value2 url encoding both key and value.
/// </summary>
public static string ToNameValueString(this Dictionary<string, string> parameters, char separator)
public static string ToUrlEncodedNameValueString(this Dictionary<string, string>? parameters, char separator)
{
if (parameters == null)
{
Expand All @@ -24,8 +25,12 @@ public static string ToNameValueString(this Dictionary<string, string> parameter
{
builder.Append(separator);
}
builder.Append(param.Key + "=" + param.Value);

builder.Append(WebUtility.UrlEncode(param.Key));
builder.Append('=');
builder.Append(WebUtility.UrlEncode(param.Value));
}

return builder.ToString();
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/Altinn.App.Api.Tests/Altinn.App.Api.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Altinn.App.Core.Features;
using Altinn.App.Core.Models;
using FluentAssertions;
using Moq;

namespace Altinn.App.Api.Tests.Controllers
{
Expand Down Expand Up @@ -70,8 +71,7 @@ public Task<AppOptions> GetAppOptionsAsync(string language, Dictionary<string, s
Parameters = new Dictionary<string, string>()
{
{ "lang", language }
},

}
};

return Task.FromResult(appOptions);
Expand Down
6 changes: 3 additions & 3 deletions test/Altinn.App.Common.Tests/Altinn.App.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
12 changes: 6 additions & 6 deletions test/Altinn.App.Core.Tests/Altinn.App.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -57,7 +57,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Debug'">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
28 changes: 24 additions & 4 deletions test/Altinn.App.Core.Tests/Extensions/DictionaryExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void ToNameValueString_OptionParameters_ShouldConvertToHttpHeaderFormat()

IHeaderDictionary headers = new HeaderDictionary
{
{ "Altinn-DownstreamParameters", options.Parameters.ToNameValueString(',') }
{ "Altinn-DownstreamParameters", options.Parameters.ToUrlEncodedNameValueString(',') }
};

Assert.Equal("lang=nb,level=1", headers["Altinn-DownstreamParameters"]);
Expand All @@ -37,7 +37,7 @@ public void ToNameValueString_OptionParametersWithEmptyValue_ShouldConvertToHttp

IHeaderDictionary headers = new HeaderDictionary
{
{ "Altinn-DownstreamParameters", options.Parameters.ToNameValueString(',') }
{ "Altinn-DownstreamParameters", options.Parameters.ToUrlEncodedNameValueString(',') }
};

Assert.Equal(string.Empty, headers["Altinn-DownstreamParameters"]);
Expand All @@ -48,15 +48,35 @@ public void ToNameValueString_OptionParametersWithNullValue_ShouldConvertToHttpH
{
var options = new AppOptions
{
Parameters = null
Parameters = null!
};

IHeaderDictionary headers = new HeaderDictionary
{
{ "Altinn-DownstreamParameters", options.Parameters.ToNameValueString(',') }
{ "Altinn-DownstreamParameters", options.Parameters.ToUrlEncodedNameValueString(',') }
};

Assert.Equal(string.Empty, headers["Altinn-DownstreamParameters"]);
}

[Fact]
public void ToNameValueString_OptionParametersWithSpecialCharaters_IsValidAsHeaders()
{
var options = new AppOptions
{
Parameters = new Dictionary<string, string>
{
{ "lang", "nb" },
{ "level", "1" },
{ "name", "ÆØÅ" },
{ "variant", "Småvilt1" }
},
};

IHeaderDictionary headers = new HeaderDictionary();
headers.Add("Altinn-DownstreamParameters", options.Parameters.ToUrlEncodedNameValueString(','));

Assert.Equal("lang=nb,level=1,name=%C3%86%C3%98%C3%85,variant=Sm%C3%A5vilt1", headers["Altinn-DownstreamParameters"]);
}
}
}

0 comments on commit 07a7897

Please sign in to comment.