Skip to content

Commit

Permalink
Merge branch 'master' into sjc-veteran-representative-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjcumming authored Apr 17, 2024
2 parents 3fef097 + be21fde commit 5826a91
Show file tree
Hide file tree
Showing 25 changed files with 619 additions and 9,049 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ GEM
attr_extras (7.1.0)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.913.0)
aws-sdk-core (3.191.6)
aws-partitions (1.914.0)
aws-sdk-core (3.192.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.79.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.146.1)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-s3 (1.147.0)
aws-sdk-core (~> 3, >= 3.192.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sdk-sns (1.72.0)
Expand Down Expand Up @@ -815,7 +815,7 @@ GEM
psych (>= 4.0.0)
redis (5.2.0)
redis-client (>= 0.22.0)
redis-client (0.22.0)
redis-client (0.22.1)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
Expand Down Expand Up @@ -874,7 +874,7 @@ GEM
rspec-support (~> 3.13)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-sidekiq (4.1.0)
rspec-sidekiq (4.2.0)
rspec-core (~> 3.0)
rspec-expectations (~> 3.0)
rspec-mocks (~> 3.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/profile/direct_deposits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def control_info_params
end

def send_confirmation_email
VANotifyDdEmailJob.send_to_emails(current_user.all_emails, 'comp_and_pen')
VANotifyDdEmailJob.send_to_emails(current_user.all_emails)
end
end
end
Expand Down
9 changes: 0 additions & 9 deletions app/sidekiq/education_form/templates/10203.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
CH33
*START*
<%= form_identifier %>
<% if Settings.vsp_environment.eql?('production') -%>
JUN 2020
<% else -%>
OMB Control #: 2900-0878
<% end -%>


APPLICATION FOR EDITH NOURSE ROGERS STEM SCHOLARSHIP
Expand Down Expand Up @@ -73,10 +69,6 @@ Applicant has POA: <%= yesno(@stem_automated_decision.poa) %>
Applicant School Email Address: <%= @applicant.schoolEmailAddress %>
Applicant School ID: <%= @applicant.schoolStudentId %>

<% if Settings.vsp_environment.eql?('production') -%>
Certification and Signature of Applicant
Signature of Applicant Date
<% else -%>
<% if @applicant.isActiveDuty -%>
As an active-duty service member, you have consulted with an Education Service
Officer (ESO) regarding your education program.
Expand All @@ -86,5 +78,4 @@ Signature of Applicant Date
<% end -%>


<% end -%>
<%= parse_with_template_path('footer') %>
13 changes: 10 additions & 3 deletions app/sidekiq/va_notify_dd_email_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class VANotifyDdEmailJob
STATSD_ERROR_NAME = 'worker.direct_deposit_confirmation_email.error'
STATSD_SUCCESS_NAME = 'worker.direct_deposit_confirmation_email.success'

def self.send_to_emails(user_emails, dd_type)
def self.send_to_emails(user_emails, dd_type = nil)
if user_emails.present?
user_emails.each do |email|
perform_async(email, dd_type)
Expand All @@ -25,9 +25,9 @@ def self.send_to_emails(user_emails, dd_type)
end
end

def perform(email, dd_type)
def perform(email, dd_type = nil)
notify_client = VaNotify::Service.new(Settings.vanotify.services.va_gov.api_key)
template_type = "direct_deposit_#{dd_type.to_sym == :ch33 ? 'edu' : 'comp_pen'}"
template_type = template_type(dd_type)
template_id = Settings.vanotify.services.va_gov.template_id.public_send(template_type)

notify_client.send_email(
Expand All @@ -39,6 +39,13 @@ def perform(email, dd_type)
handle_errors(e)
end

def template_type(dd_type)
return 'direct_deposit_edu' if dd_type&.to_sym == :ch33
return 'direct_deposit_comp_pen' if dd_type&.to_sym == :comp_pen

'direct_deposit'
end

def handle_errors(ex)
VANotifyDdEmailJob.log_exception_to_sentry(ex)
StatsD.increment(STATSD_ERROR_NAME)
Expand Down
16 changes: 16 additions & 0 deletions config/betamocks/services_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
:path: <%= "/#{Settings.ask_va_api.crm_api.veis_api_path}/ping" %>
:file_path: "/ask_va/dynamics_api"
:response_delay: 15
- :method: :get
:path: "/veis/api/btsss/travelclaim/api/v1/Sample/ping"
:file_path: "/travel_pay/ping/default"
:response_delay: 0.3
- :method: :get
:path: "/veis/api/btsss/travelclaim/api/v1/Sample/authorized-ping"
:file_path: "/travel_pay/ping/default"
:response_delay: 0.3
- :method: :post
:path: "/veis/api/btsss/travelclaim/api/v1/Auth/access-token"
:file_path: "/travel_pay/token/default"
:response_delay: 0.3
- :method: :post
:path: <%= "/#{Settings.ask_va_api.crm_api.veis_api_path}/inquiries/new" %>
:file_path: "/ask_va/crm_api/post_inquiries/default"
Expand All @@ -22,6 +34,10 @@
:path: <%= "/#{Settings.ask_va_api.crm_api.tenant_id}/oauth2/v2.0/token" %>
:file_path: "/ask_va/token/default"
:response_delay: 0.3
- :method: :post
:path: <%= "/#{Settings.travel_pay.veis.tenant_id}/oauth2/token" %>
:file_path: "/travel_pay/token/default"
:response_delay: 0.3

- :name: 'carma'
:base_uri: <%= "#{URI(Settings['salesforce-carma'].url).host}:#{URI(Settings['salesforce-carma'].url).port}" %>
Expand Down
2 changes: 2 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ vanotify:
in_progress_reminder_email_generic: fake_template_id
covid_vaccine_registration: fake_template_id
covid_vaccine_expanded_registration: fake_template_id
direct_deposit: direct_deposit_template_id
direct_deposit_edu: edu_template_id
direct_deposit_comp_pen: comp_pen_template_id
login_reactivation_email: reactivation_email_test_b
Expand Down Expand Up @@ -1666,6 +1667,7 @@ brd:


travel_pay:
mock: true
veis:
client_id: ~
client_secret: ~
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20240416155611_drop_pega_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DropPegaTables < ActiveRecord::Migration[7.1]
def change
drop_table :pega_tables, if_exists: true
end
end
18 changes: 18 additions & 0 deletions db/migrate/20240416155705_create_ivc_champva_forms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class CreateIvcChampvaForms < ActiveRecord::Migration[7.1]
def change
create_table :ivc_champva_forms do |t|
t.string :email
t.string :first_name
t.string :last_name
t.string :form_number
t.string :file_name
t.uuid :form_uuid
t.string :s3_status
t.string :pega_status

t.timestamps
end

add_index :ivc_champva_forms, :email, unique: true
end
end
31 changes: 14 additions & 17 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 27 additions & 2 deletions lib/saml/post_url_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def tou_declined_logout_redirect_url
end

def terms_of_use_redirect_url
application = @tracker&.payload_attr(:application) || 'vaweb'
if enabled_tou_clients.include?(application)
if terms_of_use_enabled_application
Rails.logger.info('Redirecting to /terms-of-use', type: :ssoe)
add_query(terms_of_use_url, { redirect_url: login_redirect_url })
else
Expand All @@ -79,6 +78,32 @@ def ssoe_slo_url

private

def terms_of_use_enabled_application
cache_key = "terms_of_use_redirect_user_#{user.uuid}"
cached_application = retrieve_and_delete_terms_of_use_redirect_user(cache_key)
current_application = @tracker&.payload_attr(:application)
write_terms_of_use_redirect_user(cache_key, current_application) if should_cache_application?(current_application)
terms_of_use_redirect_enabled?(cached_application, current_application)
end

def terms_of_use_redirect_enabled?(cached_application, current_application)
enabled_tou_clients.include?(cached_application || current_application || 'vaweb')
end

def should_cache_application?(application)
enabled_tou_clients.include?(application)
end

def retrieve_and_delete_terms_of_use_redirect_user(cache_key)
application = Rails.cache.read(cache_key)
Rails.cache.delete(cache_key)
application
end

def write_terms_of_use_redirect_user(cache_key, application)
Rails.cache.write(cache_key, application, expires_in: 5.minutes)
end

def terms_of_use_url
if Settings.review_instance_slug.present?
"http://#{Settings.review_instance_slug}.review.vetsgov-internal/terms-of-use"
Expand Down
29 changes: 13 additions & 16 deletions modules/appeals_api/app/services/appeals_api/remove_pii.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'ddtrace'

module AppealsApi
class RemovePii
include SentryLogging
Expand All @@ -15,13 +17,20 @@ def initialize(form_type:)
end

def run!
validate_form_type!
Datadog::Tracing.trace("#{self.class.name} - #{form_type}") do
validate_form_type!

result = remove_pii!
result = remove_pii!

log_failure_to_sentry if records_were_not_cleared(result)
if result.blank? && records_to_be_expunged.present?
ids = records_to_be_expunged.pluck(:id)
msg = "Failed to remove expired #{form_type} PII from records"
Rails.logger.error(msg, ids)
AppealsApi::Slack::Messager.new({ msg:, ids: }).notify!
end

result
result
end
end

private
Expand Down Expand Up @@ -49,17 +58,5 @@ def records_to_be_expunged
.pii_expunge_policy
end
end

def records_were_not_cleared(result)
result.blank? && records_to_be_expunged.present?
end

def log_failure_to_sentry
log_message_to_sentry(
"Failed to expunge PII from #{form_type} (modules/appeals_api)",
:error,
ids: records_to_be_expunged.pluck(:id)
)
end
end
end
35 changes: 26 additions & 9 deletions modules/appeals_api/spec/services/appeals_api/remove_pii_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'rails_helper'
require AppealsApi::Engine.root.join('spec', 'spec_helper.rb')

def update_appeal_status(appeal, status, code: nil, detail: nil)
# At the time of writing, the `update_status` method for each appeal model involves kicking off a sidekiq job to
Expand Down Expand Up @@ -159,6 +158,32 @@ def create_misc_appeals = create_appeals + misc_appeal_types.map { |f| FactoryBo
expect { AppealsApi::RemovePii.new(form_type: 'Invalid').run! }.to raise_error(ArgumentError)
end

context 'when the removal fails' do
let!(:appeals) do
Timecop.freeze(100.days.ago) do
status = 'complete'
[create(:supplemental_claim, status:), create(:supplemental_claim_v0, status:)]
end
end

before do
instance = AppealsApi::RemovePii.new(form_type: AppealsApi::SupplementalClaim)
msg = 'Failed to remove expired AppealsApi::SupplementalClaim PII from records'
expect(Rails.logger).to receive(:error).with(msg, appeals.map(&:id))
expect_any_instance_of(AppealsApi::Slack::Messager).to receive(:notify!)
allow(instance).to receive(:remove_pii!).and_return []
instance.run!
end

it 'logs an error and the IDs of records whose PII failed to be removed' do
appeals.each do |appeal|
appeal.reload
expect(appeal.auth_headers).to be_present
expect(appeal.form_data).to be_present
end
end
end

it 'removes PII from HLR records needing PII removal' do
day_old_has_pii_v2 = create :higher_level_review_v2, status: 'complete'
day_old_has_pii_v2.update updated_at: 1.day.ago
Expand Down Expand Up @@ -271,13 +296,5 @@ def create_misc_appeals = create_appeals + misc_appeal_types.map { |f| FactoryBo
expect(week_old_has_pii_error.reload.form_data_ciphertext).to be_present
end
end

it 'sends a message to sentry if the removal failed.' do
allow_any_instance_of(AppealsApi::RemovePii).to receive(:records_were_not_cleared).and_return(true)
service = AppealsApi::RemovePii.new(form_type: AppealsApi::NoticeOfDisagreement)
expect(service).to receive(:log_failure_to_sentry)

service.run!
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def default_service
def post_data(payload: {})
endpoint = "inquiries/#{inquiry_id}/reply/new"

response = service.call(endpoint:, payload:)
response = service.call(endpoint:, method: :post, payload:)
handle_response_data(response)
end

Expand Down
Loading

0 comments on commit 5826a91

Please sign in to comment.