diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index c3881ddd..b62e1137 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -67,7 +67,10 @@ def restricted? def content_datastream? # TODO: can be refactored after a general reindex of assets to use datastreams_ssim - HTTP.head(ds_content_url('content')).code == 200 + + HTTP.basic_auth( + user: ActiveFedora.config.credentials[:user], pass: ActiveFedora.config.credentials[:password] + ).head(ds_content_url('content')).code == 200 end def ds_content_url(dsid) diff --git a/spec/controllers/assets_controller_spec.rb b/spec/controllers/assets_controller_spec.rb index dd52cf54..e7fa72d5 100644 --- a/spec/controllers/assets_controller_spec.rb +++ b/spec/controllers/assets_controller_spec.rb @@ -27,6 +27,7 @@ let(:parent_doc) { SolrDocument.new(object_state_ssi: 'A') } let(:mock_resource) { double(docs: [resource_doc]) } let(:mock_parent) { double(docs: [parent_doc]) } + let(:mock_http_client_with_basic_auth) { double(HTTP::Client) } let(:mock_head_response) { double('headers', code: 200) } let(:resource_params) { { qt: 'search', fq: ['id:"10.7616/TESTTEST"', 'has_model_ssim:("info:fedora/ldpd:GenericResource" OR "info:fedora/ldpd:Resource")'], rows: 1 } } let(:parent_params) { { qt: 'search', fq: ['fedora3_pid_ssi:(parent\:id)'], rows: 100_000 } } @@ -34,7 +35,8 @@ before do allow(Blacklight.default_index).to receive(:search).with(resource_params).and_return(mock_resource) allow(Blacklight.default_index).to receive(:search).with(parent_params).and_return(mock_parent) - allow(HTTP).to receive(:head).and_return(mock_head_response) + allow(HTTP).to receive(:basic_auth).and_return(mock_http_client_with_basic_auth) + allow(mock_http_client_with_basic_auth).to receive(:head).and_return(mock_head_response) get :download, params: { id: '10.7616/TESTTEST' } end