diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/AuthenticationState.cs b/dotnet-authserver/src/TeacherIdentity.AuthServer/AuthenticationState.cs index 4aba50406..c6e5956b4 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/AuthenticationState.cs +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/AuthenticationState.cs @@ -150,6 +150,8 @@ public AuthenticationState( [JsonIgnore] public bool HasTrnSet => HasTrn.HasValue; [JsonIgnore] + public bool StatedTrnSet => StatedTrn is not null; + [JsonIgnore] public bool NameSet => HasName.HasValue; [JsonIgnore] public bool DateOfBirthSet => DateOfBirth.HasValue; diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Journeys/CoreSignInJourneyWithTrnLookup.cs b/dotnet-authserver/src/TeacherIdentity.AuthServer/Journeys/CoreSignInJourneyWithTrnLookup.cs index 2a58972fd..09ebc77d5 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Journeys/CoreSignInJourneyWithTrnLookup.cs +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Journeys/CoreSignInJourneyWithTrnLookup.cs @@ -118,8 +118,8 @@ public override bool IsCompleted() Steps.NiNumber => AuthenticationState is { HasNationalInsuranceNumber: true, ContactDetailsVerified: true }, Steps.HasTrn => (AuthenticationState is ({ NationalInsuranceNumberSet: true } or { HasNationalInsuranceNumberSet: true, HasNationalInsuranceNumber: false }) and { ContactDetailsVerified: true }), Steps.Trn => AuthenticationState is { HasTrn: true, ContactDetailsVerified: true }, - Steps.HasQts => AuthenticationState is ({ StatedTrn: { }, OAuthState: { TrnMatchPolicy: Models.TrnMatchPolicy.Default } } or { OAuthState: { TrnMatchPolicy: Models.TrnMatchPolicy.Default }, HasTrnSet: true, HasTrn: false }) and { ContactDetailsVerified: true }, - Steps.IttProvider => AuthenticationState is { OAuthState: { TrnMatchPolicy: Models.TrnMatchPolicy.Default }, AwardedQts: true, ContactDetailsVerified: true }, + Steps.HasQts => AuthenticationState is ({ StatedTrn: { }, OAuthState: { TrnMatchPolicy: TrnMatchPolicy.Default } } or { OAuthState: { TrnMatchPolicy: TrnMatchPolicy.Default }, HasTrnSet: true, HasTrn: false }) and { ContactDetailsVerified: true }, + Steps.IttProvider => AuthenticationState is { OAuthState: { TrnMatchPolicy: TrnMatchPolicy.Default }, AwardedQts: true, ContactDetailsVerified: true }, SignInJourney.Steps.TrnInUse => AuthenticationState.TrnLookup == AuthenticationState.TrnLookupState.ExistingTrnFound, SignInJourney.Steps.TrnInUseResendTrnOwnerEmailConfirmation => AuthenticationState.TrnLookup == AuthenticationState.TrnLookupState.ExistingTrnFound, SignInJourney.Steps.TrnInUseChooseEmail => AuthenticationState.TrnLookup == AuthenticationState.TrnLookupState.EmailOfExistingAccountForTrnVerified, @@ -152,7 +152,7 @@ public override string GetNextStepUrl(string currentStep) => (Steps.HasNiNumber, { HasNationalInsuranceNumber: false }) => shouldCheckAnswers ? CoreSignInJourney.Steps.CheckAnswers : Steps.HasTrn, (Steps.NiNumber, _) => shouldCheckAnswers ? CoreSignInJourney.Steps.CheckAnswers : Steps.HasTrn, (Steps.HasTrn, { HasTrn: true }) => Steps.Trn, - (Steps.HasTrn, { HasTrn: false, OAuthState.TrnMatchPolicy: Models.TrnMatchPolicy.Strict }) => CoreSignInJourney.Steps.CheckAnswers, + (Steps.HasTrn, { HasTrn: false, OAuthState.TrnMatchPolicy: TrnMatchPolicy.Strict }) => CoreSignInJourney.Steps.CheckAnswers, (Steps.HasTrn, { HasTrn: false }) => shouldCheckAnswers ? CoreSignInJourney.Steps.CheckAnswers : Steps.HasQts, (Steps.Trn, _) => shouldCheckAnswers ? CoreSignInJourney.Steps.CheckAnswers : Steps.HasQts, (Steps.HasQts, { AwardedQts: true }) => Steps.IttProvider, @@ -229,8 +229,10 @@ protected override bool AreAllQuestionsAnswered() => AuthenticationState.DateOfBirthSet && AuthenticationState.HasNationalInsuranceNumberSet && (AuthenticationState.NationalInsuranceNumberSet || AuthenticationState.HasNationalInsuranceNumber == false) && - ((AuthenticationState.AwardedQtsSet && - (AuthenticationState.HasIttProviderSet || AuthenticationState.AwardedQts == false) || (AuthenticationState.AwardedQtsSet == false && AuthenticationState?.OAuthState?.TrnMatchPolicy == Models.TrnMatchPolicy.Strict))); + AuthenticationState.HasTrnSet && + (AuthenticationState.StatedTrnSet || AuthenticationState.HasTrn == false) && + (AuthenticationState.AwardedQtsSet && + (AuthenticationState.HasIttProviderSet || AuthenticationState.AwardedQts == false) || (AuthenticationState.AwardedQtsSet == false && AuthenticationState?.OAuthState?.TrnMatchPolicy == TrnMatchPolicy.Strict)); public new static class Steps { diff --git a/dotnet-authserver/tests/TeacherIdentity.AuthServer.EndToEndTests/Register.cs b/dotnet-authserver/tests/TeacherIdentity.AuthServer.EndToEndTests/Register.cs index f4fef35ab..cf71dec16 100644 --- a/dotnet-authserver/tests/TeacherIdentity.AuthServer.EndToEndTests/Register.cs +++ b/dotnet-authserver/tests/TeacherIdentity.AuthServer.EndToEndTests/Register.cs @@ -113,6 +113,10 @@ public async Task NewUser_WithTrnLookup_TrnNotFound_CanRegister_StrictTrnMatchPo await page.SubmitRegisterNiNumberPage(nino); + await page.SubmitRegisterHasTrnPage(hasTrn: true); + + await page.SubmitRegisterTrnPage(trn); + await page.SubmitCheckAnswersPage(); await page.SubmitCompletePageForNewUser(email);