Skip to content

Commit

Permalink
Merge branch 'master' into MBMS-61276-Self-Service-Pre-Need-Pre-Integ…
Browse files Browse the repository at this point in the history
…ration-CMP-UUID-Text-size-Increase
  • Loading branch information
adam-antonioli authored Mar 25, 2024
2 parents 5ac500b + 3a83f6c commit cd12aa9
Show file tree
Hide file tree
Showing 63 changed files with 1,294 additions and 348 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ end

group :test do
gem 'apivore', git: 'https://github.com/department-of-veterans-affairs/apivore', tag: 'v2.0.0.vsp'
gem 'fakeredis'
gem 'mock_redis'
gem 'pdf-inspector'
gem 'rspec_junit_formatter'
gem 'rspec-retry'
Expand Down Expand Up @@ -215,7 +215,7 @@ group :development, :test do
gem 'rubocop-rails'
gem 'rubocop-rspec'
gem 'rubocop-thread_safety'
gem 'sidekiq', '>= 6.4.0'
gem 'sidekiq', '~> 7.2.0'
gem 'timecop'
gem 'webmock'
gem 'yard'
Expand Down
38 changes: 21 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ PATH
GEM
remote: https://enterprise.contribsys.com/
specs:
sidekiq-ent (2.5.3)
einhorn (>= 0.7.4)
sidekiq (>= 6.5.0, < 7)
sidekiq-pro (>= 5.5.0, < 6)
sidekiq-pro (5.5.8)
sidekiq (~> 6.0, >= 6.5.6)
sidekiq-ent (7.2.2)
einhorn (~> 1.0)
gserver
sidekiq (>= 7.2.0, < 8)
sidekiq-pro (>= 7.2.0, < 8)
sidekiq-pro (7.2.0)
sidekiq (>= 7.2.0, < 8)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -282,7 +283,7 @@ GEM
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
byebug (11.1.3)
carrierwave (3.0.6)
carrierwave (3.0.7)
activemodel (>= 6.0.0)
activesupport (>= 6.0.0)
addressable (~> 2.6)
Expand Down Expand Up @@ -417,8 +418,6 @@ GEM
railties (>= 5.0.0)
faker (3.2.3)
i18n (>= 1.8.11, < 2)
fakeredis (0.9.2)
redis (~> 4.8)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-follow_redirects (0.3.0)
Expand Down Expand Up @@ -634,6 +633,7 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.22.3)
mock_redis (0.44.0)
msgpack (1.7.2)
msgpack (1.7.2-java)
multi_json (1.15.0)
Expand Down Expand Up @@ -812,7 +812,10 @@ GEM
rchardet (1.8.0)
rdoc (6.6.2)
psych (>= 4.0.0)
redis (4.8.1)
redis (5.1.0)
redis-client (>= 0.17.0)
redis-client (0.20.0)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
regexp_parser (2.9.0)
Expand Down Expand Up @@ -904,7 +907,7 @@ GEM
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-junit-formatter (0.1.4)
rubocop-rails (2.24.0)
rubocop-rails (2.24.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
Expand Down Expand Up @@ -954,10 +957,11 @@ GEM
shrine (3.5.0)
content_disposition (~> 1.0)
down (~> 5.1)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
sidekiq (7.2.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.19.0)
sidekiq_alive (2.4.0)
gserver (~> 0.0.1)
sidekiq (>= 5, < 8)
Expand Down Expand Up @@ -1122,7 +1126,6 @@ DEPENDENCIES
facilities_api!
factory_bot_rails
faker
fakeredis
faraday (~> 2.9)
faraday-follow_redirects
faraday-httpclient
Expand Down Expand Up @@ -1170,6 +1173,7 @@ DEPENDENCIES
mimemagic
mini_magick
mobile!
mock_redis
mocked_authentication!
my_health!
net-sftp
Expand Down Expand Up @@ -1234,7 +1238,7 @@ DEPENDENCIES
sentry-ruby
shoulda-matchers
shrine
sidekiq (>= 6.4.0)
sidekiq (~> 7.2.0)
sidekiq-ent!
sidekiq-pro!
sidekiq_alive
Expand Down
73 changes: 73 additions & 0 deletions app/controllers/v1/pension_ipf_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# frozen_string_literal: true

require 'decision_review_v1/utilities/logging_utils'

module V1
class PensionIpfCallbacksController < ApplicationController
include ActionController::HttpAuthentication::Token::ControllerMethods
include DecisionReviewV1::Appeals::LoggingUtils

service_tag 'pension-ipf-callbacks'

skip_before_action :verify_authenticity_token, only: [:create]
skip_before_action :authenticate, only: [:create]
skip_after_action :set_csrf_header, only: [:create]
before_action :authenticate_header, only: [:create]

STATUSES_TO_IGNORE = %w[sent delivered temporary-failure].freeze

def create
return render json: nil, status: :not_found unless Flipper.enabled? :pension_ipf_callbacks_endpoint

payload = JSON.parse(request.body.string)

# save encrypted request body in database table for non-successful notifications
payload_status = payload['status']&.downcase
if STATUSES_TO_IGNORE.exclude? payload_status
begin
PensionIpfNotification.create!(payload:)
rescue ActiveRecord::RecordInvalid => e
log_formatted(**log_params(payload).merge(is_success: false), params: { exception_message: e.message })
return render json: { message: 'failed' }
end
end

log_formatted(**log_params(payload).merge(is_success: true))
render json: { message: 'success' }
end

private

def authenticate_header
authenticate_user_with_token || authenticity_error
end

def authenticate_user_with_token
Rails.logger.info('pension-ipf-callbacks-69766 - Received request, authenticating')
authenticate_with_http_token do |token|
return false if bearer_token_secret.nil?

token == bearer_token_secret
end
end

def authenticity_error
Rails.logger.info('pension-ipf-callbacks-69766 - Failed to authenticate request')
render json: { message: 'Invalid credentials' }, status: :unauthorized
end

def bearer_token_secret
Settings.dig(:pension_ipf_vanotify_status_callback, :bearer_token)
end

def log_params(payload)
{
key: :callbacks,
form_id: '21P-527EZ',
user_uuid: nil,
upstream_system: 'VANotify',
body: payload.merge('to' => '<FILTERED>') # scrub PII from logs
}
end
end
end
20 changes: 20 additions & 0 deletions app/models/pension_ipf_notification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require 'json_marshal/marshaller'

class PensionIpfNotification < ApplicationRecord
serialize :payload, JsonMarshal::Marshaller

has_kms_key
has_encrypted :payload, key: :kms_key, **lockbox_options

validates(:payload, presence: true)

before_save :serialize_payload

private

def serialize_payload
self.payload = payload.to_json unless payload.is_a?(String)
end
end
4 changes: 4 additions & 0 deletions app/policies/mhv_messaging_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

MHVMessagingPolicy = Struct.new(:user, :mhv_messaging) do
def access?
return false unless user.mhv_correlation_id

client = SM::Client.new(session: { user_id: user.mhv_correlation_id })
validate_client(client)
end

def mobile_access?
return false unless user.mhv_correlation_id

client = Mobile::V0::Messaging::Client.new(session: { user_id: user.mhv_correlation_id })
validate_client(client)
end
Expand Down
8 changes: 8 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,10 @@ features:
actor_type: user
enable_in_development: true
description: Allows appointment cancellations to be routed to Oracle Health sites.
va_online_scheduling_enable_OH_slots_search:
actor_type: user
enable_in_development: true
description: Toggle for routing slots search requests to the VetsAPI Gateway Service(VPG) instead of vaos-service
va_online_scheduling_datadog_RUM:
actor_type: user
description: Enables datadog Real User Monitoring.
Expand Down Expand Up @@ -1281,6 +1285,10 @@ features:
actor_type: user
description: NOD VANotify notification callbacks endpoint
enable_in_development: true
pension_ipf_callbacks_endpoint:
actor_type: user
description: Pension IPF VANotify notification callbacks endpoint
enable_in_development: true
hlr_browser_monitoring_enabled:
actor_type: user
description: HLR Datadog RUM monitoring
Expand Down
10 changes: 7 additions & 3 deletions config/initializers/01_redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
REDIS_CONFIG = Rails.application.config_for(:redis).freeze
# set the current global instance of Redis based on environment specific config

$redis = Redis.new(REDIS_CONFIG[:redis].to_hash)

Redis.exists_returns_integer = true
$redis =
if Rails.env.test?
require 'mock_redis'
MockRedis.new(url: REDIS_CONFIG[:redis][:url])
else
Redis.new(REDIS_CONFIG[:redis].to_h)
end
4 changes: 3 additions & 1 deletion config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
end

# Remove the default error handler
config.error_handlers.delete_if { |handler| handler.is_a?(Sidekiq::ExceptionHandler::Logger) }
config.error_handlers.delete(Sidekiq::Config::ERROR_HANDLER)
end

Sidekiq.strict_args!(false)
end
3 changes: 3 additions & 0 deletions config/redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ test:
<<: *defaults
redis:
inherit_socket: true
url: <%= Settings.redis.app_data.url %>
sidekiq:
url: <%= Settings.redis.sidekiq.url %>

production:
<<: *defaults
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@

scope format: false do
resources :nod_callbacks, only: [:create]
resources :pension_ipf_callbacks, only: [:create]
end
end

Expand Down
14 changes: 14 additions & 0 deletions config/settings/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,17 @@ ask_va:

nod_vanotify_status_callback:
bearer_token: bearer_token_secret

travel_pay:
veis:
client_id: 'client_id'
client_secret: 'client_secret'
resource: 'resource_id'
tenant_id: 'tenant_id'
auth_url: 'https://auth.veis.gov'
subscription_key: 'api_key'
base_url: 'https://btsss.gov'
service_name: 'BTSSS-API'

pension_ipf_vanotify_status_callback:
bearer_token: bearer_token_secret
6 changes: 6 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: '3.4'
services:
redis:
image: redis:6.2-alpine
postgres:
image: mdillon/postgis:11-alpine
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200
Expand All @@ -21,6 +23,8 @@ services:
"Settings.database_url": "postgis://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-password}@${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}/${POSTGRES_DATABASE:-vets_api_development}?pool=4"
"Settings.test_database_url": "postgis://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-password}@${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}/${POSTGRES_DATABASE:-vets_api_test}"
"Settings.binaries.clamdscan": "clamscan" # Not running a separate process within the container for clamdscan, so we use clamscan which requires no daemon
"Settings.redis.app_data.url": "redis://redis:6379"
"Settings.redis.sidekiq.url": "redis://redis:6379"
POSTGRES_HOST: "${POSTGRES_HOST:-postgres}"
POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
POSTGRES_USER: "${POSTGRES_USER:-postgres}"
Expand All @@ -34,7 +38,9 @@ services:
DANGER_GITHUB_API_TOKEN: "${DANGER_GITHUB_API_TOKEN}"
depends_on:
- postgres
- redis
links:
- postgres
- redis
volumes:
test_bundle:
2 changes: 2 additions & 0 deletions lib/common/models/redis_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def initialize(attributes = {}, persisted = false)
end

def self.find(redis_key = nil)
return nil if redis_key.nil?

response = redis_namespace.get(redis_key)
return nil unless response

Expand Down
Binary file modified lib/pdf_fill/forms/pdfs/21P-527EZ.pdf
Binary file not shown.
Loading

0 comments on commit cd12aa9

Please sign in to comment.