From 70130b0af834fd3d299e789520ac6162c8a5ffb7 Mon Sep 17 00:00:00 2001 From: Kenneth Lee Date: Fri, 6 Sep 2024 16:05:54 +0100 Subject: [PATCH 1/3] LUPEYALPHA-955 - Add identity confirmation task to FE that auto passes * Show task outcome with OneLogin timestamp * Tidy up status tags with tasks --- app/helpers/admin/claims_helper.rb | 2 +- .../claim_verifiers/identity.rb | 8 ++- .../policies/further_education_payments.rb | 1 + app/views/admin/tasks/_task_outcome.html.erb | 2 + .../tasks/identity_confirmation.html.erb | 2 +- .../provider/verify_claim_form_spec.rb | 6 +- spec/helpers/admin/claims_helper_spec.rb | 60 ++++++++++++++++++- .../claim_verifiers/identity_spec.rb | 48 ++++++++++++++- 8 files changed, 115 insertions(+), 14 deletions(-) diff --git a/app/helpers/admin/claims_helper.rb b/app/helpers/admin/claims_helper.rb index e91e6ff0b6..dab5855f56 100644 --- a/app/helpers/admin/claims_helper.rb +++ b/app/helpers/admin/claims_helper.rb @@ -116,7 +116,7 @@ def matching_attributes(first_claim, second_claim) def identity_confirmation_task_claim_verifier_match_status_tag(claim) task = claim.tasks.detect { |t| t.name == "identity_confirmation" } - if task.nil? || task.claim_verifier_match.nil? + if task.nil? status = "Unverified" status_colour = "grey" elsif task.passed? diff --git a/app/models/automated_checks/claim_verifiers/identity.rb b/app/models/automated_checks/claim_verifiers/identity.rb index c6d31d8cc3..0ccb183f7e 100644 --- a/app/models/automated_checks/claim_verifiers/identity.rb +++ b/app/models/automated_checks/claim_verifiers/identity.rb @@ -18,9 +18,7 @@ def perform return unless awaiting_task?(TASK_NAME) # Order of matching matters so that subsequent conditions in methods fall through to execute the right thing - no_match || - partial_match || - complete_match + auto_pass || no_match || partial_match || complete_match end private @@ -28,6 +26,10 @@ def perform attr_accessor :admin_user, :claim attr_reader :dqt_teacher_status + def auto_pass + create_task(match: nil, passed: true) if claim.policy.further_education_payments? + end + def dqt_teacher_status=(dqt_teacher_status) @dqt_teacher_status = if dqt_teacher_status.instance_of?(Array) dqt_teacher_status.first diff --git a/app/models/policies/further_education_payments.rb b/app/models/policies/further_education_payments.rb index 419870e3f6..9f94236208 100644 --- a/app/models/policies/further_education_payments.rb +++ b/app/models/policies/further_education_payments.rb @@ -10,6 +10,7 @@ module FurtherEducationPayments MIN_QA_THRESHOLD = 10 VERIFIERS = [ + AutomatedChecks::ClaimVerifiers::Identity, AutomatedChecks::ClaimVerifiers::ProviderVerification, AutomatedChecks::ClaimVerifiers::Employment ] diff --git a/app/views/admin/tasks/_task_outcome.html.erb b/app/views/admin/tasks/_task_outcome.html.erb index 2f6d695684..88a108b089 100644 --- a/app/views/admin/tasks/_task_outcome.html.erb +++ b/app/views/admin/tasks/_task_outcome.html.erb @@ -10,6 +10,8 @@ This task was performed by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.updated_at) %> <% elsif task.created_by %> This task was performed by an automated check uploaded by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.created_at) %> + <% elsif onelogin_auth_at = task.claim.onelogin_auth_at %> + This task was performed by GOV.UK One Login on <%= l(onelogin_auth_at) %> <% else %> This task was performed by an automated check on <%= l(task.created_at) %> <% end %> diff --git a/app/views/admin/tasks/identity_confirmation.html.erb b/app/views/admin/tasks/identity_confirmation.html.erb index 2efe3073c6..0a31d5edbf 100644 --- a/app/views/admin/tasks/identity_confirmation.html.erb +++ b/app/views/admin/tasks/identity_confirmation.html.erb @@ -10,7 +10,7 @@

<%= @current_task_name.humanize %>

- <% unless @claim.identity_verified? %> + <% unless @claim.identity_verified? || @tasks_presenter.identity_confirmation.empty? %>
<%= render "admin/claims/answers", answers: @tasks_presenter.identity_confirmation %>
diff --git a/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb b/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb index 4e99995eda..0f1422b821 100644 --- a/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb +++ b/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb @@ -332,10 +332,8 @@ ) end - it "creates the provider verification task" do - task = claim.reload.tasks.last - - expect(task.name).to eq("provider_verification") + it "creates a provider verification task" do + task = claim.reload.tasks.find_by(name: "provider_verification") expect(task.created_by.email).to eq( "seymour.skinner@springfield-elementary.edu" diff --git a/spec/helpers/admin/claims_helper_spec.rb b/spec/helpers/admin/claims_helper_spec.rb index 432dfb5ae7..daddd44ee1 100644 --- a/spec/helpers/admin/claims_helper_spec.rb +++ b/spec/helpers/admin/claims_helper_spec.rb @@ -227,7 +227,61 @@ end end - context "with task" do + context "with task passed nil" do + let(:claim_tasks) do + [ + build( + :task, + claim_verifier_match: task_claim_verifier_match, + name: "identity_confirmation", + passed: nil + ) + ] + end + + context "with task claim verifier match any" do + let(:task_claim_verifier_match) { :any } + + it "returns partial match status tag" do + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Partial match") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--yellow") + end + end + + context "with task claim verifier match none" do + let(:task_claim_verifier_match) { :none } + + it "returns no match status tag" do + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("No match") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--red") + end + end + end + + # TODO: Don't think this condition is ever used as identity confirmation task is never failed + # However adding this purely for coverage of the condition that is available + context "with task passed false" do + let(:claim_tasks) do + [ + build( + :task, + claim_verifier_match: nil, + name: "identity_confirmation", + passed: false + ) + ] + end + + it "returns failed task status tag" do + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Failed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--red") + end + end + + context "with task passed true" do let(:claim_tasks) do [ build( @@ -243,9 +297,9 @@ let(:task_claim_verifier_match) { nil } it "returns unverified task status tag" do - expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Unverified") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Passed") expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") - expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--grey") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--green") end end diff --git a/spec/models/automated_checks/claim_verifiers/identity_spec.rb b/spec/models/automated_checks/claim_verifiers/identity_spec.rb index b5e18c3aa4..b68e04f3b8 100644 --- a/spec/models/automated_checks/claim_verifiers/identity_spec.rb +++ b/spec/models/automated_checks/claim_verifiers/identity_spec.rb @@ -63,6 +63,50 @@ module ClaimVerifiers } end + describe "#perform with auto pass for FurtherEducationPayments" do + let(:policy) { Policies::FurtherEducationPayments } + let(:data) do + { + dob: claim_arg.date_of_birth, + name: claim_arg.full_name, + nino: claim_arg.national_insurance_number, + trn: claim_arg.eligibility.teacher_reference_number + } + end + + subject(:perform) { identity.perform } + + describe "identity confirmation task" do + subject(:identity_confirmation_task) { claim_arg.tasks.find_by(name: "identity_confirmation") } + + before { perform } + + describe "#claim_verifier_match" do + subject(:claim_verifier_match) { identity_confirmation_task.claim_verifier_match } + + it { is_expected.to eq nil } + end + + describe "#passed" do + subject(:passed) { identity_confirmation_task.passed } + + it { is_expected.to eq true } + end + + describe "#created_by" do + subject(:created_by) { identity_confirmation_task.created_by } + + it { is_expected.to eq nil } + end + + describe "#manual" do + subject(:manual) { identity_confirmation_task.manual } + + it { is_expected.to eq false } + end + end + end + describe "#perform" do subject(:perform) { identity.perform } @@ -553,7 +597,7 @@ module ClaimVerifiers national_insurance_number: "QQ100000C", reference: "AB123456", surname: "ELIGIBLE", - tasks: [build(:task, name: :identity_confirmation)], + tasks: [build(:task, name: :identity_confirmation, claim_verifier_match: :all)], eligibility_attributes: {teacher_reference_number: "1234567"} ) end @@ -568,7 +612,7 @@ module ClaimVerifiers describe "#claim_verifier_match" do subject(:claim_verifier_match) { identity_confirmation_task.claim_verifier_match } - it { is_expected.to eq nil } + it { is_expected.to eq "all" } end describe "#created_by" do From 0a7ee66a35e0d650984dfe7a215927ebffb94739 Mon Sep 17 00:00:00 2001 From: Kenneth Lee Date: Fri, 6 Sep 2024 18:08:48 +0100 Subject: [PATCH 2/3] Delegate to policy to decide auto pass logic and include failure --- .../claim_verifiers/identity.rb | 9 ++++++- app/models/base_policy.rb | 4 +++ .../policies/further_education_payments.rb | 4 +++ app/views/admin/tasks/_task_outcome.html.erb | 4 +-- .../claim_verifiers/identity_spec.rb | 25 ++++++++++++++++--- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/app/models/automated_checks/claim_verifiers/identity.rb b/app/models/automated_checks/claim_verifiers/identity.rb index 0ccb183f7e..2bd9f5d9bc 100644 --- a/app/models/automated_checks/claim_verifiers/identity.rb +++ b/app/models/automated_checks/claim_verifiers/identity.rb @@ -27,7 +27,14 @@ def perform attr_reader :dqt_teacher_status def auto_pass - create_task(match: nil, passed: true) if claim.policy.further_education_payments? + case claim.policy.auto_pass_identity_confirmation_task(claim) + when :pass + create_task(match: nil, passed: true) + when :fail + create_task(match: nil, passed: false) + when :skip + nil + end end def dqt_teacher_status=(dqt_teacher_status) diff --git a/app/models/base_policy.rb b/app/models/base_policy.rb index 7ce56a6c5d..a551f5d9e8 100644 --- a/app/models/base_policy.rb +++ b/app/models/base_policy.rb @@ -54,4 +54,8 @@ def international_relocation_payments? def further_education_payments? to_s == "FurtherEducationPayments" end + + def auto_pass_identity_confirmation_task(claim) + :skip + end end diff --git a/app/models/policies/further_education_payments.rb b/app/models/policies/further_education_payments.rb index 9f94236208..0eb9758c2f 100644 --- a/app/models/policies/further_education_payments.rb +++ b/app/models/policies/further_education_payments.rb @@ -40,5 +40,9 @@ def verification_due_date_for_claim(claim) def duplicate_claim?(claim) Claim::MatchingAttributeFinder.new(claim).matching_claims.exists? end + + def auto_pass_identity_confirmation_task(claim) + claim.identity_confirmed_with_onelogin? ? :pass : :fail + end end end diff --git a/app/views/admin/tasks/_task_outcome.html.erb b/app/views/admin/tasks/_task_outcome.html.erb index 88a108b089..56b1e1ac5e 100644 --- a/app/views/admin/tasks/_task_outcome.html.erb +++ b/app/views/admin/tasks/_task_outcome.html.erb @@ -10,8 +10,8 @@ This task was performed by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.updated_at) %> <% elsif task.created_by %> This task was performed by an automated check uploaded by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.created_at) %> - <% elsif onelogin_auth_at = task.claim.onelogin_auth_at %> - This task was performed by GOV.UK One Login on <%= l(onelogin_auth_at) %> + <% elsif task.claim.identity_confirmed_with_onelogin? %> + This task was performed by GOV.UK One Login on <%= l(task.claim.onelogin_idv_at) %> <% else %> This task was performed by an automated check on <%= l(task.created_at) %> <% end %> diff --git a/spec/models/automated_checks/claim_verifiers/identity_spec.rb b/spec/models/automated_checks/claim_verifiers/identity_spec.rb index b68e04f3b8..13c271ec20 100644 --- a/spec/models/automated_checks/claim_verifiers/identity_spec.rb +++ b/spec/models/automated_checks/claim_verifiers/identity_spec.rb @@ -27,6 +27,8 @@ module ClaimVerifiers ) end + let(:identity_confirmed_with_onelogin) { nil } + let(:claim_arg) do claim = create( :claim, @@ -36,7 +38,8 @@ module ClaimVerifiers national_insurance_number: "QQ100000C", reference: "AB123456", surname: "ELIGIBLE", - policy: policy + policy: policy, + identity_confirmed_with_onelogin: identity_confirmed_with_onelogin ) policy_underscored = policy.to_s.underscore @@ -77,6 +80,8 @@ module ClaimVerifiers subject(:perform) { identity.perform } describe "identity confirmation task" do + let(:identity_confirmed_with_onelogin) { true } + subject(:identity_confirmation_task) { claim_arg.tasks.find_by(name: "identity_confirmation") } before { perform } @@ -87,10 +92,22 @@ module ClaimVerifiers it { is_expected.to eq nil } end - describe "#passed" do - subject(:passed) { identity_confirmation_task.passed } + context "identity_confirmed_with_onelogin true" do + describe "#passed" do + subject(:passed) { identity_confirmation_task.passed } + + it { is_expected.to eq true } + end + end + + context "identity_confirmed_with_onelogin false" do + let(:identity_confirmed_with_onelogin) { false } - it { is_expected.to eq true } + describe "#passed" do + subject(:passed) { identity_confirmation_task.passed } + + it { is_expected.to eq false } + end end describe "#created_by" do From 8d928f08be23ca772c42cfe7b7b3e1eadb783758 Mon Sep 17 00:00:00 2001 From: Kenneth Lee Date: Sat, 7 Sep 2024 17:19:15 +0100 Subject: [PATCH 3/3] Ensure OL task outcome is specific to identity confirmation and OL --- app/models/task.rb | 4 ++++ app/views/admin/tasks/_task_outcome.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/task.rb b/app/models/task.rb index fe3d9d7af5..b6d2f46682 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -47,4 +47,8 @@ class Task < ApplicationRecord def to_param name end + + def identity_confirmation? + name == "identity_confirmation" + end end diff --git a/app/views/admin/tasks/_task_outcome.html.erb b/app/views/admin/tasks/_task_outcome.html.erb index 56b1e1ac5e..21fe35d047 100644 --- a/app/views/admin/tasks/_task_outcome.html.erb +++ b/app/views/admin/tasks/_task_outcome.html.erb @@ -10,7 +10,7 @@ This task was performed by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.updated_at) %> <% elsif task.created_by %> This task was performed by an automated check uploaded by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.created_at) %> - <% elsif task.claim.identity_confirmed_with_onelogin? %> + <% elsif task.identity_confirmation? && task.claim.identity_confirmed_with_onelogin? %> This task was performed by GOV.UK One Login on <%= l(task.claim.onelogin_idv_at) %> <% else %> This task was performed by an automated check on <%= l(task.created_at) %>