Skip to content

Commit

Permalink
Merge w/ master, resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mchristiansonVA committed Jan 6, 2025
2 parents ffa2ba5 + 7c38e39 commit 74be79b
Show file tree
Hide file tree
Showing 30 changed files with 364 additions and 235 deletions.
20 changes: 10 additions & 10 deletions app/controllers/v1/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,27 @@ def user_login(saml_response)
user_session_form = UserSessionForm.new(saml_response)
raise_saml_error(user_session_form) unless user_session_form.valid?
mhv_unverified_validation(user_session_form.user)
create_user_verification(user_session_form.user)
user_verification = create_user_verification(user_session_form.user_identity)
@current_user, @session_object = user_session_form.persist
set_cookies
after_login_actions

if @current_user.needs_accepted_terms_of_use
if user_verification.user_account.needs_accepted_terms_of_use?
redirect_to url_service.terms_of_use_redirect_url
else
redirect_to url_service.login_redirect_url
end
login_stats(:success)
end

def create_user_verification(user)
user_verifier_object = OpenStruct.new({ sign_in: user.identity.sign_in,
mhv_correlation_id: user.mhv_correlation_id,
idme_uuid: user.idme_uuid,
edipi: user.identity.edipi,
logingov_uuid: user.logingov_uuid,
icn: user.icn })
Login::UserVerifier.new(user_verifier_object).perform
def create_user_verification(user_identity)
Login::UserVerifier.new(login_type: user_identity.sign_in&.dig(:service_name),
auth_broker: user_identity.sign_in&.dig(:auth_broker),
mhv_uuid: user_identity.mhv_credential_uuid,
idme_uuid: user_identity.idme_uuid,
dslogon_uuid: user_identity.edipi,
logingov_uuid: user_identity.logingov_uuid,
icn: user_identity.icn).perform
end

def mhv_unverified_validation(user)
Expand Down
5 changes: 3 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def mhv_account_type
end

def mhv_correlation_id
return unless can_create_mhv_account?
return mhv_user_account.id if mhv_user_account.present?

mpi_mhv_correlation_id if active_mhv_ids&.one?
Expand Down Expand Up @@ -473,12 +474,12 @@ def create_mhv_account_async
MHV::AccountCreatorJob.perform_async(user_verification_id)
end

private

def can_create_mhv_account?
loa3? && !needs_accepted_terms_of_use
end

private

def mpi_profile
return nil unless identity && mpi

Expand Down
22 changes: 14 additions & 8 deletions app/services/login/user_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

module Login
class UserVerifier
def initialize(user)
@login_type = user.sign_in&.dig(:service_name)
@auth_broker = user.sign_in&.dig(:auth_broker)
@mhv_uuid = user.mhv_credential_uuid
@idme_uuid = user.idme_uuid
@dslogon_uuid = user.edipi
@logingov_uuid = user.logingov_uuid
@icn = user.icn.presence
def initialize(login_type:, # rubocop:disable Metrics/ParameterLists
auth_broker:,
mhv_uuid:,
idme_uuid:,
dslogon_uuid:,
logingov_uuid:,
icn:)
@login_type = login_type
@auth_broker = auth_broker
@mhv_uuid = mhv_uuid
@idme_uuid = idme_uuid
@dslogon_uuid = dslogon_uuid
@logingov_uuid = logingov_uuid
@icn = icn.presence
@deprecated_log = nil
@user_account_mismatch_log = nil
end
Expand Down
17 changes: 7 additions & 10 deletions app/services/sign_in/user_code_map_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ def device_sso
state_payload.scope == Constants::Auth::DEVICE_SSO
end

def user_verifier_object
@user_verifier_object ||= OpenStruct.new({ idme_uuid:,
logingov_uuid:,
sign_in:,
edipi:,
mhv_credential_uuid:,
icn: verified_icn })
end

def user_code_map
@user_code_map ||= UserCodeMap.new(login_code:,
type: state_payload.type,
Expand All @@ -84,7 +75,13 @@ def user_code_map
end

def user_verification
@user_verification ||= Login::UserVerifier.new(user_verifier_object).perform
@user_verification ||= Login::UserVerifier.new(login_type: sign_in[:service_name],
auth_broker: sign_in[:auth_broker],
mhv_uuid: mhv_credential_uuid,
idme_uuid:,
dslogon_uuid: edipi,
logingov_uuid:,
icn: verified_icn).perform
end

def user_account
Expand Down
2 changes: 1 addition & 1 deletion app/sidekiq/education_form/forms/va_1995.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def form_benefit
end

def header_form_type
@applicant.rudisillReview == 'Yes' ? 'V1995R' : 'V1995'
@applicant.rudisillReview == 'Yes' ? '1995R' : 'V1995'
end
end
end
2 changes: 1 addition & 1 deletion app/sidekiq/education_form/templates/1995.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= form_benefit %>
<% end -%>
*START*
VA Form 22-1995<%= @applicant.rudisillReview == "Yes" ? "R" : "" %>
VA Form 22-1995
OMB Control #: 2900-0074


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,30 +411,44 @@ def validate_form_526_disability_secondary_disabilities!
end

def validate_form_526_disability_classification_code!
return if (form_attributes['disabilities'].pluck('classificationCode') - [nil]).blank?
form_attributes['disabilities'].each_with_index do |disability, index|
classification_code = disability['classificationCode']
next if classification_code.nil? || classification_code.blank?

if bgs_classification_ids.include?(classification_code)
validate_form_526_disability_classification_code_end_date!(classification_code, index)
else
raise ::Common::Exceptions::InvalidFieldValue.new("disabilities.#{index}.classificationCode",
classification_code)
end
end
end

form_attributes['disabilities'].each do |disability|
next if disability['classificationCode'].blank?
next if bgs_classification_ids.include?(disability['classificationCode'])
def validate_form_526_disability_classification_code_end_date!(classification_code, index)
bgs_disability = contention_classification_type_code_list.find { |d| d[:clsfcn_id] == classification_code }
end_date = bgs_disability[:end_dt] if bgs_disability

raise ::Common::Exceptions::InvalidFieldValue.new('disabilities.classificationCode',
disability['classificationCode'])
end
return if end_date.nil?

return if Date.parse(end_date) >= Time.zone.today

raise ::Common::Exceptions::InvalidFieldValue.new("disabilities.#{index}.classificationCode", classification_code)
end

def contention_classification_type_code_list
@contention_classification_type_code_list ||= if Flipper.enabled?(:claims_api_526_validations_v1_local_bgs)
service = ClaimsApi::StandardDataService.new(
external_uid: Settings.bgs.external_uid,
external_key: Settings.bgs.external_key
)
service.get_contention_classification_type_code_list
else
bgs_service.data.get_contention_classification_type_code_list
end
end

def bgs_classification_ids
return @bgs_classification_ids if @bgs_classification_ids.present?

contention_classification_type_codes = if Flipper.enabled?(:claims_api_526_validations_v1_local_bgs)
contention_service = ClaimsApi::StandardDataService.new(
external_uid: Settings.bgs.external_uid,
external_key: Settings.bgs.external_key
)
contention_service.get_contention_classification_type_code_list
else
bgs_service.data.get_contention_classification_type_code_list
end
@bgs_classification_ids = contention_classification_type_codes.pluck(:clsfcn_id)
contention_classification_type_code_list.pluck(:clsfcn_id)
end

def validate_form_526_disability_approximate_begin_date!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'bgs_service/tracked_item_service'
module ClaimsApi
module V2
module ClaimsRequests
Expand All @@ -9,7 +10,7 @@ module TrackedItems
def find_tracked_items!(claim_id)
return if claim_id.blank?

@tracked_items = local_bgs_service.find_tracked_items(claim_id)[:dvlpmt_items] || []
@tracked_items = tracked_item_service.find_tracked_items(claim_id)[:dvlpmt_items] || []
end

def find_tracked_item(id)
Expand Down Expand Up @@ -100,6 +101,15 @@ def build_tracked_item(tracked_item, status, item, wwsnfy: false)
uploads_allowed:
}
end

private

def tracked_item_service
@tracked_item_service ||= ClaimsApi::TrackedItemService.new(
external_uid: target_veteran.participant_id,
external_key: target_veteran.participant_id
)
end
end
end
end
Expand Down
18 changes: 18 additions & 0 deletions modules/claims_api/lib/bgs_service/tracked_item_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module ClaimsApi
class TrackedItemService < ClaimsApi::LocalBGS
def bean_name
'TrackedItemService/TrackedItemService'
end

def find_tracked_items(id)
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<claimId>#{id}</claimId>
EOXML

make_request(endpoint: 'TrackedItemService/TrackedItemService', action: 'findTrackedItems', body:,
key: 'BenefitClaim')
end
end
end
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true

require 'rails_helper'
require 'bgs_service/tracked_item_service'

class FakeController
include ClaimsApi::V2::ClaimsRequests::TrackedItems
include ClaimsApi::V2::ClaimsRequests::TrackedItemsAssistance

def local_bgs_service
@local_bgs_service ||= ClaimsApi::LocalBGS.new(
def tracked_item_service
@tracked_item_service ||= ClaimsApi::TrackedItemService.new(
external_uid: target_veteran.participant_id,
external_key: target_veteran.participant_id
)
Expand Down
16 changes: 13 additions & 3 deletions modules/claims_api/spec/requests/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'bgs_service/e_benefits_bnft_claim_status_web_service'
require 'bgs_service/org_web_service'
require 'bgs_service/intent_to_file_web_service'
require 'bgs_service/tracked_item_service'
require 'bgs_service/person_web_service'

RSpec.describe 'ClaimsApi::Metadata', type: :request do
Expand Down Expand Up @@ -58,9 +59,8 @@
expect(result['mpi']['success']).to eq(false)
end

local_bgs_services = %i[claimant trackeditem].freeze
local_bgs_methods = %i[find_poa_by_participant_id
find_tracked_items].freeze
local_bgs_services = %i[claimant].freeze
local_bgs_methods = %i[find_poa_by_participant_id].freeze
local_bgs_services.each do |local_bgs_service|
it "returns the correct status when the local bgs #{local_bgs_service} is not healthy" do
local_bgs_methods.each do |local_bgs_method|
Expand All @@ -73,6 +73,16 @@
end
end

local_tracked_item_service = %i[trackeditem].freeze
local_tracked_item_method = %i[find_tracked_items].freeze
it "returns the correct status when the tracked item service #{local_tracked_item_service} is not healthy" do
allow_any_instance_of(ClaimsApi::TrackedItemService).to receive(local_tracked_item_method.first.to_sym)
.and_return(Struct.new(:healthy?).new(false))
get "/services/claims/#{version}/upstream_healthcheck"
result = JSON.parse(response.body)
expect(result['localbgs-trackeditem']['success']).to eq(false)
end

local_bgs_claims_status_services = %i[ebenefitsbenftclaim]
local_bgs_claims_status_methods = %i[find_benefit_claims_status_by_ptcpnt_id]
local_bgs_claims_status_services.each do |local_bgs_claims_status_service|
Expand Down
Loading

0 comments on commit 74be79b

Please sign in to comment.