diff --git a/config/features.yml b/config/features.yml index 068190f7557..d9e65f1cdb8 100644 --- a/config/features.yml +++ b/config/features.yml @@ -73,12 +73,6 @@ features: actor_type: user description: Enables access to the 10-10EZR application in prod for the purposes of conducting user reasearch enable_in_development: true - cerner_transition_556_t30: - actor_type: user - description: This will control the content that will be in effect 30 days prior to transition. - cerner_transition_556_t5: - actor_type: user - description: This will control the content that will be in effect 5 days prior to transition. cerner_override_653: actor_type: user description: This will show the Cerner facility 653 as `isCerner`. diff --git a/lib/rx/client.rb b/lib/rx/client.rb index c3a9fe4780f..4e62136e59a 100644 --- a/lib/rx/client.rb +++ b/lib/rx/client.rb @@ -18,6 +18,7 @@ class Client < Common::Client::Base client_session Rx::ClientSession CACHE_TTL = 3600 * 1 # 1 hour cache + CACHE_TTL_ZERO = 0 def request(method, path, params = {}, headers = {}, options = {}) super(method, path, params, headers, options) @@ -31,7 +32,7 @@ def request(method, path, params = {}, headers = {}, options = {}) # @return [Common::Collection[Prescription]] # def get_active_rxs - Common::Collection.fetch(::Prescription, cache_key: cache_key('getactiverx'), ttl: CACHE_TTL) do + Common::Collection.fetch(::Prescription, cache_key: cache_key('getactiverx'), ttl: CACHE_TTL_ZERO) do perform(:get, 'prescription/getactiverx', nil, token_headers).body end end @@ -53,7 +54,7 @@ def get_active_rxs_with_details # @return [Common::Collection[Prescription]] # def get_history_rxs - Common::Collection.fetch(::Prescription, cache_key: cache_key('gethistoryrx'), ttl: CACHE_TTL) do + Common::Collection.fetch(::Prescription, cache_key: cache_key('gethistoryrx'), ttl: CACHE_TTL_ZERO) do perform(:get, 'prescription/gethistoryrx', nil, token_headers).body end end @@ -123,10 +124,7 @@ def get_tracking_history_rx(id) # @return [Faraday::Env] # def post_refill_rxs(ids) - if (result = perform(:post, 'prescription/rxrefill', ids, token_headers)) - Common::Collection.bust([cache_key('getactiverx'), cache_key('gethistoryrx')]) - end - result + perform(:post, 'prescription/rxrefill', ids, token_headers) end ## diff --git a/modules/mobile/spec/request/prescriptions_request_spec.rb b/modules/mobile/spec/request/prescriptions_request_spec.rb index bc820f34fe1..3f6f269a6b7 100644 --- a/modules/mobile/spec/request/prescriptions_request_spec.rb +++ b/modules/mobile/spec/request/prescriptions_request_spec.rb @@ -125,20 +125,21 @@ end end - context 'prescription cache is present on refill' do - it 'flushes prescription cache on refill' do - set_cache + # Temporarily removing test until we can figure out how to handle cache + # context 'prescription cache is present on refill' do + # it 'flushes prescription cache on refill' do + # set_cache - VCR.use_cassette('mobile/rx_refill/prescriptions/refills_prescriptions') do - put '/mobile/v0/health/rx/prescriptions/refill', params: { ids: %w[21530889 21539942] }, - headers: sis_headers - end + # VCR.use_cassette('mobile/rx_refill/prescriptions/refills_prescriptions') do + # put '/mobile/v0/health/rx/prescriptions/refill', params: { ids: %w[21530889 21539942] }, + # headers: sis_headers + # end - get '/mobile/v0/health/rx/prescriptions', headers: sis_headers + # get '/mobile/v0/health/rx/prescriptions', headers: sis_headers - assert_requested :get, upstream_mhv_history_url, times: 1 - end - end + # assert_requested :get, upstream_mhv_history_url, times: 1 + # end + # end end describe 'GET /mobile/v0/health/rx/prescriptions', :aggregate_failures do diff --git a/modules/simple_forms_api/app/services/simple_forms_api/pdf_stamper.rb b/modules/simple_forms_api/app/services/simple_forms_api/pdf_stamper.rb index a0f8d61bcb7..2d4793d0cb2 100644 --- a/modules/simple_forms_api/app/services/simple_forms_api/pdf_stamper.rb +++ b/modules/simple_forms_api/app/services/simple_forms_api/pdf_stamper.rb @@ -168,12 +168,12 @@ def self.stamp2010207(stamped_template_path, form) def self.stamp4010007_uuid(uuid) uuid = "UUID: #{uuid}" stamped_template_path = 'tmp/vba_40_10007-tmp.pdf' - desired_stamps = [[410, 20]] + desired_stamps = [[390, 18]] page_configuration = [ { type: :text, position: desired_stamps[0] } ] - verified_multistamp(stamped_template_path, uuid, page_configuration, 7) + verified_multistamp(stamped_template_path, uuid, page_configuration, 9) end def self.multistamp(stamped_template_path, signature_text, page_configuration, font_size = 16) diff --git a/modules/travel_pay/app/controllers/travel_pay/pings_controller.rb b/modules/travel_pay/app/controllers/travel_pay/pings_controller.rb index 5f5e9332e4e..8529b72d842 100644 --- a/modules/travel_pay/app/controllers/travel_pay/pings_controller.rb +++ b/modules/travel_pay/app/controllers/travel_pay/pings_controller.rb @@ -10,6 +10,17 @@ def ping render json: { data: "Received ping from upstream server with status #{btsss_ping_response.status}." } end + def authorized_ping + vagov_token = request.headers['Authorization'].split[1] + veis_token = client.request_veis_token + btsss_token = client.request_btsss_token(veis_token, vagov_token) + + btsss_authorized_ping_response = client.authorized_ping(veis_token, btsss_token) + render json: { + data: "Received authorized ping from upstream server with status #{btsss_authorized_ping_response.status}." + } + end + def client TravelPay::Client.new end diff --git a/modules/travel_pay/app/services/travel_pay/client.rb b/modules/travel_pay/app/services/travel_pay/client.rb index 40e2f461a28..79424725b3a 100644 --- a/modules/travel_pay/app/services/travel_pay/client.rb +++ b/modules/travel_pay/app/services/travel_pay/client.rb @@ -52,6 +52,22 @@ def ping(veis_token) end end + ## + # HTTP GET call to the BTSSS 'authorized-ping' endpoint to test liveness + # + # @return [Faraday::Response] + # + def authorized_ping(veis_token, btsss_token) + btsss_url = Settings.travel_pay.base_url + api_key = Settings.travel_pay.subscription_key + + connection(server_url: btsss_url).get('api/v1/Sample/authorized-ping') do |req| + req.headers['Authorization'] = "Bearer #{veis_token}" + req.headers['BTSSS-Access-Token'] = btsss_token + req.headers['Ocp-Apim-Subscription-Key'] = api_key + end + end + ## # HTTP GET call to the BTSSS 'claims' endpoint # API responds with travel pay claims including status diff --git a/modules/travel_pay/config/routes.rb b/modules/travel_pay/config/routes.rb index a0751ec089e..0f62badc5ae 100644 --- a/modules/travel_pay/config/routes.rb +++ b/modules/travel_pay/config/routes.rb @@ -2,5 +2,6 @@ TravelPay::Engine.routes.draw do get '/pings/ping', to: 'pings#ping' + get '/pings/authorized_ping', to: 'pings#authorized_ping' resources :claims end diff --git a/modules/travel_pay/spec/controllers/pings_controller_spec.rb b/modules/travel_pay/spec/controllers/pings_controller_spec.rb index 33dd8a9a537..750a96600bf 100644 --- a/modules/travel_pay/spec/controllers/pings_controller_spec.rb +++ b/modules/travel_pay/spec/controllers/pings_controller_spec.rb @@ -8,9 +8,7 @@ before do allow(TravelPay::Client).to receive(:new).and_return(client) - veis_response = double - allow(veis_response).to receive(:body).and_return('sample_token') - allow(client).to receive(:request_veis_token).and_return(veis_response) + allow(client).to receive(:request_veis_token).and_return('sample_token') btsss_ping_response = double allow(btsss_ping_response).to receive(:status).and_return(200) @@ -45,4 +43,38 @@ end end end + + describe '#authorized_ping' do + before do + btsss_authorized_ping_response = double + allow(btsss_authorized_ping_response).to receive(:status).and_return(200) + allow(client) + .to receive(:request_btsss_token) + .and_return('sample_btsss_token') + allow(client) + .to receive(:authorized_ping) + .with('sample_token', 'sample_btsss_token') + .and_return(btsss_authorized_ping_response) + end + + context 'the feature switch is enabled' do + before do + Flipper.enable :travel_pay_power_switch + end + + it 'requests a token and sends a ping to BTSSS' do + expect(client).to receive(:authorized_ping) + get '/travel_pay/pings/authorized_ping', headers: { 'Authorization' => 'Bearer vagov_token' } + expect(response.body).to include('authorized ping') + end + end + + context 'the feature switch is disabled' do + it 'raises the proper error' do + get '/travel_pay/pings/authorized_ping', headers: { 'Authorization' => 'Bearer vagov_token' } + expect(response).to have_http_status(:service_unavailable) + expect(response.body).to include('This feature has been temporarily disabled') + end + end + end end diff --git a/modules/travel_pay/spec/services/client_spec.rb b/modules/travel_pay/spec/services/client_spec.rb index c88cb9d230e..2fe2c43d5ed 100644 --- a/modules/travel_pay/spec/services/client_spec.rb +++ b/modules/travel_pay/spec/services/client_spec.rb @@ -77,6 +77,23 @@ actual_claim_ids = claims.pluck(:id) expect(actual_claim_ids).to eq(expected_ordered_ids) + end + end + + context 'authorized_ping' do + it 'receives response from authorized-ping endpoint' do + allow(Settings.travel_pay.veis).to receive(:auth_url).and_return('sample_url') + allow(Settings.travel_pay.veis).to receive(:tenant_id).and_return('sample_id') + @stubs.get('/api/v1/Sample/authorized-ping') do + [ + 200, + { 'Content-Type': 'application/json' } + ] + end + client = TravelPay::Client.new + response = client.authorized_ping('veis_token', 'btsss_token') + + expect(response).to be_success @stubs.verify_stubbed_calls end end