diff --git a/config/environments/demo.rb b/config/environments/demo.rb index 2000da40c1b..474107fc1eb 100644 --- a/config/environments/demo.rb +++ b/config/environments/demo.rb @@ -85,6 +85,8 @@ # eFolder Express URL for demo environment used as a mock link ENV["EFOLDER_EXPRESS_URL"] ||= "http://localhost:4000" + ENV["CASEFLOW_BASE_URL"] ||= "https://www.demo.appeals.va.gov" + # BatchProcess ENVs # priority_ep_sync ENV["BATCH_PROCESS_JOB_DURATION"] ||= "1" # Number of hours the job will run for diff --git a/config/environments/development.rb b/config/environments/development.rb index 9d6df8f25c6..3e102dae6ac 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -137,6 +137,8 @@ # Time in seconds before the sync lock expires LOCK_TIMEOUT = ENV["SYNC_LOCK_MAX_DURATION"] ||= "60" + ENV["CASEFLOW_BASE_URL"] ||= "http://localhost:3000" + # Notifications page eFolder link ENV["CLAIM_EVIDENCE_EFOLDER_BASE_URL"] ||= "https://vefs-claimevidence-ui-uat.stage.bip.va.gov" diff --git a/config/initializers/va_notify.rb b/config/initializers/va_notify.rb index de650eac2fc..80d05092136 100644 --- a/config/initializers/va_notify.rb +++ b/config/initializers/va_notify.rb @@ -1 +1,6 @@ -VANotifyService = (ApplicationController.dependencies_faked? ? Fakes::VANotifyService : ExternalApi::VANotifyService) \ No newline at end of file +case Rails.deploy_env +when :uat, :prod + VANotifyService = ExternalApi::VANotifyService +else + VANotifyService = Fakes::VANotifyService +end diff --git a/db/seeds.rb b/db/seeds.rb index 6b458fbab78..af32a532675 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -54,6 +54,7 @@ def seed call_and_log_seed_step Seeds::BgsServiceRecordMaker call_and_log_seed_step Seeds::PopulateCaseflowFromVacols call_and_log_seed_step Seeds::IssueModificationRequest + call_and_log_seed_step Seeds::ApiKey end end diff --git a/db/seeds/va_notify_api_key.rb b/db/seeds/va_notify_api_key.rb new file mode 100644 index 00000000000..d7cb348d1bd --- /dev/null +++ b/db/seeds/va_notify_api_key.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# create annotation seeds + +module Seeds + class ApiKey + def seed! + create_api_key + end + + private + + def create_api_key + ApiKey.create!(consumer_name: "TestApiKey", key_string: "test") + end + end +end diff --git a/lib/fakes/va_notify_service.rb b/lib/fakes/va_notify_service.rb index 42365937ac5..af4dee700eb 100644 --- a/lib/fakes/va_notify_service.rb +++ b/lib/fakes/va_notify_service.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Fakes::VANotifyService < ExternalApi::VANotifyService + VA_NOTIFY_ENDPOINT = "/api/v1/va_notify_update" + class << self # rubocop:disable Metrics/ParameterLists def send_email_notifications( @@ -11,7 +13,20 @@ def send_email_notifications( docket_number:, status: "" ) - fake_notification_response(email_template_id, status) + + external_id = SecureRandom.uuid + + unless Rails.deploy_env == :test + request = HTTPI::Request.new + request.url = "#{ENV['CASEFLOW_BASE_URL']}#{VA_NOTIFY_ENDPOINT}"\ + "?id=#{external_id}&status=delivered&to=test@example.com¬ification_type=email" + request.headers["Content-Type"] = "application/json" + request.headers["Authorization"] = "Bearer test" + + HTTPI.post(request) + end + + fake_notification_response(email_template_id, status, external_id) end def send_sms_notifications( @@ -22,11 +37,24 @@ def send_sms_notifications( docket_number:, status: "" ) + + external_id = SecureRandom.uuid + + unless Rails.deploy_env == :test + request = HTTPI::Request.new + request.url = "#{ENV['CASEFLOW_BASE_URL']}#{VA_NOTIFY_ENDPOINT}"\ + "?id=#{external_id}&status=delivered&to=+15555555555¬ification_type=sms" + request.headers["Content-Type"] = "application/json" + request.headers["Authorization"] = "Bearer test" + + HTTPI.post(request) + end + if participant_id.length.nil? return bad_participant_id_response end - fake_notification_response(sms_template_id, status) + fake_notification_response(sms_template_id, status, external_id) end # rubocop:enable Metrics/ParameterLists @@ -102,12 +130,12 @@ def bad_notification_response ) end - def fake_notification_response(template_id, status) + def fake_notification_response(template_id, status, external_id) HTTPI::Response.new( 200, {}, OpenStruct.new( - "id": SecureRandom.uuid, + "id": external_id, "reference": "string", "uri": "string", "template": {