diff --git a/app/controllers/concerns/idv/document_capture_concern.rb b/app/controllers/concerns/idv/document_capture_concern.rb index cc89ac16ba4..88e03b0113a 100644 --- a/app/controllers/concerns/idv/document_capture_concern.rb +++ b/app/controllers/concerns/idv/document_capture_concern.rb @@ -4,21 +4,6 @@ module Idv module DocumentCaptureConcern extend ActiveSupport::Concern - def save_proofing_components(user) - return unless user - - doc_auth_vendor = DocAuthRouter.doc_auth_vendor( - discriminator: document_capture_session_uuid, - analytics: analytics, - ) - - component_attributes = { - document_check: doc_auth_vendor, - document_type: 'state_id', - } - ProofingComponent.create_or_find_by(user: user).update(component_attributes) - end - def successful_response FormResponse.new(success: true) end diff --git a/app/controllers/concerns/idv/verify_info_concern.rb b/app/controllers/concerns/idv/verify_info_concern.rb index cd3a11fdf5d..dc4130916ed 100644 --- a/app/controllers/concerns/idv/verify_info_concern.rb +++ b/app/controllers/concerns/idv/verify_info_concern.rb @@ -203,20 +203,11 @@ def summarize_result_and_rate_limit(summary_result) proofing_results_exception = summary_result.extra.dig(:proofing_results, :exception) resolution_rate_limiter.increment! if proofing_results_exception.blank? - if summary_result.success? - add_proofing_components - else + if !summary_result.success? idv_failure(summary_result) end end - def add_proofing_components - ProofingComponent.create_or_find_by(user: current_user).update( - resolution_check: Idp::Constants::Vendors::LEXIS_NEXIS, - source_check: Idp::Constants::Vendors::AAMVA, - ) - end - def load_async_state dcs_uuid = idv_session.verify_info_step_document_capture_session_uuid dcs = DocumentCaptureSession.find_by(uuid: dcs_uuid) diff --git a/app/controllers/idv/by_mail/request_letter_controller.rb b/app/controllers/idv/by_mail/request_letter_controller.rb index 189682018a1..a65483921d2 100644 --- a/app/controllers/idv/by_mail/request_letter_controller.rb +++ b/app/controllers/idv/by_mail/request_letter_controller.rb @@ -78,8 +78,6 @@ def update_tracking **ab_test_analytics_buckets, ) create_user_event(:gpo_mail_sent, current_user) - - ProofingComponent.find_or_create_by(user: current_user).update(address_check: 'gpo_letter') end def resend_requested? diff --git a/app/controllers/idv/document_capture_controller.rb b/app/controllers/idv/document_capture_controller.rb index 54e43f24b11..b6d06cd75b5 100644 --- a/app/controllers/idv/document_capture_controller.rb +++ b/app/controllers/idv/document_capture_controller.rb @@ -105,7 +105,6 @@ def analytics_arguments def handle_stored_result if stored_result&.success? && selfie_requirement_met? - save_proofing_components(current_user) extract_pii_from_doc(current_user, store_in_session: true) flash[:success] = t('doc_auth.headings.capture_complete') successful_response diff --git a/app/controllers/idv/hybrid_mobile/document_capture_controller.rb b/app/controllers/idv/hybrid_mobile/document_capture_controller.rb index 5b64081c542..f8ae44af6f8 100644 --- a/app/controllers/idv/hybrid_mobile/document_capture_controller.rb +++ b/app/controllers/idv/hybrid_mobile/document_capture_controller.rb @@ -65,7 +65,6 @@ def analytics_arguments def handle_stored_result if stored_result&.success? && selfie_requirement_met? - save_proofing_components(document_capture_user) extract_pii_from_doc(document_capture_user) successful_response else diff --git a/app/controllers/idv/in_person/usps_locations_controller.rb b/app/controllers/idv/in_person/usps_locations_controller.rb index 4367b795ba3..d3889720f15 100644 --- a/app/controllers/idv/in_person/usps_locations_controller.rb +++ b/app/controllers/idv/in_person/usps_locations_controller.rb @@ -47,7 +47,6 @@ def update selected_location_details: update_params.as_json, issuer: current_sp&.issuer, ) - add_proofing_component render json: { success: true }, status: :ok end @@ -58,12 +57,6 @@ def proofer @proofer ||= EnrollmentHelper.usps_proofer end - def add_proofing_component - ProofingComponent. - create_or_find_by(user: current_or_hybrid_user). - update(document_check: Idp::Constants::Vendors::USPS) - end - def handle_error(err) remapped_error = case err when ActionController::InvalidAuthenticityToken, diff --git a/app/controllers/idv/link_sent_controller.rb b/app/controllers/idv/link_sent_controller.rb index b6a34a99b7c..f400db71c87 100644 --- a/app/controllers/idv/link_sent_controller.rb +++ b/app/controllers/idv/link_sent_controller.rb @@ -65,7 +65,6 @@ def analytics_arguments end def handle_document_verification_success - save_proofing_components(current_user) extract_pii_from_doc(current_user, store_in_session: true) idv_session.flow_path = 'hybrid' end diff --git a/app/controllers/idv/personal_key_controller.rb b/app/controllers/idv/personal_key_controller.rb index 4d18dcbc6b1..180cb751cc2 100644 --- a/app/controllers/idv/personal_key_controller.rb +++ b/app/controllers/idv/personal_key_controller.rb @@ -30,7 +30,6 @@ def show if pii_is_missing? redirect_to_retrieve_pii else - add_proofing_component finish_idv_session end end @@ -79,10 +78,6 @@ def next_step end end - def add_proofing_component - ProofingComponent.find_or_create_by(user: current_user).update(verified_at: Time.zone.now) - end - def finish_idv_session @code = personal_key @personal_key_generated_at = current_user.personal_key_generated_at diff --git a/app/controllers/idv/sessions_controller.rb b/app/controllers/idv/sessions_controller.rb index 37d98075582..50bdc27ac86 100644 --- a/app/controllers/idv/sessions_controller.rb +++ b/app/controllers/idv/sessions_controller.rb @@ -9,8 +9,8 @@ class SessionsController < ApplicationController def destroy cancel_processing - clear_session log_analytics + clear_session redirect_to idv_url end diff --git a/app/jobs/resolution_proofing_job.rb b/app/jobs/resolution_proofing_job.rb index a0959d4f7bc..b40b7c4c4c2 100644 --- a/app/jobs/resolution_proofing_job.rb +++ b/app/jobs/resolution_proofing_job.rb @@ -98,7 +98,6 @@ def make_vendor_proofing_requests( ) log_threatmetrix_info(result.device_profiling_result, user) - add_threatmetrix_proofing_component(user.id, result.device_profiling_result) if user.present? CallbackLogData.new( device_profiling_success: result.device_profiling_result.success?, @@ -125,11 +124,4 @@ def logger_info_hash(hash) def progressive_proofer @progressive_proofer ||= Proofing::Resolution::ProgressiveProofer.new end - - def add_threatmetrix_proofing_component(user_id, threatmetrix_result) - ProofingComponent. - create_or_find_by(user_id: user_id). - update(threatmetrix: FeatureManagement.proofing_device_profiling_collecting_enabled?, - threatmetrix_review_status: threatmetrix_result.review_status) - end end diff --git a/app/models/anonymous_user.rb b/app/models/anonymous_user.rb index b871d1a74be..f3b22485419 100644 --- a/app/models/anonymous_user.rb +++ b/app/models/anonymous_user.rb @@ -5,6 +5,10 @@ def uuid 'anonymous-uuid' end + def establishing_in_person_enrollment; end + + def pending_in_person_enrollment; end + def second_factor_locked_at nil end diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index 699e56d39c0..c16c09ccae9 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -887,7 +887,14 @@ def idv_camera_info_logged(flow_path:, camera_info:, **_extra) end # @param [String] step the step that the user was on when they clicked cancel - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The user confirmed their choice to cancel going through IDV @@ -909,7 +916,14 @@ def idv_cancellation_confirmed( end # @param [String] step the step that the user was on when they clicked cancel - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [boolean,nil] cancelled_enrollment Whether the user's IPP enrollment has been canceled # @param [String,nil] enrollment_code IPP enrollment code # @param [Integer,nil] enrollment_id ID of the associated IPP enrollment record @@ -942,7 +956,14 @@ def idv_cancellation_go_back( # @param [String] step the step that the user was on when they clicked cancel # @param [String] request_came_from the controller and action from the # source such as "users/sessions#new" - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The user clicked cancel during IDV (presented with an option to go back or confirm) @@ -1453,7 +1474,14 @@ def idv_doc_auth_welcome_visited(**extra) # @param [Boolean] fraud_rejection # @param [Boolean] gpo_verification_pending # @param [Boolean] in_person_verification_pending - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String, nil] deactivation_reason Reason user's profile was deactivated, if any. # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. @@ -1485,8 +1513,14 @@ def idv_enter_password_submitted( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's - # current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String] address_verification_method The method (phone or gpo) being # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. @@ -1516,7 +1550,14 @@ def idv_enter_password_visited( # @param [Boolean] fraud_rejection Profile is rejected due to fraud # @param [Boolean] gpo_verification_pending Profile is awaiting gpo verification # @param [Boolean] in_person_verification_pending Profile is awaiting in person verification - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # @param [Array,nil] profile_history Array of user's profiles (oldest to newest). @@ -1552,7 +1593,14 @@ def idv_final( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # User visited forgot password page @@ -1571,7 +1619,14 @@ def idv_forgot_password( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # User confirmed forgot password @@ -1717,7 +1772,14 @@ def idv_front_image_clicked( # @param [Integer] hours_since_first_letter Difference between first_letter_requested_at # and now in hours # @param [Integer] phone_step_attempts Number of attempts at phone step before requesting letter - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # GPO letter was enqueued and the time at which it was enqueued @@ -1751,7 +1813,14 @@ def idv_gpo_address_letter_enqueued( # @param [Integer] hours_since_first_letter Difference between first_letter_requested_at # and now in hours # @param [Integer] phone_step_attempts Number of attempts at phone step before requesting letter - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # GPO letter was requested @@ -2212,7 +2281,14 @@ def idv_in_person_ready_to_verify_sp_link_clicked(**extra) ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The user visited the "ready to verify" page for the in person proofing flow @@ -2694,7 +2770,14 @@ def idv_ipp_deactivated_for_never_visiting_post_office( end # The user visited the "letter enqueued" page shown during the verify by mail flow - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # @identity.idp.previous_event_name IdV: come back later visited @@ -2777,7 +2860,14 @@ def idv_not_verified_visited(**extra) # Tracks if a user clicks the 'acknowledge' checkbox during personal # key creation - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [boolean] checked whether the user checked or un-checked # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. @@ -2801,7 +2891,14 @@ def idv_personal_key_acknowledgment_toggled( # A user has downloaded their personal key. This event is no longer emitted. # @identity.idp.previous_event_name IdV: download personal key - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. def idv_personal_key_downloaded( @@ -2819,7 +2916,14 @@ def idv_personal_key_downloaded( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String, nil] deactivation_reason Reason profile was deactivated. # @param [Boolean] fraud_review_pending Profile is under review for fraud # @param [Boolean] fraud_rejection Profile is rejected due to fraud @@ -2853,7 +2957,14 @@ def idv_personal_key_submitted( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String] address_verification_method "phone" or "gpo" # @param [Boolean,nil] in_person_verification_pending # @param [Boolean] encrypted_profiles_missing True if user's session had no encrypted pii @@ -2885,7 +2996,14 @@ def idv_personal_key_visited( # @param [Hash] errors Errors resulting from form validation # @param [Hash] error_details Details for errors that occurred in unsuccessful submission # @param ["sms", "voice"] otp_delivery_preference - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The user submitted their phone on the phone confirmation page @@ -2912,7 +3030,14 @@ def idv_phone_confirmation_form_submitted( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The user was rate limited for submitting too many OTPs during the IDV phone step @@ -2931,7 +3056,14 @@ def idv_phone_confirmation_otp_rate_limit_attempts( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The user was locked out for hitting the phone OTP rate limit during IDV @@ -2950,7 +3082,14 @@ def idv_phone_confirmation_otp_rate_limit_locked_out( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The user was rate limited for requesting too many OTPs during the IDV phone step @@ -2978,7 +3117,14 @@ def idv_phone_confirmation_otp_rate_limit_sends( # @param [Boolean] rate_limit_exceeded whether or not the rate limit was exceeded by this attempt # @param [Hash] telephony_response response from Telephony gem # @param [String] phone_fingerprint Fingerprint string identifying phone number - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # @param [Hash, nil] ab_tests data for ongoing A/B tests @@ -3027,7 +3173,14 @@ def idv_phone_confirmation_otp_resent( # @param [Boolean] rate_limit_exceeded whether or not the rate limit was exceeded by this attempt # @param [String] phone_fingerprint the hmac fingerprint of the phone number formatted as e164 # @param [Hash] telephony_response response from Telephony gem - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [:test, :pinpoint] adapter which adapter the OTP was delivered with # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. @@ -3075,7 +3228,14 @@ def idv_phone_confirmation_otp_sent( # @param [:sms,:voice] otp_delivery_preference # @param [Integer] second_factor_attempts_count number of attempts to confirm this phone # @param [Time, nil] second_factor_locked_at timestamp when the phone was locked out - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # When a user attempts to confirm posession of a new phone number during the IDV process @@ -3110,7 +3270,14 @@ def idv_phone_confirmation_otp_submitted( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # When a user visits the page to confirm posession of a new phone number during the IDV process @@ -3132,7 +3299,14 @@ def idv_phone_confirmation_otp_visit( # @param [Boolean] success Whether form validation was successful # @param [Hash] errors Errors resulting from form validation # @param [Hash] error_details Details for errors that occurred in unsuccessful submission - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The vendor finished the process of confirming the users phone @@ -3161,7 +3335,14 @@ def idv_phone_confirmation_vendor_submitted( # @param [Time] limiter_expires_at when the rate limit expires # @param [Integer] remaining_submit_attempts number of submit attempts remaining # (previously called "remaining_attempts") - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # When a user gets an error during the phone finder flow of IDV @@ -3188,7 +3369,14 @@ def idv_phone_error_visited( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # User visited idv phone of record @@ -3207,7 +3395,14 @@ def idv_phone_of_record_visited( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String] step the step the user was on when they clicked use a different phone number # User decided to use a different phone number in idv def idv_phone_use_different(step:, proofing_components: nil, **extra) @@ -3220,7 +3415,14 @@ def idv_phone_use_different(step:, proofing_components: nil, **extra) end # @identity.idp.previous_event_name IdV: Verify setup errors visited - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # @param [Array,nil] profile_history Array of user's profiles (oldest to newest). @@ -3242,7 +3444,14 @@ def idv_please_call_visited( ) end - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. # The system encountered an error and the proofing results are missing @@ -3552,7 +3761,14 @@ def idv_session_error_visited( # @param [String] step # @param [String] location - # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components + # @param [Hash,nil] proofing_components User's current proofing components + # @option proofing_components [String,nil] 'document_check' Vendor that verified the user's ID + # @option proofing_components [String,nil] 'document_type' Type of ID used to verify + # @option proofing_components [String,nil] 'source_check' Source used to verify user's PII + # @option proofing_components [String,nil] 'resolution_check' Vendor for identity resolution check + # @option proofing_components [String,nil] 'address_check' Method used to verify user's address + # @option proofing_components [Boolean,nil] 'threatmetrix' Whether ThreatMetrix check was done + # @option proofing_components [String,nil] 'threatmetrix_review_status' TMX decision on the user # @param [boolean,nil] cancelled_enrollment Whether the user's IPP enrollment has been canceled # @param [String,nil] enrollment_code IPP enrollment code # @param [Integer,nil] enrollment_id ID of the associated IPP enrollment record diff --git a/app/services/idv/analytics_events_enhancer.rb b/app/services/idv/analytics_events_enhancer.rb index 5645c1f3320..f75fd52f412 100644 --- a/app/services/idv/analytics_events_enhancer.rb +++ b/app/services/idv/analytics_events_enhancer.rb @@ -183,8 +183,20 @@ def profile_history end def proofing_components - return if !user&.respond_to?(:proofing_component) || !user.proofing_component - ProofingComponentsLogging.new(user.proofing_component) + return if !user + + idv_session = Idv::Session.new( + user_session: session&.dig('warden.user.user.session') || {}, + current_user: user, + service_provider: sp, + ) + + proofing_components_hash = ProofingComponents.new( + user:, + idv_session:, + ).to_h + + proofing_components_hash.empty? ? nil : proofing_components_hash end end end diff --git a/app/services/idv/phone_step.rb b/app/services/idv/phone_step.rb index 0ed264ffefd..eb13660adce 100644 --- a/app/services/idv/phone_step.rb +++ b/app/services/idv/phone_step.rb @@ -132,9 +132,6 @@ def failed_due_to_timeout_or_exception? def update_idv_session idv_session.applicant = applicant idv_session.mark_phone_step_started! - - ProofingComponent.find_or_create_by(user: idv_session.current_user). - update(address_check: 'lexis_nexis_address') end def start_phone_confirmation_session diff --git a/app/services/idv/proofing_components.rb b/app/services/idv/proofing_components.rb new file mode 100644 index 00000000000..6300bfd8ff3 --- /dev/null +++ b/app/services/idv/proofing_components.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +module Idv + class ProofingComponents + def initialize( + user:, + idv_session: + ) + @user = user + @idv_session = idv_session + end + + def document_check + if user.establishing_in_person_enrollment || user.pending_in_person_enrollment + Idp::Constants::Vendors::USPS + elsif idv_session.remote_document_capture_complete? + DocAuthRouter.doc_auth_vendor( + discriminator: idv_session.document_capture_session_uuid, + ) + end + end + + def document_type + return 'state_id' if idv_session.remote_document_capture_complete? + end + + def source_check + Idp::Constants::Vendors::AAMVA if idv_session.verify_info_step_complete? + end + + def resolution_check + Idp::Constants::Vendors::LEXIS_NEXIS if idv_session.verify_info_step_complete? + end + + def address_check + if idv_session.verify_by_mail? + 'gpo_letter' + elsif idv_session.address_verification_mechanism == 'phone' + 'lexis_nexis_address' + end + end + + def threatmetrix + if idv_session.threatmetrix_review_status.present? + FeatureManagement.proofing_device_profiling_collecting_enabled? + end + end + + def threatmetrix_review_status + idv_session.threatmetrix_review_status + end + + def to_h + { + document_check:, + document_type:, + source_check:, + resolution_check:, + address_check:, + threatmetrix:, + threatmetrix_review_status:, + + }.compact + end + + private + + attr_reader :user, :idv_session + end +end diff --git a/app/services/idv/proofing_components_logging.rb b/app/services/idv/proofing_components_logging.rb deleted file mode 100644 index d6f31ced71c..00000000000 --- a/app/services/idv/proofing_components_logging.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module Idv - ProofingComponentsLogging = Struct.new(:proofing_components) do - def as_json(*) - proofing_components.slice( - :document_check, - :document_type, - :source_check, - :resolution_check, - :address_check, - :liveness_check, - :device_fingerprinting_vendor, - :threatmetrix, - :threatmetrix_review_status, - :threatmetrix_risk_rating, - :threatmetrix_policy_score, - ).compact - end - end -end diff --git a/app/services/idv/steps/doc_auth_base_step.rb b/app/services/idv/steps/doc_auth_base_step.rb index 1c8ef2ade1b..f5977a4963d 100644 --- a/app/services/idv/steps/doc_auth_base_step.rb +++ b/app/services/idv/steps/doc_auth_base_step.rb @@ -9,21 +9,6 @@ def initialize(flow) private - def save_proofing_components - return unless current_user - - doc_auth_vendor = DocAuthRouter.doc_auth_vendor( - discriminator: flow_session[document_capture_session_uuid_key], - analytics: @flow.analytics, - ) - - component_attributes = { - document_check: doc_auth_vendor, - document_type: 'state_id', - } - ProofingComponent.create_or_find_by(user: current_user).update(component_attributes) - end - def user_id_from_token flow_session[:doc_capture_user_id] end diff --git a/spec/controllers/idv/in_person/usps_locations_controller_spec.rb b/spec/controllers/idv/in_person/usps_locations_controller_spec.rb index 8d0a7228a43..4a5fe60ca39 100644 --- a/spec/controllers/idv/in_person/usps_locations_controller_spec.rb +++ b/spec/controllers/idv/in_person/usps_locations_controller_spec.rb @@ -271,14 +271,6 @@ expect(enrollment.service_provider).to be_nil end - it 'updates proofing component vendor' do - expect(user.proofing_component&.document_check).to be_nil - - response - - expect(user.proofing_component.document_check).to eq Idp::Constants::Vendors::USPS - end - context 'when unauthenticated' do let(:user) { nil } diff --git a/spec/controllers/idv/link_sent_controller_spec.rb b/spec/controllers/idv/link_sent_controller_spec.rb index 6cd1f023328..122472e285b 100644 --- a/spec/controllers/idv/link_sent_controller_spec.rb +++ b/spec/controllers/idv/link_sent_controller_spec.rb @@ -155,12 +155,7 @@ context 'document capture session successful' do it 'redirects to ssn page' do put :update - expect(response).to redirect_to(idv_ssn_url) - - pc = ProofingComponent.find_by(user_id: user.id) - expect(pc.document_check).to eq('mock') - expect(pc.document_type).to eq('state_id') end context 'redo document capture' do diff --git a/spec/features/idv/analytics_spec.rb b/spec/features/idv/analytics_spec.rb index 2da550bb912..8c55e9cb1b2 100644 --- a/spec/features/idv/analytics_spec.rb +++ b/spec/features/idv/analytics_spec.rb @@ -776,6 +776,7 @@ and_return(proofing_device_profiling) allow_any_instance_of(ApplicationController).to receive(:analytics) do |controller| fake_analytics.user = controller.analytics_user + fake_analytics.session = controller.session fake_analytics end allow(IdentityConfig.store).to receive(:idv_acuant_sdk_upgrade_a_b_testing_enabled). diff --git a/spec/features/idv/cancel_spec.rb b/spec/features/idv/cancel_spec.rb index 9f2592914be..0eddb6e18d0 100644 --- a/spec/features/idv/cancel_spec.rb +++ b/spec/features/idv/cancel_spec.rb @@ -13,7 +13,11 @@ start_idv_from_sp(sp) sign_in_and_2fa_user(user) complete_doc_auth_steps_before_agreement_step - allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) + + allow_any_instance_of(ApplicationController).to receive(:analytics) do |controller| + fake_analytics.session = controller.session + fake_analytics + end end it 'shows the user a cancellation message with the option to go back to the step' do diff --git a/spec/features/idv/end_to_end_idv_spec.rb b/spec/features/idv/end_to_end_idv_spec.rb index b26d4f711b7..832e4391d38 100644 --- a/spec/features/idv/end_to_end_idv_spec.rb +++ b/spec/features/idv/end_to_end_idv_spec.rb @@ -33,7 +33,7 @@ validate_verify_info_page complete_verify_step - validate_verify_info_submit(user) + validate_verify_info_submit validate_phone_page try_to_skip_ahead_from_phone @@ -251,10 +251,8 @@ def validate_verify_info_page expect(page).to have_text(DocAuthHelper::GOOD_SSN) end - def validate_verify_info_submit(user) + def validate_verify_info_submit expect(page).to have_content(t('doc_auth.forms.doc_success')) - expect(user.proofing_component.resolution_check).to eq(Idp::Constants::Vendors::LEXIS_NEXIS) - expect(user.proofing_component.source_check).to eq(Idp::Constants::Vendors::AAMVA) end def validate_phone_page diff --git a/spec/features/idv/proofing_components_spec.rb b/spec/features/idv/proofing_components_spec.rb deleted file mode 100644 index 9849497c69d..00000000000 --- a/spec/features/idv/proofing_components_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'proofing components', allowed_extra_analytics: [:*] do - include DocAuthHelper - include IdvHelper - include SamlAuthHelper - - describe 'proofing jobs' do - let(:email) { 'test@test.com' } - let(:user) { User.find_with_email(email) } - - before do - allow(IdentityConfig.store).to receive(:ruby_workers_idv_enabled). - and_return(ruby_workers_idv_enabled) - - visit_idp_from_sp_with_ial2(:oidc) - register_user(email) - - expect(current_path).to eq idv_welcome_path - - complete_all_doc_auth_steps_before_password_step - fill_in 'Password', with: Features::SessionHelper::VALID_PASSWORD - click_continue - acknowledge_and_confirm_personal_key - end - - context 'sync proofing', js: true do - let(:ruby_workers_idv_enabled) { false } - - it 'records proofing components' do - proofing_components = user.active_profile.proofing_components - expect(proofing_components['document_check']).to eq('mock') - expect(proofing_components['document_type']).to eq('state_id') - end - end - end -end diff --git a/spec/features/multiple_emails/sign_in_spec.rb b/spec/features/multiple_emails/sign_in_spec.rb index 4a642b78ce6..e047eb50bbb 100644 --- a/spec/features/multiple_emails/sign_in_spec.rb +++ b/spec/features/multiple_emails/sign_in_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.feature 'sign in with any email address', allowed_extra_analytics: [:*] do +RSpec.feature 'sign in with any email address' do scenario 'signing in with any email address' do user = create(:user, :fully_registered, :with_multiple_emails) diff --git a/spec/jobs/resolution_proofing_job_spec.rb b/spec/jobs/resolution_proofing_job_spec.rb index d4c2db323c2..d68b8e72e54 100644 --- a/spec/jobs/resolution_proofing_job_spec.rb +++ b/spec/jobs/resolution_proofing_job_spec.rb @@ -128,10 +128,6 @@ expect(result_context_stages_threatmetrix[:response_body]).to eq( JSON.parse(LexisNexisFixtures.ddp_success_redacted_response_json, symbolize_names: true), ) - - proofing_component = user.proofing_component - expect(proofing_component.threatmetrix).to equal(true) - expect(proofing_component.threatmetrix_review_status).to eq('pass') end end @@ -322,10 +318,6 @@ expect(result_context_stages_threatmetrix[:client]).to eq('tmx_disabled') expect(@threatmetrix_stub).to_not have_been_requested - - proofing_component = user.proofing_component - expect(proofing_component.threatmetrix).to equal(false) - expect(proofing_component.threatmetrix_review_status).to eq('pass') end end @@ -453,10 +445,6 @@ expect(result_context_stages_threatmetrix[:response_body]).to eq( JSON.parse(LexisNexisFixtures.ddp_success_redacted_response_json, symbolize_names: true), ) - - proofing_component = user.proofing_component - expect(proofing_component.threatmetrix).to equal(true) - expect(proofing_component.threatmetrix_review_status).to eq('pass') end end diff --git a/spec/services/idv/analytics_events_enhancer_spec.rb b/spec/services/idv/analytics_events_enhancer_spec.rb index 874e23f4069..a553f623b4e 100644 --- a/spec/services/idv/analytics_events_enhancer_spec.rb +++ b/spec/services/idv/analytics_events_enhancer_spec.rb @@ -3,7 +3,15 @@ RSpec.describe Idv::AnalyticsEventsEnhancer do let(:user) { build(:user) } let(:sp) { nil } - let(:session) { nil } + let(:user_session) { nil } + let(:session) do + if user_session.present? + { + 'warden.user.user.session' => user_session, + } + end + end + let(:analytics_class) do Class.new(FakeAnalytics) do include AnalyticsEvents @@ -63,11 +71,7 @@ def track_event(_event, **kwargs) end describe 'proofing_components' do - let(:proofing_components) { nil } - - before do - user.proofing_component = proofing_components - end + let(:user_session) { {} } context 'without proofing component' do it 'calls analytics method with original attributes' do @@ -79,17 +83,26 @@ def track_event(_event, **kwargs) end end - context 'with proofing component' do - let(:proofing_components) do - ProofingComponent.new(source_check: Idp::Constants::Vendors::AAMVA) + context 'with proofing components' do + before do + # Set up the user_session so it looks like the user's been through doc auth + idv_session = Idv::Session.new( + user_session:, + current_user: user, + service_provider: sp, + ) + idv_session.pii_from_doc = Idp::Constants::MOCK_IDV_APPLICANT end it 'calls analytics method with original attributes and proofing_components' do analytics.idv_test_method(extra: true) - expect(analytics.called_kwargs).to match( + expect(analytics.called_kwargs).to eql( extra: true, - proofing_components: kind_of(Idv::ProofingComponentsLogging), + proofing_components: { + document_check: 'mock', + document_type: 'state_id', + }, ) end end diff --git a/spec/services/idv/profile_maker_spec.rb b/spec/services/idv/profile_maker_spec.rb index 6736bcba24e..f7ac8d035c8 100644 --- a/spec/services/idv/profile_maker_spec.rb +++ b/spec/services/idv/profile_maker_spec.rb @@ -18,7 +18,6 @@ end it 'creates an inactive Profile with encrypted PII' do - proofing_component = ProofingComponent.create(user_id: user.id, document_check: 'mock') profile = subject.save_profile( fraud_pending_reason: nil, gpo_verification_needed: false, @@ -32,7 +31,6 @@ expect(profile.encrypted_pii).to_not be_nil expect(profile.encrypted_pii).to_not match('Some') expect(profile.fraud_pending_reason).to be_nil - expect(profile.proofing_components).to match(proofing_component.as_json) expect(profile.active).to eq(false) expect(profile.deactivation_reason).to be_nil diff --git a/spec/services/idv/proofing_components_logging_spec.rb b/spec/services/idv/proofing_components_logging_spec.rb deleted file mode 100644 index b270a722c8d..00000000000 --- a/spec/services/idv/proofing_components_logging_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'rails_helper' - -RSpec.describe Idv::ProofingComponentsLogging do - describe '#as_json' do - it 'returns hash with nil values omitted' do - proofing_components = ProofingComponent.new(document_check: Idp::Constants::Vendors::AAMVA) - logging = described_class.new(proofing_components) - - expect(logging.as_json).to eq('document_check' => Idp::Constants::Vendors::AAMVA) - end - end -end diff --git a/spec/services/idv/proofing_components_spec.rb b/spec/services/idv/proofing_components_spec.rb new file mode 100644 index 00000000000..d6bd1b81b73 --- /dev/null +++ b/spec/services/idv/proofing_components_spec.rb @@ -0,0 +1,243 @@ +require 'rails_helper' + +RSpec.describe Idv::ProofingComponents do + let(:user) { create(:user) } + + let(:user_session) { {} } + + let(:idv_session) do + Idv::Session.new( + current_user: user, + user_session:, + service_provider: nil, + ).tap do |idv_session| + idv_session.pii_from_doc = pii_from_doc + end + end + + let(:pii_from_doc) { nil } + + subject do + described_class.new( + user:, + idv_session:, + ) + end + + describe '#to_h' do + let(:pii_from_doc) { Idp::Constants::MOCK_IDV_APPLICANT } + + before do + allow(IdentityConfig.store).to receive(:doc_auth_vendor).and_return('test_vendor') + idv_session.mark_verify_info_step_complete! + idv_session.address_verification_mechanism = 'gpo' + allow(FeatureManagement).to receive(:proofing_device_profiling_collecting_enabled?). + and_return(true) + idv_session.threatmetrix_review_status = 'pass' + end + + it 'returns expected result' do + expect(subject.to_h).to eql( + { + document_check: 'test_vendor', + document_type: 'state_id', + source_check: 'aamva', + resolution_check: 'lexis_nexis', + address_check: 'gpo_letter', + threatmetrix: true, + threatmetrix_review_status: 'pass', + }, + ) + end + end + + describe '#document_check' do + it 'returns nil by default' do + expect(subject.document_check).to be_nil + end + + context 'in-person proofing' do + context 'establishing' do + let!(:enrollment) { create(:in_person_enrollment, :establishing, user:) } + it 'returns USPS' do + expect(subject.document_check).to eql(Idp::Constants::Vendors::USPS) + end + end + + context 'pending' do + let!(:enrollment) { create(:in_person_enrollment, :pending, user:) } + it 'returns USPS' do + expect(subject.document_check).to eql(Idp::Constants::Vendors::USPS) + end + end + end + + context 'doc auth' do + before do + allow(IdentityConfig.store).to receive(:doc_auth_vendor).and_return('test_vendor') + end + context 'before doc auth complete' do + it 'returns nil' do + expect(subject.document_check).to be_nil + end + end + context 'after doc auth completed successfully' do + let(:pii_from_doc) { Idp::Constants::MOCK_IDV_APPLICANT } + it 'returns doc auth vendor' do + expect(subject.document_check).to eql('test_vendor') + end + end + end + end + + describe '#document_type' do + context 'in-person proofing' do + context 'establishing' do + let!(:enrollment) { create(:in_person_enrollment, :establishing, user:) } + it 'returns nil' do + expect(subject.document_type).to be_nil + end + end + + context 'pending' do + let!(:enrollment) { create(:in_person_enrollment, :pending, user:) } + it 'returns nil' do + expect(subject.document_type).to be_nil + end + end + end + + context 'doc auth' do + context 'before doc auth complete' do + it 'returns nil' do + expect(subject.document_type).to be_nil + end + end + context 'after doc auth completed successfully' do + let(:pii_from_doc) { Idp::Constants::MOCK_IDV_APPLICANT } + it 'returns doc auth vendor' do + expect(subject.document_type).to eql('state_id') + end + end + end + end + + describe '#source_check' do + it 'returns nil by default' do + expect(subject.source_check).to be_nil + end + + context 'after verification' do + before do + idv_session.mark_verify_info_step_complete! + end + + it 'returns aamva' do + expect(subject.source_check).to eql(Idp::Constants::Vendors::AAMVA) + end + end + end + + describe '#resolution_check' do + it 'returns nil by default' do + expect(subject.resolution_check).to be_nil + end + + context 'after verification' do + before do + idv_session.mark_verify_info_step_complete! + end + + it 'returns LexisNexis' do + expect(subject.resolution_check).to eql(Idp::Constants::Vendors::LEXIS_NEXIS) + end + end + end + + describe '#address_check' do + it 'returns nil by default' do + expect(subject.address_check).to be_nil + end + + context 'in GPO flow' do + before do + idv_session.address_verification_mechanism = 'gpo' + end + + it 'returns gpo_letter' do + expect(subject.address_check).to eql('gpo_letter') + end + end + + context 'using phone verification' do + before do + idv_session.mark_phone_step_started! + end + + it 'returns lexis_nexis_address' do + expect(subject.address_check).to eql('lexis_nexis_address') + end + end + end + + describe '#threatmetrix' do + context 'device profiling collecting enabled' do + before do + allow(FeatureManagement).to receive(:proofing_device_profiling_collecting_enabled?). + and_return(true) + end + + context 'threatmetrix_review_status present' do + before do + idv_session.threatmetrix_review_status = 'pass' + end + it 'returns true' do + expect(subject.threatmetrix).to be_truthy + end + end + context 'threatmetrix_review_status not present' do + it 'returns nil' do + expect(subject.threatmetrix).to be_nil + end + end + end + + context 'device profiling collecting disabled' do + before do + allow(FeatureManagement).to receive(:proofing_device_profiling_collecting_enabled?). + and_return(false) + end + + context 'threatmetrix_review_status present' do + before do + idv_session.threatmetrix_review_status = 'pass' + end + it 'returns false' do + expect(subject.threatmetrix).to eql(false) + end + end + + context 'threatmetrix_review_status not present' do + it 'returns nil' do + expect(subject.threatmetrix).to be_nil + end + end + end + end + + describe '#threatmetrix_review_status' do + context 'threatmetrix_review_status present in idv_session' do + before do + idv_session.threatmetrix_review_status = 'pass' + end + it 'returns value' do + expect(subject.threatmetrix_review_status).to eql('pass') + end + end + context 'threatmetrix_review_status not present in idv_session' do + it 'returns nil' do + expect(subject.threatmetrix_review_status).to be_nil + end + end + end +end diff --git a/spec/support/fake_analytics.rb b/spec/support/fake_analytics.rb index e456e629275..a8dbe00ca24 100644 --- a/spec/support/fake_analytics.rb +++ b/spec/support/fake_analytics.rb @@ -150,6 +150,7 @@ def option_param_names(instance_method) attr_reader :events attr_accessor :user + attr_accessor :session def initialize(user: AnonymousUser.new, sp: nil, session: nil) @events = Hash.new @@ -159,7 +160,7 @@ def initialize(user: AnonymousUser.new, sp: nil, session: nil) end def track_event(event, attributes = {}) - if attributes[:proofing_components].instance_of?(Idv::ProofingComponentsLogging) + if attributes[:proofing_components].instance_of?(Idv::ProofingComponents) attributes[:proofing_components] = attributes[:proofing_components].as_json.symbolize_keys end events[event] ||= []