-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some tests against the import notification, and verified that t…
…he json is the same after the flatten, and unflattening
- Loading branch information
Thomas Anderson
committed
Dec 3, 2024
1 parent
4ce11e7
commit d926789
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Text.Json.Nodes; | ||
using Cdms.SensitiveData; | ||
using Cdms.Types.Ipaffs; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using Microsoft.Extensions.Options; | ||
using Xunit; | ||
|
||
namespace CdmsBackend.IntegrationTests; | ||
|
||
public class SensitiveDataTests | ||
{ | ||
[Fact] | ||
public void WhenIncludeSensitiveData_RedactedShouldBeSameAsJson() | ||
{ | ||
string json = | ||
File.ReadAllText(Path.GetFullPath("..\\..\\..\\Fixtures\\SmokeTest\\IPAFFS\\CHEDA\\CHEDA_GB_2024_1041389-ee0e6fcf-52a4-45ea-8830-d4553ee70361.json")); | ||
|
||
SensitiveDataOptions options = new SensitiveDataOptions { Getter = s => "TestRedacted", Include = true }; | ||
var serializer = new SensitiveDataSerializer(Options.Create(options), NullLogger<SensitiveDataSerializer>.Instance); | ||
|
||
var result = serializer.RedactRawJson(json, typeof(ImportNotification)); | ||
|
||
JsonNode.DeepEquals(JsonNode.Parse(json), JsonNode.Parse(result)).Should().BeTrue(); | ||
|
||
} | ||
|
||
[Fact] | ||
public void WhenIncludeSensitiveData_RedactedShouldBeDifferentJson() | ||
{ | ||
string json = | ||
File.ReadAllText(Path.GetFullPath("..\\..\\..\\Fixtures\\SmokeTest\\IPAFFS\\CHEDA\\CHEDA_GB_2024_1041389-ee0e6fcf-52a4-45ea-8830-d4553ee70361.json")); | ||
|
||
SensitiveDataOptions options = new SensitiveDataOptions { Getter = s => "TestRedacted", Include = false }; | ||
var serializer = new SensitiveDataSerializer(Options.Create(options), NullLogger<SensitiveDataSerializer>.Instance); | ||
|
||
var result = serializer.RedactRawJson(json, typeof(ImportNotification)); | ||
|
||
JsonNode.DeepEquals(JsonNode.Parse(json), JsonNode.Parse(result)).Should().BeFalse(); | ||
result.Should().Contain("TestRedacted"); | ||
|
||
} | ||
} |