Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added trn verification level to dqt record pane #735

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@
<govuk-summary-list-row-key>TRN</govuk-summary-list-row-key>
<govuk-summary-list-row-value>@Model.Trn</govuk-summary-list-row-value>
</govuk-summary-list-row>
@{
if(Model.EffectiveVerificationLevel == TrnVerificationLevel.Low)
{
<govuk-summary-list-row>
<govuk-summary-list-row-key>TRN verification level</govuk-summary-list-row-key>
<govuk-summary-list-row-value><govuk-tag class="govuk-tag--yellow">Low</govuk-tag></govuk-summary-list-row-value>
</govuk-summary-list-row>
}
else if(Model.EffectiveVerificationLevel == TrnVerificationLevel.Medium)
{
<govuk-summary-list-row>
<govuk-summary-list-row-key>TRN verification level</govuk-summary-list-row-key>
<govuk-summary-list-row-value><govuk-tag class="govuk-tag--blue">Medium</govuk-tag></govuk-summary-list-row-value>
</govuk-summary-list-row>
}
}
</govuk-summary-list>
</div>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public UserModel(TeacherIdentityServerDbContext dbContext, IDqtApiClient dqtApiC

public IEnumerable<Guid>? MergedUserIds { get; set; }

public TrnVerificationLevel? EffectiveVerificationLevel { get; set; }

[FromRoute]
public Guid UserId { get; set; }

Expand All @@ -71,7 +73,8 @@ public async Task<IActionResult> OnGet()
u.Created,
u.UserType,
MergedUserIds = u.MergedUsers!.Select(mu => mu.UserId),
RegisteredWithClientDisplayName = u.RegisteredWithClient != null ? u.RegisteredWithClient.DisplayName : null
RegisteredWithClientDisplayName = u.RegisteredWithClient != null ? u.RegisteredWithClient.DisplayName : null,
u.EffectiveVerificationLevel
})
.SingleOrDefaultAsync();

Expand All @@ -96,6 +99,7 @@ public async Task<IActionResult> OnGet()
CanChangeDqtRecord = !HaveDqtRecord;
MergedUserIds = user.MergedUserIds;
DateOfBirth = user.DateOfBirth;
EffectiveVerificationLevel = user.EffectiveVerificationLevel;

if (user.Trn is not null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

namespace TeacherIdentity.AuthServer.Tests.EndpointTests.Admin;

public class UserTests : TestBase
Expand Down Expand Up @@ -137,4 +138,58 @@ public async Task Get_ValidRequestForUserWithMergedUsers_RendersExpectedContent(
var doc = await response.GetDocument();
Assert.Equal(mergedUser.UserId.ToString(), doc.GetSummaryListValueForKey("Merged user IDs"));
}

[Theory]
[InlineData(Models.TrnVerificationLevel.Low, "Low")]
[InlineData(Models.TrnVerificationLevel.Medium, "Medium")]
public async Task Get_ValidRequestForTrnVerificationLevel_RendersExpectedContent(Models.TrnVerificationLevel trnVerificationLevel, string verificationLevelString)
MrKevJoy marked this conversation as resolved.
Show resolved Hide resolved
{
// Arrange
var user = await TestData.CreateUser(hasTrn: true, userType: Models.UserType.Teacher, hasPreferredName: true, trnVerificationLevel: trnVerificationLevel);
var request = new HttpRequestMessage(HttpMethod.Get, $"/admin/users/{user.UserId}");
var dqtFirstName = Faker.Name.First();
var dqtLastName = Faker.Name.Last();
var dqtDateOfBirth = DateOnly.FromDateTime(Faker.Identification.DateOfBirth());
var dqtNino = Faker.Identification.UkNationalInsuranceNumber();

HostFixture.DqtApiClient.Setup(mock => mock.GetTeacherByTrn(user.Trn!, It.IsAny<CancellationToken>()))
.ReturnsAsync(new AuthServer.Services.DqtApi.TeacherInfo()
{
DateOfBirth = dqtDateOfBirth,
FirstName = dqtFirstName,
MiddleName = "",
LastName = dqtLastName,
NationalInsuranceNumber = dqtNino,
Trn = user.Trn!,
PendingNameChange = false,
PendingDateOfBirthChange = false,
Email = null
});

// Act
var response = await HttpClient.SendAsync(request);

// Assert
Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);

var doc = await response.GetDocument();
Assert.Equal(verificationLevelString, doc.GetSummaryListValueForKey("TRN verification level"));
}

[Fact]
public async Task Get_ValidRequestForUserWithoutTRN_DoesNotRenderTrnVerificationLevelSummaryRow()
{
// Arrange
var user = await TestData.CreateUser(hasTrn: false, userType: Models.UserType.Teacher, hasPreferredName: true);
var request = new HttpRequestMessage(HttpMethod.Get, $"/admin/users/{user.UserId}");

// Act
var response = await HttpClient.SendAsync(request);

// Assert
Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);

var doc = await response.GetDocument();
Assert.Null(doc.GetSummaryListRowForKey("TRN verification level"));
}
}
Loading