Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
Browse files Browse the repository at this point in the history
…rgWebServiceBean-from-localBGS
  • Loading branch information
mchristiansonVA committed Dec 19, 2024
2 parents 4735c99 + ebf58a6 commit a478138
Show file tree
Hide file tree
Showing 205 changed files with 27,574 additions and 5,368 deletions.
7 changes: 6 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ app/controllers/v0/search_controller.rb @department-of-veterans-affairs/va-api-e
app/controllers/v0/search_typeahead_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/sign_in_controller.rb @department-of-veterans-affairs/octo-identity
app/controllers/v0/terms_of_use_agreements_controller.rb @department-of-veterans-affairs/octo-identity
app/controllers/v0/test_account_user_emails_controller.rb @department-of-veterans-affairs/octo-identity
app/controllers/v0/trackings_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/qa-standards @department-of-veterans-affairs/backend-review-group
app/controllers/v0/triage_teams_controller.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/upload_supporting_evidences_controller.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -461,7 +462,6 @@ app/services/mhv_account_type_service.rb @department-of-veterans-affairs/octo-id
app/services/mhv_logging_service.rb @department-of-veterans-affairs/octo-identity
app/services/rapid_ready_for_decision @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/services/sign_in @department-of-veterans-affairs/octo-identity
app/services/submission_pdf_url_service.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/services/terms_of_use @department-of-veterans-affairs/octo-identity
app/services/users @department-of-veterans-affairs/octo-identity
app/swagger/readme.md @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -851,6 +851,7 @@ lib/caseflow @department-of-veterans-affairs/lighthouse-banana-peels @department
lib/central_mail @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
lib/chip @department-of-veterans-affairs/vsa-healthcare-health-quest-1-backend @department-of-veterans-affairs/patient-check-in @department-of-veterans-affairs/backend-review-group
lib/claim_letters @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
lib/claim_documents/monitor.rb @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
lib/clamav @department-of-veterans-affairs/backend-review-group
lib/common/client/base.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
lib/common/client/concerns/mhv_fhir_session_client.rb @department-of-veterans-affairs/vfs-mhv-medical-records @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1234,6 +1235,7 @@ spec/factories/message_drafts.rb @department-of-veterans-affairs/vfs-mhv-secure-
spec/factories/message_threads.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/messages.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/messaging_preferences.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/mhv_user_accounts.rb @department-of-veterans-affairs/octo-identity
spec/factories/military_service_episodes.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/mpi @department-of-veterans-affairs/octo-identity
spec/factories/mvi_profile_relationships.rb @department-of-veterans-affairs/octo-identity
Expand Down Expand Up @@ -1418,6 +1420,7 @@ spec/lib/carma @department-of-veterans-affairs/vfs-10-10 @department-of-veterans
spec/lib/caseflow @department-of-veterans-affairs/lighthouse-banana-peels @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/central_mail @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/chip @department-of-veterans-affairs/vsa-healthcare-health-quest-1-backend @department-of-veterans-affairs/patient-check-in @department-of-veterans-affairs/backend-review-group
spec/lib/claim_documents/monitor_spec.rb @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
spec/lib/claim_status_tool @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/common/client/concerns/mhv_fhir_session_client_spec.rb @department-of-veterans-affairs/vfs-mhv-medical-records @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb @department-of-veterans-affairs/vfs-mhv-medical-records @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1734,6 +1737,7 @@ spec/requests/v0/caregivers_assistance_claims_spec.rb @department-of-veterans-af
spec/requests/v0/claim_documents_spec.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/requests/v0/debts_spec.rb @department-of-veterans-affairs/vsa-debt-resolution @department-of-veterans-affairs/backend-review-group
spec/requests/v0/disability_compensation_form_spec.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/requests/v0/test_account_user_emails_spec.rb @department-of-veterans-affairs/octo-identity
spec/requests/v1/higher_level_reviews @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
spec/requests/v1/notice_of_disagreements @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
spec/requests/v1/supplemental_claims @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -2125,6 +2129,7 @@ spec/support/vcr_cassettes/spec/support @department-of-veterans-affairs/octo-ide
spec/support/vcr_cassettes/staccato @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/support/vcr_cassettes/token_validation @department-of-veterans-affairs/lighthouse-banana-peels @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/support/vcr_cassettes/travel_pay @department-of-veterans-affairs/travel-pay-integration @department-of-veterans-affairs/backend-review-group
spec/support/vcr_cassettes/uploads/validate_document.yml @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
spec/spupport/vcr_cassettes/user/get_facilities_empty.yml @department-of-veterans-affairs/vfs-facilities-frontend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/support/vcr_cassettes/va_forms @department-of-veterans-affairs/platform-va-product-forms @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/support/vcr_cassettes/va_notify @department-of-veterans-affairs/va-notify-write @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
30 changes: 14 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,11 @@ GEM
ruby-vips (>= 2.0.17, < 3)
io-console (0.8.0)
io-console (0.8.0-java)
irb (1.14.1)
irb (1.14.2)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
iso_country_codes (0.7.8)
jar-dependencies (0.5.0)
jar-dependencies (0.5.1)
jmespath (1.6.2)
jruby-openssl (0.15.1-java)
json (2.9.0)
Expand Down Expand Up @@ -653,7 +653,7 @@ GEM
ffi-compiler (~> 1.0)
rake (~> 13.0)
lockbox (2.0.0)
logger (1.6.2)
logger (1.6.3)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -705,11 +705,9 @@ GEM
nio4r (2.7.4-java)
nkf (0.2.0)
nkf (0.2.0-java)
nokogiri (1.16.8)
nokogiri (1.17.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.8-java)
racc (~> 1.4)
nori (2.7.1)
bigdecimal
notiffany (0.1.3)
Expand Down Expand Up @@ -793,10 +791,10 @@ GEM
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
pstore (0.1.3)
psych (5.2.1)
psych (5.2.2)
date
stringio
psych (5.2.1-java)
psych (5.2.2-java)
date
jar-dependencies (>= 0.1.7)
public_suffix (6.0.1)
Expand Down Expand Up @@ -845,7 +843,7 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.1)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
rails-session_cookie (0.3.0)
Expand All @@ -868,7 +866,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rchardet (1.8.0)
rdoc (6.8.1)
rdoc (6.9.1)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
Expand All @@ -877,7 +875,7 @@ GEM
redis-namespace (1.11.0)
redis (>= 4)
regexp_parser (2.9.3)
reline (0.5.12)
reline (0.6.0)
io-console (~> 0.5)
representable (3.2.0)
declarative (< 0.1.0)
Expand Down Expand Up @@ -923,7 +921,7 @@ GEM
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (7.0.1)
rspec-rails (7.1.0)
actionpack (>= 7.0)
activesupport (>= 7.0)
railties (>= 7.0)
Expand All @@ -938,7 +936,7 @@ GEM
rspec-expectations (~> 3.0)
rspec-mocks (~> 3.0)
sidekiq (>= 5, < 8)
rspec-support (3.13.1)
rspec-support (3.13.2)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rswag-specs (2.16.0)
Expand All @@ -950,7 +948,7 @@ GEM
actionpack (>= 5.2, < 8.1)
railties (>= 5.2, < 8.1)
rtesseract (3.1.3)
rubocop (1.69.1)
rubocop (1.69.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -960,7 +958,7 @@ GEM
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.36.2)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
Expand Down Expand Up @@ -1006,7 +1004,7 @@ GEM
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
script_utils (0.0.4)
securerandom (0.4.0)
securerandom (0.4.1)
seedbank (0.5.0)
rake (>= 10.0)
semantic_logger (4.16.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/exception_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def report_mapped_exception(exception, va_exception)
# Add additional user specific context to the logs
if exception.is_a?(Common::Exceptions::BackendServiceException) && current_user.present?
extra[:icn] = current_user.icn
extra[:mhv_correlation_id] = current_user.mhv_correlation_id
extra[:mhv_credential_uuid] = current_user.mhv_credential_uuid
end
va_exception_info = { va_exception_errors: va_exception.errors.map(&:to_hash) }
log_exception_to_sentry(exception, extra.merge(va_exception_info))
Expand Down
66 changes: 56 additions & 10 deletions app/controllers/v0/claim_documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,46 @@

require 'pension_burial/tag_sentry'
require 'lgy/tag_sentry'
require 'claim_documents/monitor'
require 'lighthouse/benefits_intake/service'
require 'pdf_utilities/datestamp_pdf'

module V0
class ClaimDocumentsController < ApplicationController
service_tag 'claims-shared'
skip_before_action(:authenticate)
before_action :load_user

def create
Rails.logger.info "Creating PersistentAttachment FormID=#{form_id}"
uploads_monitor.track_document_upload_attempt(form_id, current_user)

attachment = klass.new(form_id:)
@attachment = klass&.new(form_id:)
# add the file after so that we have a form_id and guid for the uploader to use
attachment.file = unlock_file(params['file'], params['password'])
@attachment.file = unlock_file(params['file'], params['password'])

raise Common::Exceptions::ValidationErrors, attachment unless attachment.valid?
if %w[21P-527EZ 21P-530 21P-530V2].include?(form_id) &&
Flipper.enabled?(:document_upload_validation_enabled) && !stamped_pdf_valid?

attachment.save
raise Common::Exceptions::ValidationErrors, @attachment
end

raise Common::Exceptions::ValidationErrors, @attachment unless @attachment.valid?

Rails.logger.info "Success creating PersistentAttachment FormID=#{form_id} AttachmentID=#{attachment.id}"
@attachment.save

render json: PersistentAttachmentSerializer.new(attachment)
uploads_monitor.track_document_upload_success(form_id, @attachment.id, current_user)

render json: PersistentAttachmentSerializer.new(@attachment)
rescue => e
Rails.logger.error "Error creating PersistentAttachment FormID=#{form_id} AttachmentID=#{attachment.id} #{e}"
uploads_monitor.track_document_upload_failed(form_id, @attachment&.id, current_user, e)
raise e
end

private

def klass
case form_id
when '21P-527EZ', '21P-530EZ'
when '21P-527EZ', '21P-530EZ', '21P-530V2'
PensionBurial::TagSentry.tag_sentry
PersistentAttachments::PensionBurial
when '21-686C', '686C-674'
Expand All @@ -47,7 +57,7 @@ def form_id
end

def unlock_file(file, file_password)
return file unless File.extname(file) == '.pdf' && file_password
return file unless File.extname(file) == '.pdf' && file_password.present?

pdftk = PdfForms.new(Settings.binaries.pdftk)
tmpf = Tempfile.new(['decrypted_form_attachment', '.pdf'])
Expand All @@ -69,5 +79,41 @@ def unlock_file(file, file_password)
file.tempfile = tmpf
file
end

# rubocop:disable Metrics/MethodLength
def stamped_pdf_valid?
extension = File.extname(@attachment&.file&.id)
allowed_types = PersistentAttachment::ALLOWED_DOCUMENT_TYPES

if allowed_types.exclude?(extension)
raise Common::Exceptions::UnprocessableEntity.new(
detail: I18n.t('errors.messages.extension_allowlist_error', extension:, allowed_types:),
source: 'PersistentAttachment.stamped_pdf_valid?'
)
elsif @attachment&.file&.size&.< PersistentAttachment::MINIMUM_FILE_SIZE
raise Common::Exceptions::UnprocessableEntity.new(
detail: 'File size must not be less than 1.0 KB',
source: 'PersistentAttachment.stamped_pdf_valid?'
)
end

document = PDFUtilities::DatestampPdf.new(@attachment.to_pdf).run(text: 'VA.GOV', x: 5, y: 5)
intake_service.valid_document?(document:)
rescue BenefitsIntake::Service::InvalidDocumentError => e
@attachment.errors.add(:attachment, e.message)
false
rescue PdfForms::PdftkError
@attachment.errors.add(:attachment, 'File is corrupt and cannot be uploaded')
false
end
# rubocop:enable Metrics/MethodLength

def intake_service
@intake_service ||= BenefitsIntake::Service.new
end

def uploads_monitor
@uploads_monitor ||= ClaimDocuments::Monitor.new
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def create_submission(saved_claim)
saved_claim_id: saved_claim.id,
auth_headers_json: auth_headers.to_json,
form_json: saved_claim.to_submission_data(@current_user),
submit_endpoint: includes_toxic_exposure? ? 'claims_api' : 'evss'
submit_endpoint: 'claims_api'
) { |sub| sub.add_birls_ids @current_user.birls_id }

if missing_disabilities?(submission)
Expand Down Expand Up @@ -162,11 +162,6 @@ def stats_key
'api.disability_compensation'
end

def includes_toxic_exposure?
# any form that has a startedFormVersion (whether it is '2019' or '2022') will go through the Toxic Exposure flow
form_content['form526']['startedFormVersion']
end

def missing_disabilities?(submission)
if submission.form['form526']['form526']['disabilities'].none?
StatsD.increment("#{stats_key}.failure")
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/v0/my_va/submission_pdf_urls_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# frozen_string_literal: true

require 'forms/submission_statuses/pdf_urls'

module V0
module MyVA
class SubmissionPdfUrlsController < ApplicationController
before_action :check_flipper_flag
service_tag 'form-submission-pdf'

def create
url = SubmissionPdfUrlService.new(
url = Forms::SubmissionStatuses::PdfUrls.new(
form_id: request_params[:form_id],
submission_guid: request_params[:submission_guid]
).fetch_url
Expand Down
26 changes: 26 additions & 0 deletions app/controllers/v0/test_account_user_emails_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module V0
class TestAccountUserEmailsController < ApplicationController
service_tag 'identity'
skip_before_action :authenticate

NAMESPACE = 'test_account_user_email'
TTL = 2_592_000

def create
email_redis_key = SecureRandom.uuid
Rails.cache.write(email_redis_key, create_params, namespace: NAMESPACE, expires_in: TTL)

Rails.logger.info("[V0][TestAccountUserEmailsController] create, key:#{email_redis_key}")

render json: { test_account_user_email_uuid: email_redis_key }, status: :created
rescue
render json: { errors: 'invalid params' }, status: :bad_request
end

def create_params
params.require(:email)
end
end
end
11 changes: 4 additions & 7 deletions app/controllers/v1/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def handle_callback_error(exc, status, response, level = :error, context = {},
else
exc.message
end
conditional_log_message_to_sentry(message, level, context, code)
conditional_log_message_to_sentry(message, level, context)
Rails.logger.info("SessionsController version:v1 saml_callback failure, user_uuid=#{@current_user&.uuid}")

unless performed?
Expand All @@ -393,14 +393,11 @@ def handle_callback_error(exc, status, response, level = :error, context = {},
end
# rubocop:enable Metrics/ParameterLists

def conditional_log_message_to_sentry(message, level, context, code)
# If our error is that we have multiple mhv ids, this is a case where we won't log in the user,
# but we give them a path to resolve this. So we don't want to throw an error, and we don't want
# to pollute Sentry with this condition, but we will still log in case we want metrics in
# Cloudwatch or any other log aggregator. Additionally, if the user has an invalid message timestamp
def conditional_log_message_to_sentry(message, level, context)
# If the user has an invalid message timestamp
# error, this means they have waited too long in the log in page to progress, so it's not really an
# appropriate Sentry error
if code == SAML::UserAttributeError::MULTIPLE_MHV_IDS_CODE || invalid_message_timestamp_error?(message)
if invalid_message_timestamp_error?(message)
Rails.logger.warn("SessionsController version:v1 context:#{context} message:#{message}")
else
log_message_to_sentry(message, level, extra_context: context)
Expand Down
2 changes: 1 addition & 1 deletion app/models/form_profiles/va_2122.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def metadata
{
version: 0,
prefill: true,
returnUrl: '/claimant-information'
returnUrl: '/claimant-type'
}
end

Expand Down
Loading

0 comments on commit a478138

Please sign in to comment.