Skip to content

Commit

Permalink
Add system user properties to PlatformUser (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandGrainOne authored Dec 6, 2024
1 parent 8ce2e56 commit fc0628c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
20 changes: 20 additions & 0 deletions src/Storage.Interface/Models/PlatformUser.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

using Newtonsoft.Json;

namespace Altinn.Platform.Storage.Interface.Models
Expand Down Expand Up @@ -38,5 +40,23 @@ public class PlatformUser
/// </summary>
[JsonProperty(PropertyName = "nationalIdentityNumber")]
public string NationalIdentityNumber { get; set; }

/// <summary>
/// Gets or sets the ID of the system user that triggered the event.
/// </summary>
[JsonProperty(PropertyName = "systemUserId")]
public Guid? SystemUserId { get; set; }

/// <summary>
/// Gets or sets the organization number of the owner of the system user that triggered the event.
/// </summary>
[JsonProperty(PropertyName = "systemUserOwnerOrgNo")]
public string SystemUserOwnerOrgNo { get; set; }

/// <summary>
/// Gets or sets the name of the system user that triggered the event.
/// </summary>
[JsonProperty(PropertyName = "systemUserName")]
public string SystemUserName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<None Remove="AllowUserActions\applicationMetadata_afterChange.json" />
<None Remove="AllowUserActions\applicationMetadata_beforeChange.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
Expand Down Expand Up @@ -47,6 +42,8 @@
<EmbeddedResource Include="AllowUserActions\applicationMetadata_beforeChange.json" />
<EmbeddedResource Include="AllowInSubform\applicationMetadata_afterChange.json" />
<EmbeddedResource Include="AllowInSubform\applicationMetadata_beforeChange.json" />
<EmbeddedResource Include="SystemUser\platformUser_afterChange.json" />
<EmbeddedResource Include="SystemUser\platformUser_beforeChange.json" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;

using Altinn.Platform.Storage.Interface.Models;

using FluentAssertions;

using Xunit;

namespace Altinn.Platform.Storage.Interface.Tests.SystemUser;

public class PlatformUserTests
{
[Fact]
public void MetadataWithoutShadowFields_ShouldBeFalse()
{
PlatformUser target = TestdataHelper.LoadDataFromEmbeddedResourceAsType<PlatformUser>("SystemUser.platformUser_beforeChange.json");

target.SystemUserId.Should().BeNull();
target.SystemUserName.Should().BeNull();
target.SystemUserOwnerOrgNo.Should().BeNull();
}

[Fact]
public void MetadataWithShadowFields_ShouldBeTrue()
{
PlatformUser target = TestdataHelper.LoadDataFromEmbeddedResourceAsType<PlatformUser>("SystemUser.platformUser_afterChange.json");

target.SystemUserId.Should().Be(Guid.Parse("2280457B-0A79-49C5-AC14-09217705C9A1"));
target.SystemUserName.Should().Be("Vismalise");
target.SystemUserOwnerOrgNo.Should().Be("565433454");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"systemUserId": "2280457B-0A79-49C5-AC14-09217705C9A1",
"systemUserOwnerOrgNo": "565433454",
"systemUserName": "Vismalise",
"authenticationLevel": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"orgId": "tdd",
"authenticationLevel": 3
}

0 comments on commit fc0628c

Please sign in to comment.