From d1405baabe1e4a39aaaed6561d82c4e9ae5743fb Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:15:46 -0500 Subject: [PATCH] MHV-64151 Added tests --- .../v1/medical_records/imaging_spec.rb | 48 +++++++++++++++++++ .../vcr_cassettes/bb_client/get_dicom.yml | 45 +++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb create mode 100644 spec/support/vcr_cassettes/bb_client/get_dicom.yml diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb new file mode 100644 index 00000000000..4b366da8abf --- /dev/null +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'rails_helper' +require 'support/mr_client_helpers' +require 'medical_records/client' +require 'medical_records/bb_internal/client' +require 'support/shared_examples_for_mhv' + +RSpec.describe 'MyHealth::V1::MedicalRecords::ImagingController', type: :request do + include MedicalRecords::ClientHelpers + include MedicalRecords::ClientHelpers + + let(:user_id) { '11375034' } + let(:va_patient) { true } + let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } + let(:study_id) { '453-2487448' } + + before do + bb_internal_client = BBInternal::Client.new( + session: { + user_id: 11_375_034, + patient_id: '11382904', + expires_at: 1.hour.from_now, + token: 'ENC(MA0ECJh1RjEgZFMhAgEQC4nF/gSOKGSZuYg8kVN8CmHNnCLychZ7Wo2jXGwPj39SQFG4wLsFYlZN)' + } + ) + + allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) + allow(BBInternal::Client).to receive(:new).and_return(bb_internal_client) + sign_in_as(current_user) + VCR.insert_cassette('user_eligibility_client/perform_an_eligibility_check_for_premium_user', + match_requests_on: %i[method sm_user_ignoring_path_param]) + end + + context 'Premium User' do + let(:mhv_account_type) { 'Premium' } + + it 'streams DICOM data without the Content-Length header' do + VCR.use_cassette('bb_client/get_dicom') do + get "/my_health/v1/medical_records/imaging/#{study_id}/dicom" + end + + expect(response).to be_successful + # expect(response.headers).not_to have_key('Content-Length') + expect(response.headers['Content-Type']).to eq('application/zip') + end + end +end diff --git a/spec/support/vcr_cassettes/bb_client/get_dicom.yml b/spec/support/vcr_cassettes/bb_client/get_dicom.yml new file mode 100644 index 00000000000..4653916da18 --- /dev/null +++ b/spec/support/vcr_cassettes/bb_client/get_dicom.yml @@ -0,0 +1,45 @@ +--- +http_interactions: + - request: + method: get + uri: "/mhvapi/v1/bluebutton/studyjob/zip/stream/11382904/studyidUrn/453-2487448" + body: + encoding: US-ASCII + string: "" + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - application/json + User-Agent: + - Vets.gov Agent + Host: + - localhost:2003 + Content-Type: + - application/json + Token: "" + response: + status: + code: 200 + message: "" + headers: + Date: + - Mon, 09 Dec 2024 19:55:58 GMT + Content-Type: + - application/zip + Content-Length: + - "260002" + Expires: + - "-1" + Cache-Control: + - no-cache + Content-Disposition: + - attachment; filename=VA_IMG_IPOACEVEDA_CT_THORAX_W/CONT_04APR2024.zip + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: ASCII-8BIT + string: !binary |- + QSBzaW1wbGUgdGVzdA== + recorded_at: Mon, 09 Dec 2024 19:55:59 GMT +recorded_with: VCR 6.3.1