Skip to content

Commit

Permalink
New field AltinnNugetVersion in applicationMetadata.cs (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarne authored Nov 13, 2023
1 parent 9c4ed1a commit 58862ae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/Altinn.App.Core/Models/ApplicationMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using Altinn.Platform.Storage.Interface.Models;
using Newtonsoft.Json;

Expand Down Expand Up @@ -57,7 +58,13 @@ public ApplicationMetadata(string id)
/// </summary>
[JsonProperty(PropertyName = "logo")]
public Logo? Logo { get; set; }


/// <summary>
/// Frontend sometimes need to have knowledge of the nuget package version for backwards compatibility
/// </summary>
[JsonProperty(PropertyName = "altinnNugetVersion")]
public string AltinnNugetVersion { get; set; } = typeof(ApplicationMetadata).Assembly!.GetName().Version!.ToString();

/// <summary>
/// Holds properties that are not mapped to other properties
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using System.Text.Json;
using Altinn.App.Core.Configuration;
using Altinn.App.Core.Internal.App;
Expand Down Expand Up @@ -482,8 +483,9 @@ public async Task GetApplicationMetadata_deserialize_serialize_unmapped_properti
AppSettings appSettings = GetAppSettings("AppMetadata", "unmapped-properties.applicationmetadata.json");
IAppMetadata appMetadata = SetupAppMedata(Options.Create(appSettings));
var appMetadataObj = await appMetadata.GetApplicationMetadata();
string serialized = JsonSerializer.Serialize(appMetadataObj, new JsonSerializerOptions { WriteIndented = true });
string serialized = JsonSerializer.Serialize(appMetadataObj, new JsonSerializerOptions { WriteIndented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping });
string expected = File.ReadAllText(Path.Join(appBasePath, "AppMetadata", "unmapped-properties.applicationmetadata.expected.json"));
expected = expected.Replace("--AltinnNugetVersion--", typeof(ApplicationMetadata).Assembly!.GetName().Version!.ToString());
serialized.Should().Be(expected);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Show": "select-instance"
},
"Logo": null,
"AltinnNugetVersion": "--AltinnNugetVersion--",
"VersionId": null,
"Org": "tdd",
"Title": {
Expand Down

0 comments on commit 58862ae

Please sign in to comment.