Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mocked encrypted_kms_key from AccreditedRepresentativePortal POA Request Factories #19983

Closed
9 changes: 5 additions & 4 deletions app/models/appeal_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class AppealSubmission < ApplicationRecord

scope :failure_not_sent, -> { where(failure_notification_sent_at: nil).order(id: :asc) }

def self.submit_nod(request_body_hash:, current_user:, decision_review_service: nil)
def self.submit_nod(request_body_hash:, current_user:, decision_review_service: nil,
submit_upload_job: DecisionReview::SubmitUpload)
ActiveRecord::Base.transaction do
raise 'Must pass in a version of the DecisionReview Service' if decision_review_service.nil?

Expand All @@ -65,16 +66,16 @@ def self.submit_nod(request_body_hash:, current_user:, decision_review_service:
# Clear in-progress form if submit was successful
InProgressForm.form_for_user('10182', current_user)&.destroy!

appeal_submission.enqueue_uploads(uploads_arr, current_user)
appeal_submission.enqueue_uploads(uploads_arr, current_user, submit_upload_job)
nod_response_body
end
end

def enqueue_uploads(uploads_arr, _user)
def enqueue_uploads(uploads_arr, _user, submit_upload_job)
uploads_arr.each do |upload_attrs|
asu = AppealSubmissionUpload.create!(decision_review_evidence_attachment_guid: upload_attrs['confirmationCode'],
appeal_submission_id: id)
DecisionReview::SubmitUpload.perform_async(asu.id)
submit_upload_job.perform_async(asu.id)
end
end

Expand Down
6 changes: 6 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,12 @@ features:
decision_review_sc_new_api:
actor_type: user
description: Enable to switch to new Supplemental Claim modularized Decision Review endpoint
decision_review_new_engine_4142_job:
actor_type: user
description: Enable to switch to new modularized Decision Review Form4142Submit job
decision_review_new_engine_submit_upload_job:
actor_type: user
description: Enable to switch to new modularized Decision Review SubmitUpload job
dependency_verification:
actor_type: user
description: Feature gates the dependency verification modal for updating the diaries service.
Expand Down
4 changes: 2 additions & 2 deletions lib/decision_review_v1/appeals/supplemental_claim_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def queue_submit_evidence_uploads(sc_evidences, appeal_submission_id)
asu = AppealSubmissionUpload.create!(decision_review_evidence_attachment_guid: upload['confirmationCode'],
appeal_submission_id:)

DecisionReview::SubmitUpload.perform_async(asu.id)
submit_upload_job.perform_async(asu.id)
end
end

Expand All @@ -265,7 +265,7 @@ def queue_submit_evidence_uploads(sc_evidences, appeal_submission_id)
# @return String
#
def queue_form4142(appeal_submission_id:, rejiggered_payload:, submitted_appeal_uuid:)
DecisionReview::Form4142Submit.perform_async(
form4142_submit_job.perform_async(
appeal_submission_id,
payload_encrypted_string(rejiggered_payload),
submitted_appeal_uuid
Expand Down
8 changes: 8 additions & 0 deletions lib/decision_review_v1/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ def construct_tmpfile_name(appeal_submission_upload_id, original_filename)

private

def submit_upload_job
DecisionReview::SubmitUpload
end

def form4142_submit_job
DecisionReview::Form4142Submit
end

def create_higher_level_review_headers(user)
headers = {
'X-VA-SSN' => user.ssn.to_s.strip.presence,
Expand Down
3 changes: 3 additions & 0 deletions lib/periodic_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
# Update Optionset data cache
mgr.register('0 0 * * *', 'Crm::OptionsetDataJob')

# Update Facilities data cache
mgr.register('0 0 * * *', 'Crm::FacilitiesDataJob')

# Update FormSubmissionAttempt status from Lighthouse Benefits Intake API
mgr.register('0 0 * * *', 'BenefitsIntakeStatusJob')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
city_bidx { Faker::Alphanumeric.alphanumeric(number: 44) }
state_bidx { Faker::Alphanumeric.alphanumeric(number: 44) }
zipcode_bidx { Faker::Alphanumeric.alphanumeric(number: 44) }
encrypted_kms_key { SecureRandom.hex(16) }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
resolving_id { SecureRandom.uuid }
reason_ciphertext { 'Encrypted Reason' }
created_at { Time.current }
encrypted_kms_key { SecureRandom.hex(16) }

trait :with_expiration do
resolving_type { 'AccreditedRepresentativePortal::PowerOfAttorneyRequestExpiration' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ def search
api_result.tmp_covid_online_scheduling = mobile_api_get_by_id(api_result.id)
end
end
render_json(serializer, lighthouse_params, api_results)

patsr_approved_codes = retrieve_patsr_approved_facilities.pluck(:FacilityCode)

filtered_results = WillPaginate::Collection.create(
api_results.current_page,
api_results.per_page,
api_results.total_entries
) do |pager|
filtered_items = api_results.select { |object| patsr_approved_codes.include?(object.unique_id) }
pager.replace(filtered_items)
pager.total_entries = filtered_items.size
end

render_json(serializer, lighthouse_params, filtered_results)
end

def show
Expand All @@ -28,6 +41,11 @@ def show

private

def retrieve_patsr_approved_facilities
data = Crm::CacheData.new.fetch_and_cache_data(endpoint: 'Facilities', cache_key: 'Facilities', payload: {})
JSON.parse(data, symbolize_names: true)[:Data]
end

def api
FacilitiesApi::V2::Lighthouse::Client.new
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def call
inquiry_details = base_inquiry_details(inquiry_params[:your_role])

if education_benefits?(inquiry_params[:select_category],
inquiry_params[:select_topic])
inquiry_params[:select_topic]) ||
inquiry_params[:who_is_your_question_about] == "It's a general question"
return general_inquiry(inquiry_params, inquiry_details)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def fetch_state(state_code)
def formatted_pronouns(pronouns)
return unless pronouns

pronouns[:pronouns_not_listed_text].presence || pronouns.key(true)&.to_s&.tr('_', '/')
pronouns[:pronouns_not_listed_text].presence || pronouns.key('true')&.to_s&.tr('_', '/')
end

def contact_field(field, inquiry_details, inquiry_params)
Expand Down
28 changes: 28 additions & 0 deletions modules/ask_va_api/app/sidekiq/crm/facilities_data_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

require 'sidekiq'

module Crm
class FacilitiesDataJob
include Sidekiq::Job

# Schedule to run every 24 hours. Adjust as needed.
sidekiq_options retry: false, unique_for: 24.hours

def perform
Crm::CacheData.new.fetch_and_cache_data(endpoint: 'Facilities', cache_key: 'Facilities', payload: {})
rescue => e
log_error('optionset', e)
end

private

def log_error(action, exception)
LogService.new.call(action) do |span|
span.set_tag('error', true)
span.set_tag('error.msg', exception.message)
end
Rails.logger.error("Error during #{action}: #{exception.message}")
end
end
end
Loading
Loading