Skip to content

Commit

Permalink
Remove tests that have a setup that is not possible in SDR
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 9, 2023
1 parent c619069 commit eda3e4a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 144 deletions.
77 changes: 0 additions & 77 deletions spec/requests/file_auth_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,6 @@
</publicObject>
EOF
end
let(:stanford_and_location_rights) do
<<-EOF
<publicObject>
<rightsMetadata>
<access type="read">
<machine>
<group>Stanford</group>
<location>location1</location>
</machine>
</access>
</rightsMetadata>
</publicObject>
EOF
end
let(:stanford_and_location_other_rights) do
<<-EOF
<publicObject>
<rightsMetadata>
<access type="read">
<machine>
<group>Stanford</group>
<location>location-other</location>
</machine>
</access>
</rightsMetadata>
</publicObject>
EOF
end

# NOTE: stanford only + location rights tested under location context
context 'stanford only (no location qualifications)' do
Expand Down Expand Up @@ -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
67 changes: 0 additions & 67 deletions spec/requests/iiif_auth_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
<publicObject>
<rightsMetadata>
<access type="read">
<machine>
<group>Stanford</group>
</machine>
<machine>
<location>location1</location>
</machine>
</access>
</rightsMetadata>
</publicObject>
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

0 comments on commit eda3e4a

Please sign in to comment.