Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ Layout/IndentationConsistency:

Layout/IndentationStyle:
Enabled: true
IndentationWidth: null

Layout/IndentationWidth:
Enabled: true

Layout/InitialIndentation:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion app/forms/idv/api_image_upload_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def image_metadata
to_h.
transform_values do |str|
JSON.parse(str)
rescue JSON::ParserError
rescue JSON::ParserError
nil
end.
compact.
Expand Down
25 changes: 13 additions & 12 deletions app/jobs/address_proofing_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,18 @@ def perform(user_id:, issuer:, result_id:, encrypted_arguments:, trace_id:)
private

def address_proofer
@address_proofer ||= if IdentityConfig.store.proofer_mock_fallback
Proofing::Mock::AddressMockClient.new
else
Proofing::LexisNexis::PhoneFinder::Proofer.new(
phone_finder_workflow: IdentityConfig.store.lexisnexis_phone_finder_workflow,
account_id: IdentityConfig.store.lexisnexis_account_id,
base_url: IdentityConfig.store.lexisnexis_base_url,
username: IdentityConfig.store.lexisnexis_username,
password: IdentityConfig.store.lexisnexis_password,
request_mode: IdentityConfig.store.lexisnexis_request_mode,
)
end
@address_proofer ||=
if IdentityConfig.store.proofer_mock_fallback
Proofing::Mock::AddressMockClient.new
else
Proofing::LexisNexis::PhoneFinder::Proofer.new(
phone_finder_workflow: IdentityConfig.store.lexisnexis_phone_finder_workflow,
account_id: IdentityConfig.store.lexisnexis_account_id,
base_url: IdentityConfig.store.lexisnexis_base_url,
username: IdentityConfig.store.lexisnexis_username,
password: IdentityConfig.store.lexisnexis_password,
request_mode: IdentityConfig.store.lexisnexis_request_mode,
)
end
end
end
52 changes: 27 additions & 25 deletions app/jobs/resolution_proofing_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,33 +187,35 @@ def proof_state_id(applicant_pii:, result:)
end

def resolution_proofer
@resolution_proofer ||= if IdentityConfig.store.proofer_mock_fallback
Proofing::Mock::ResolutionMockClient.new
else
Proofing::LexisNexis::InstantVerify::Proofer.new(
instant_verify_workflow: IdentityConfig.store.lexisnexis_instant_verify_workflow,
account_id: IdentityConfig.store.lexisnexis_account_id,
base_url: IdentityConfig.store.lexisnexis_base_url,
username: IdentityConfig.store.lexisnexis_username,
password: IdentityConfig.store.lexisnexis_password,
request_mode: IdentityConfig.store.lexisnexis_request_mode,
)
end
@resolution_proofer ||=
if IdentityConfig.store.proofer_mock_fallback
Proofing::Mock::ResolutionMockClient.new
else
Proofing::LexisNexis::InstantVerify::Proofer.new(
instant_verify_workflow: IdentityConfig.store.lexisnexis_instant_verify_workflow,
account_id: IdentityConfig.store.lexisnexis_account_id,
base_url: IdentityConfig.store.lexisnexis_base_url,
username: IdentityConfig.store.lexisnexis_username,
password: IdentityConfig.store.lexisnexis_password,
request_mode: IdentityConfig.store.lexisnexis_request_mode,
)
end
end

def state_id_proofer
@state_id_proofer ||= if IdentityConfig.store.proofer_mock_fallback
Proofing::Mock::StateIdMockClient.new
else
Proofing::Aamva::Proofer.new(
auth_request_timeout: IdentityConfig.store.aamva_auth_request_timeout,
auth_url: IdentityConfig.store.aamva_auth_url,
cert_enabled: IdentityConfig.store.aamva_cert_enabled,
private_key: IdentityConfig.store.aamva_private_key,
public_key: IdentityConfig.store.aamva_public_key,
verification_request_timeout: IdentityConfig.store.aamva_verification_request_timeout,
verification_url: IdentityConfig.store.aamva_verification_url,
)
end
@state_id_proofer ||=
if IdentityConfig.store.proofer_mock_fallback
Proofing::Mock::StateIdMockClient.new
else
Proofing::Aamva::Proofer.new(
auth_request_timeout: IdentityConfig.store.aamva_auth_request_timeout,
auth_url: IdentityConfig.store.aamva_auth_url,
cert_enabled: IdentityConfig.store.aamva_cert_enabled,
private_key: IdentityConfig.store.aamva_private_key,
public_key: IdentityConfig.store.aamva_public_key,
verification_request_timeout: IdentityConfig.store.aamva_verification_request_timeout,
verification_url: IdentityConfig.store.aamva_verification_url,
)
end
end
end
19 changes: 10 additions & 9 deletions app/models/throttle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@ class Throttle < ApplicationRecord
# @param [User] user
# @return [Throttle]
def self.for(throttle_type:, user: nil, target: nil)
throttle = if user
find_or_create_by(user: user, throttle_type: throttle_type)
elsif target
if !target.is_a?(String)
raise ArgumentError, "target must be a string, but got #{target.class}"
throttle =
if user
find_or_create_by(user: user, throttle_type: throttle_type)
elsif target
if !target.is_a?(String)
raise ArgumentError, "target must be a string, but got #{target.class}"
end
find_or_create_by(target: target, throttle_type: throttle_type)
else
raise 'Throttle must have a user or a target, but neither were provided'
end
find_or_create_by(target: target, throttle_type: throttle_type)
else
raise 'Throttle must have a user or a target, but neither were provided'
end

throttle.reset_if_expired_and_maxed
throttle
Expand Down
10 changes: 5 additions & 5 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,11 @@ def idv_gpo_address_visited(
letter_already_sent:,
**extra
)
track_event(
'IdV: USPS address visited',
letter_already_sent: letter_already_sent,
**extra,
)
track_event(
'IdV: USPS address visited',
letter_already_sent: letter_already_sent,
**extra,
)
Comment on lines +624 to +628
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good catch 👍

end

# @identity.idp.previous_event_name Account verification submitted
Expand Down
66 changes: 33 additions & 33 deletions app/services/doc_auth/error_result.rb
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
module DocAuth
class ErrorResult
def initialize(error = nil, side = nil)
@error = ''
@error_display = nil
@sides = []
set_error(error) unless error.nil?
add_side(side) unless side.nil?
end
class ErrorResult
def initialize(error = nil, side = nil)
@error = ''
@error_display = nil
@sides = []
set_error(error) unless error.nil?
add_side(side) unless side.nil?
end

def set_error(error)
@error = error
@error_display = Errors::USER_DISPLAY[@error]
end
def set_error(error)
@error = error
@error_display = Errors::USER_DISPLAY[@error]
end

def error
@error
end
def error
@error
end

def add_side(side)
if side == :id
@sides.push(:front, :back)
else
@sides << side
end
def add_side(side)
if side == :id
@sides.push(:front, :back)
else
@sides << side
end
end

def empty?
@error.empty?
end
def empty?
@error.empty?
end

def to_h
return {} if @error.empty? || @error_display.empty?
error_output = {}
def to_h
return {} if @error.empty? || @error_display.empty?
error_output = {}

plural_banner = @error_display[:long_msg_plural] || @error_display[:long_msg]
plural_banner = @error_display[:long_msg_plural] || @error_display[:long_msg]

error_output[:general] = [@sides.length < 2 ? @error_display[:long_msg] : plural_banner]
@sides.each { |side| error_output[side] = [@error_display[:field_msg]] }
error_output[:general] = [@sides.length < 2 ? @error_display[:long_msg] : plural_banner]
@sides.each { |side| error_output[side] = [@error_display[:field_msg]] }

error_output[:hints] = @error_display[:hints] || false
error_output[:hints] = @error_display[:hints] || false

error_output
end
error_output
end
end
end
15 changes: 7 additions & 8 deletions app/services/idv/actions/verify_document_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ def form
end

def enqueue_job
verify_document_capture_session = if hybrid_flow_mobile?
document_capture_session
else
create_document_capture_session(
verify_document_capture_session_uuid_key,
)
end
verify_document_capture_session =
if hybrid_flow_mobile?
document_capture_session
else
create_document_capture_session(verify_document_capture_session_uuid_key)
end
verify_document_capture_session.requested_at = Time.zone.now
verify_document_capture_session.create_doc_auth_session

Expand Down Expand Up @@ -80,7 +79,7 @@ def image_metadata
to_h.
transform_values do |str|
JSON.parse(str)
rescue JSON::ParserError
rescue JSON::ParserError
nil
end.
compact.
Expand Down
13 changes: 7 additions & 6 deletions app/services/idv/actions/verify_document_status_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ def process_result(async_state)

def verify_document_capture_session
return @verify_document_capture_session if defined?(@verify_document_capture_session)
@verify_document_capture_session = if hybrid_flow_mobile?
document_capture_session
else
DocumentCaptureSession.find_by(
uuid: flow_session[verify_document_capture_session_uuid_key],
)
@verify_document_capture_session =
if hybrid_flow_mobile?
document_capture_session
else
DocumentCaptureSession.find_by(
uuid: flow_session[verify_document_capture_session_uuid_key],
)
end
end

Expand Down
11 changes: 6 additions & 5 deletions app/services/secure_headers_allow_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ def self.csp_with_sp_redirect_uris(action_url_domain, sp_redirect_uris)
def self.reduce_sp_redirect_uris_for_csp(uris)
csp_uri_set = uris.each_with_object(Set.new) do |uri, uri_set|
parsed_uri = URI.parse(uri)
reduced_uri = if parsed_uri.scheme.match?(/\Ahttps?\z/)
reduce_web_sp_uri(parsed_uri)
else
reduce_native_app_sp_uri(parsed_uri)
end
reduced_uri =
if parsed_uri.scheme.match?(/\Ahttps?\z/)
reduce_web_sp_uri(parsed_uri)
else
reduce_native_app_sp_uri(parsed_uri)
end
uri_set.add(reduced_uri)
end
csp_uri_set.to_a
Expand Down
17 changes: 8 additions & 9 deletions app/views/idv/shared/_error.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ locals:
* options: Array of troubleshooting options.
%>
<% if local_assigns.fetch(:type, :error) == :error
image_src = 'status/error.svg'
troubleshooting_heading = t('idv.troubleshooting.headings.need_assistance')
alt = t('errors.alt.error')
else
image_src = 'status/warning.svg'
troubleshooting_heading = t('components.troubleshooting_options.default_heading')
alt = t('errors.alt.warning')
end
%>
image_src = 'status/error.svg'
troubleshooting_heading = t('idv.troubleshooting.headings.need_assistance')
alt = t('errors.alt.error')
else
image_src = 'status/warning.svg'
troubleshooting_heading = t('components.troubleshooting_options.default_heading')
alt = t('errors.alt.warning')
end %>
<% title local_assigns.fetch(:title, heading) %>
<%= image_tag(image_src, width: 54, alt: alt, class: 'display-block margin-bottom-4') %>

Expand Down
2 changes: 1 addition & 1 deletion lib/identity_job_log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def duplicate_cron_error?(ex)
end

def should_error?(job, ex)
job.class.warning_error_classes.none? { |warning_class| ex.is_a?(warning_class) }
job.class.warning_error_classes.none? { |warning_class| ex.is_a?(warning_class) }
end
end

Expand Down
44 changes: 22 additions & 22 deletions lib/tasks/convert_application_yml_to_proper_types.rake
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ namespace :convert_application_yml_to_proper_types do
end

def value_types
@value_types ||= begin
types = {}
IO.foreach("#{Rails.root}/lib/identity_config.rb") do |line|
if (line.strip.index('config.add') == 0)
line = line.split(':')
name = nil
type = nil
if line.length == 2
name = line[1].strip[0..-2]
type = 'string'
elsif line.length == 4
name = line[1].split(',').first
type = line.last.strip[0..-2]
elsif line.length == 5
name = line[1].split(',').first
type = line[3].split(',').first
elsif line.length == 6
name = line[1].split(',').first
type = line[3].split(',').first
end
types[name] = type
@value_types ||= begin
types = {}
IO.foreach("#{Rails.root}/lib/identity_config.rb") do |line|
if (line.strip.index('config.add') == 0)
line = line.split(':')
name = nil
type = nil
if line.length == 2
name = line[1].strip[0..-2]
type = 'string'
elsif line.length == 4
name = line[1].split(',').first
type = line.last.strip[0..-2]
elsif line.length == 5
name = line[1].split(',').first
type = line[3].split(',').first
elsif line.length == 6
name = line[1].split(',').first
type = line[3].split(',').first
end
types[name] = type
end
types
end
types
end
end

def convert(value, value_type)
Expand Down
Loading