diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml index 9b46595f4..d7ed1fb78 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml @@ -125,6 +125,22 @@ TRN @Model.Trn + @{ + if(Model.EffectiveVerificationLevel == TrnVerificationLevel.Low) + { + + TRN verification level + Low + + } + else if(Model.EffectiveVerificationLevel == TrnVerificationLevel.Medium) + { + + TRN verification level + Medium + + } + } diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml.cs b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml.cs index ed56777cb..8fd3e3b78 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml.cs +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/User.cshtml.cs @@ -48,6 +48,8 @@ public UserModel(TeacherIdentityServerDbContext dbContext, IDqtApiClient dqtApiC public IEnumerable? MergedUserIds { get; set; } + public TrnVerificationLevel? EffectiveVerificationLevel { get; set; } + [FromRoute] public Guid UserId { get; set; } @@ -71,7 +73,8 @@ public async Task 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(); @@ -96,6 +99,7 @@ public async Task OnGet() CanChangeDqtRecord = !HaveDqtRecord; MergedUserIds = user.MergedUserIds; DateOfBirth = user.DateOfBirth; + EffectiveVerificationLevel = user.EffectiveVerificationLevel; if (user.Trn is not null) { diff --git a/dotnet-authserver/tests/TeacherIdentity.AuthServer.Tests/EndpointTests/Admin/UserTests.cs b/dotnet-authserver/tests/TeacherIdentity.AuthServer.Tests/EndpointTests/Admin/UserTests.cs index a3c310622..843e00c46 100644 --- a/dotnet-authserver/tests/TeacherIdentity.AuthServer.Tests/EndpointTests/Admin/UserTests.cs +++ b/dotnet-authserver/tests/TeacherIdentity.AuthServer.Tests/EndpointTests/Admin/UserTests.cs @@ -1,3 +1,4 @@ + namespace TeacherIdentity.AuthServer.Tests.EndpointTests.Admin; public class UserTests : TestBase @@ -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) + { + // 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())) + .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")); + } }