Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tests for impossible SDR rights combinations #1017

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 33 additions & 179 deletions spec/abilities/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,190 +435,44 @@
end
end

describe 'for multiple read access declarations' do
context 'with stanford read access and location based read access with download restriction' do
let(:rights_xml) do
<<-EOF.strip_heredoc
<rightsMetadata>
<access type="read">
<machine>
<group>Stanford</group>
</machine>
<machine>
<location rule="no-download">location1</location>
</machine>
</access>
</rightsMetadata>
EOF
end

context 'for a stanford webauth user at an unknown location' do
let(:user) { User.new(id: 'a', webauth_user: true, ldap_groups: %w(stanford:stanford)) }

it { is_expected.to be_able_to(:download, file) }
it { is_expected.to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'for an anonymous user from a configured location' do
let(:user) { User.new(ip_address: 'ip.address1') }

it { is_expected.not_to be_able_to(:download, file) }
it { is_expected.not_to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'for a stanford webauth user from a configured location' do
let(:user) do
User.new(id: 'a', webauth_user: true, ldap_groups: %w(stanford:stanford), ip_address: 'ip.address1')
end

it { is_expected.to be_able_to(:download, file) }
it { is_expected.to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'for a non-stanford webauth user from a configured location' do
let(:user) do
User.new(id: 'a', webauth_user: true, ldap_groups: %w(stanford:sponsored), ip_address: 'ip.address1')
end

it { is_expected.not_to be_able_to(:download, file) }
it { is_expected.not_to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'for a non-stanford webauth user from an unknown location' do
let(:user) do
User.new(id: 'a', webauth_user: true, ldap_groups: %w(stanford:sponsored), ip_address: 'another.unknown.ip')
end

it { is_expected.not_to be_able_to(:download, file) }
it { is_expected.not_to be_able_to(:download, image) }
it { is_expected.not_to be_able_to(:read, tile) }
it { is_expected.not_to be_able_to(:stream, media) }
it { is_expected.not_to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end
context 'with world (no-download), and full access for stanford users' do
let(:rights_xml) do
<<-EOF.strip_heredoc
<rightsMetadata>
<access type="read">
<machine>
<world rule="no-download"/>
</machine>
<machine>
<group>Stanford</group>
</machine>
</access>
</rightsMetadata>
EOF
end

context 'with two locations configured for read access, including one with a no-download rule' do
let(:rights_xml) do
<<-EOF.strip_heredoc
<rightsMetadata>
<access type="read">
<machine>
<location rule="no-download">location1</location>
</machine>
<machine>
<location>location2</location>
</machine>
</access>
</rightsMetadata>
EOF
end

context 'for an anonymous user user from the first configured location' do
let(:user) { User.new(ip_address: 'ip.address2') }

it { is_expected.not_to be_able_to(:download, file) }
it { is_expected.not_to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'for an anonymous user user from the second configured location' do
let(:user) { User.new(ip_address: 'ip.address4') }

it { is_expected.to be_able_to(:download, file) }
it { is_expected.to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'for an anonymous user user from an unrecognized location' do
let(:user) { User.new(ip_address: 'another.unknown.ip') }

it { is_expected.not_to be_able_to(:download, file) }
it { is_expected.not_to be_able_to(:download, image) }
it { is_expected.not_to be_able_to(:read, tile) }
it { is_expected.not_to be_able_to(:stream, media) }
it { is_expected.not_to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end
context 'for an anonymous user' do
it { is_expected.not_to be_able_to(:download, file) }
it { is_expected.not_to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'with world (no-download), and full access for stanford users' do
let(:rights_xml) do
<<-EOF.strip_heredoc
<rightsMetadata>
<access type="read">
<machine>
<world rule="no-download"/>
</machine>
<machine>
<group>Stanford</group>
</machine>
</access>
</rightsMetadata>
EOF
end

context 'for an anonymous user' do
it { is_expected.not_to be_able_to(:download, file) }
it { is_expected.not_to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end

context 'for a stanford webauth user' do
let(:user) { User.new(id: 'a', webauth_user: true, ldap_groups: %w(stanford:stanford)) }
context 'for a stanford webauth user' do
let(:user) { User.new(id: 'a', webauth_user: true, ldap_groups: %w(stanford:stanford)) }

it { is_expected.to be_able_to(:download, file) }
it { is_expected.to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end
it { is_expected.to be_able_to(:download, file) }
it { is_expected.to be_able_to(:download, image) }
it { is_expected.to be_able_to(:read, tile) }
it { is_expected.to be_able_to(:stream, media) }
it { is_expected.to be_able_to(:access, file) }
it { is_expected.to be_able_to(:read_metadata, image) }
it { is_expected.to be_able_to(:read, thumbnail) }
it { is_expected.to be_able_to(:read, square_thumbnail) }
end
end

Expand Down