Skip to content

Commit

Permalink
Don't expose G1 sanctions over the API (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Sep 13, 2024
1 parent 58cc546 commit bbc7c6d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ public static class Constants
{
public static IReadOnlyCollection<string> LegacyExposableSanctionCodes { get; } = new[]
{
"G1",
"A18",
"A7",
"A3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public async Task Get_ValidRequestWithMatchesOnLastName_ReturnsMappedContacts()
var lastName = "Smith";
var dateOfBirth = new DateOnly(1990, 1, 1);

var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));

var request = new HttpRequestMessage(
HttpMethod.Get,
Expand Down Expand Up @@ -155,8 +155,8 @@ public async Task Get_ValidRequestWithMatchOnPreviousName_ReturnsMappedContacts(
var lastName = TestData.GenerateLastName();
var dateOfBirth = new DateOnly(1990, 1, 1);

var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));
var person3 = await TestData.CreatePerson(b => b.WithLastName(TestData.GenerateChangedLastName(lastName)).WithDateOfBirth(dateOfBirth));
var updatedLastName = TestData.GenerateChangedLastName(lastName);
await TestData.UpdatePerson(b => b.WithPersonId(person2.PersonId).WithUpdatedName(person2.FirstName, person2.MiddleName, updatedLastName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ protected async Task ValidRequestWithSanctions_ReturnsExpectedSanctionsContent(
var sanctions = new (string SanctionCode, DateOnly? StartDate)[]
{
new("A18", null),
new("G1", new DateOnly(2022, 4, 1)),
new("A21B", new DateOnly(2022, 4, 1)),
};
Debug.Assert(sanctions.Select(s => s.SanctionCode).All(TeachingRecordSystem.Api.V3.Constants.LegacyExposableSanctionCodes.Contains));

Expand Down Expand Up @@ -452,8 +452,8 @@ protected async Task ValidRequestWithAlerts_ReturnsExpectedSanctionsContent(
// Arrange
var sanctions = new (string SanctionCode, DateOnly? StartDate)[]
{
new("B1", null),
new("G1", new DateOnly(2022, 4, 1)),
new("A21B", null),
new("A21B", new DateOnly(2022, 4, 1)),
};
Debug.Assert(sanctions.Select(s => s.SanctionCode).All(TeachingRecordSystem.Api.V3.Constants.LegacyProhibitionSanctionCodes.Contains));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public async Task Get_ValidRequestWithMatchesOnLastName_ReturnsMappedContacts()
var lastName = "Smith";
var dateOfBirth = new DateOnly(1990, 1, 1);

var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));

var request = new HttpRequestMessage(
HttpMethod.Get,
Expand Down Expand Up @@ -155,8 +155,8 @@ public async Task Get_ValidRequestWithMatchOnPreviousName_ReturnsMappedContacts(
var lastName = TestData.GenerateLastName();
var dateOfBirth = new DateOnly(1990, 1, 1);

var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("G1"));
var person1 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));
var person2 = await TestData.CreatePerson(b => b.WithLastName(lastName).WithDateOfBirth(dateOfBirth).WithSanction("A21B"));
var person3 = await TestData.CreatePerson(b => b.WithLastName(TestData.GenerateChangedLastName(lastName)).WithDateOfBirth(dateOfBirth));
var updatedLastName = TestData.GenerateChangedLastName(lastName);
await TestData.UpdatePerson(b => b.WithPersonId(person2.PersonId).WithUpdatedName(person2.FirstName, person2.MiddleName, updatedLastName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ protected async Task ValidRequestWithSanctions_ReturnsExpectedSanctionsContent(
var sanctions = new (string SanctionCode, DateOnly? StartDate)[]
{
new("A18", null),
new("G1", new DateOnly(2022, 4, 1)),
new("A21B", new DateOnly(2022, 4, 1)),
};
Debug.Assert(sanctions.Select(s => s.SanctionCode).All(Api.V3.Constants.LegacyExposableSanctionCodes.Contains));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ public async Task Get_ValidRequestWithMatchesOnLastName_ReturnsExpectedResponse(
var person1 = await TestData.CreatePerson(b => b
.WithLastName(lastName)
.WithDateOfBirth(dateOfBirth)
.WithSanction("G1")
.WithSanction("A21B")
.WithInduction(dfeta_InductionStatus.Pass, inductionExemptionReason: null, inductionStartDate: new(2022, 1, 1), completedDate: new DateOnly(2023, 1, 1))
.WithQts(qtsDate: new(2021, 7, 1))
.WithEyts(eytsDate: new(2021, 8, 1), eytsStatusValue: "222"));

var person2 = await TestData.CreatePerson(b => b
.WithLastName(lastName)
.WithDateOfBirth(dateOfBirth)
.WithSanction("G1"));
.WithSanction("A21B"));

var request = new HttpRequestMessage(
HttpMethod.Get,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public async Task Get_ValidRequest_ReturnsMatchedRecord()

var person = await TestData.CreatePerson(b => b
.WithDateOfBirth(dateOfBirth)
.WithSanction("G1")
.WithSanction("A21B")
.WithInduction(dfeta_InductionStatus.Pass, inductionExemptionReason: null, inductionStartDate: new(2022, 1, 1), completedDate: new DateOnly(2023, 1, 1))
.WithQts(qtsDate: new(2021, 7, 1))
.WithEyts(eytsDate: new(2021, 8, 1), eytsStatusValue: "222"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ private void AddSanctionCodes()
dfeta_Value = "B1",
dfeta_name = "B1 Description"
});

_xrmFakedContext.CreateEntity(new dfeta_sanctioncode()
{
dfeta_Value = "A21B",
dfeta_name = "A21B Description"
});
}

private void AddTeacherStatuses()
Expand Down

0 comments on commit bbc7c6d

Please sign in to comment.