diff --git a/spec/requests/file_auth_request_spec.rb b/spec/requests/file_auth_request_spec.rb index 5d12fedd..203dcab8 100644 --- a/spec/requests/file_auth_request_spec.rb +++ b/spec/requests/file_auth_request_spec.rb @@ -63,34 +63,6 @@ EOF end - let(:stanford_and_location_rights) do - <<-EOF - - - - - Stanford - location1 - - - - - EOF - end - let(:stanford_and_location_other_rights) do - <<-EOF - - - - - Stanford - location-other - - - - - EOF - end # NOTE: stanford only + location rights tested under location context context 'stanford only (no location qualifications)' do @@ -132,55 +104,6 @@ expect(response).to have_http_status(:forbidden) end end - context 'OR stanford' do - context 'user webauthed' do - context 'authorized' do - it 'allows when user in location' do - allow_any_instance_of(FileController).to receive(:current_user).and_return(user_webauth_stanford_loc) - allow(Purl).to receive(:public_xml).and_return(stanford_and_location_rights) - expect_any_instance_of(FileController).to receive(:send_file).with(sf.path, disposition: :inline).and_call_original - get "/file/#{druid}/#{filename}" - end - - it 'allows when user not in location' do - allow_any_instance_of(FileController).to receive(:current_user).and_return(user_webauth_stanford_no_loc) - allow(Purl).to receive(:public_xml).and_return(stanford_and_location_other_rights) - expect_any_instance_of(FileController).to receive(:send_file).with(sf.path, disposition: :inline).and_call_original - get "/file/#{druid}/#{filename}" - end - end - context 'NOT authorized' do - it 'allows when in location' do - allow_any_instance_of(FileController).to receive(:current_user).and_return(user_webauth_no_stanford_loc) - allow(Purl).to receive(:public_xml).and_return(stanford_and_location_rights) - expect_any_instance_of(FileController).to receive(:send_file).with(sf.path, disposition: :inline).and_call_original - get "/file/#{druid}/#{filename}" - end - - it 'blocks when not in location' do - allow_any_instance_of(FileController).to receive(:current_user).and_return(user_webauth_no_stanford_no_loc) - allow(Purl).to receive(:public_xml).and_return(stanford_and_location_other_rights) - get "/file/#{druid}/#{filename}" - expect(response).to have_http_status(:forbidden) - end - end - end - context 'user NOT webauthed' do - it 'allows when in location (no webauth prompt)' do - allow_any_instance_of(FileController).to receive(:current_user).and_return(user_loc_no_webauth) - allow(Purl).to receive(:public_xml).and_return(stanford_and_location_rights) - expect_any_instance_of(FileController).to receive(:send_file).with(sf.path, disposition: :inline).and_call_original - get "/file/#{druid}/#{filename}" - end - - it 'prompts for webauth when not in location' do - allow_any_instance_of(FileController).to receive(:current_user).and_return(user_no_loc_no_webauth) - allow(Purl).to receive(:public_xml).and_return(stanford_and_location_other_rights) - get "/file/#{druid}/#{filename}" - expect(response).to redirect_to(auth_file_url(id: druid, file_name: filename)) - end - end - end end end end diff --git a/spec/requests/iiif_auth_request_spec.rb b/spec/requests/iiif_auth_request_spec.rb index 558b4e06..041f2266 100644 --- a/spec/requests/iiif_auth_request_spec.rb +++ b/spec/requests/iiif_auth_request_spec.rb @@ -113,72 +113,5 @@ end end end - - context 'with an item that is stanford-only or viewable in a location' do - before do - stub_rights_xml <<-XML - - - - - Stanford - - - location1 - - - - - XML - end - - context 'with a user in the location' do - let(:current_user) { user_loc_no_webauth } - - it 'works' do - get "/image/iiif/#{identifier}/#{region}/#{size}/#{rotation}/#{quality}.#{format}" - expect(response).to have_http_status(:ok) - expect(response.media_type).to eq('image/jpeg') - end - end - - context 'with an unauthorized user outside the location' do - let(:current_user) { user_webauth_no_stanford_no_loc } - - it 'blocks' do - get "/image/iiif/#{identifier}/#{region}/#{size}/#{rotation}/#{quality}.#{format}" - expect(response).to have_http_status(:forbidden) - end - end - - context 'with a stanford authenticated user' do - let(:current_user) { user_webauth_stanford_no_loc } - - it 'works' do - get "/image/iiif/#{identifier}/#{region}/#{size}/#{rotation}/#{quality}.#{format}" - expect(response).to have_http_status(:ok) - expect(response.media_type).to eq('image/jpeg') - end - end - - context 'with a stanford authenticated user in the location' do - let(:current_user) { user_webauth_stanford_loc } - - it 'works' do - get "/image/iiif/#{identifier}/#{region}/#{size}/#{rotation}/#{quality}.#{format}" - expect(response).to have_http_status(:ok) - expect(response.media_type).to eq('image/jpeg') - end - end - - context 'with an unauthenticated user not in the location' do - let(:current_user) { user_no_loc_no_webauth } - - it 'redirects to the authentication endpoint' do - get "/image/iiif/#{identifier}/#{region}/#{size}/#{rotation}/#{quality}.#{format}" - expect(response).to redirect_to(auth_iiif_url(id: 'nr349ct7889', file_name: 'nr349ct7889_00_0001', format:)) - end - end - end end end