diff --git a/app/models/ability.rb b/app/models/ability.rb index 53b258c7..bb61f042 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -69,20 +69,6 @@ def initialize(user) end end - if user.app_user? - can [:download, :read], models do |f| - value, rule = f.rights.agent_rights_for_file f.file_name, user.id - - value && (rule.nil? || rule != Dor::RightsAuth::NO_DOWNLOAD_RULE) - end - - can [:access], models do |f| - value, _rule = f.rights.agent_rights_for_file f.file_name, user.id - - value - end - end - if user.locations.present? can [:download, :read], models do |f| user.locations.any? do |location| diff --git a/spec/abilities/ability_spec.rb b/spec/abilities/ability_spec.rb index 1f5b020e..31e24670 100644 --- a/spec/abilities/ability_spec.rb +++ b/spec/abilities/ability_spec.rb @@ -417,112 +417,6 @@ it { is_expected.to be_able_to(:read, thumbnail) } it { is_expected.to be_able_to(:read, square_thumbnail) } end - - context 'with a world-readable file that also has agent rights' do - let(:rights_xml) do - <<-EOF.strip_heredoc - - - - - a - - - - EOF - 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(:download, media) } - it { is_expected.to be_able_to(:read, file) } - it { is_expected.to be_able_to(:read, image) } - it { is_expected.to be_able_to(:read, media) } - 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 a stanford-restricted file that also has agent rights' do - let(:rights_xml) do - <<-EOF.strip_heredoc - - - - Stanford - a - - - - EOF - 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(:download, media) } - it { is_expected.to be_able_to(:read, file) } - it { is_expected.to be_able_to(:read, image) } - it { is_expected.to be_able_to(:read, media) } - 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 an agent-only file' do - let(:rights_xml) do - <<-EOF.strip_heredoc - - - - a - - - - EOF - 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(:download, media) } - it { is_expected.to be_able_to(:read, file) } - it { is_expected.to be_able_to(:read, image) } - it { is_expected.to be_able_to(:read, media) } - 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 an agent-only file with a no-download rule' do - let(:rights_xml) do - <<-EOF.strip_heredoc - - - - a - - - - EOF - 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(:download, media) } - it { is_expected.not_to be_able_to(:read, file) } - it { is_expected.not_to be_able_to(:read, image) } - it { is_expected.not_to be_able_to(:read, media) } - 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 context 'for an anonymous user' do @@ -968,77 +862,6 @@ it { is_expected.to be_able_to(:read, square_thumbnail) } end end - - context 'with an object defaults to read access from location2, but file is agent-only' do - let(:rights_xml) do - <<-EOF.strip_heredoc - - - - location2 - - - - file.csv - - a - - - - EOF - end - - context 'as an anonymous user in location2' do - let(:user) { User.new(ip_address: 'ip.address3') } - - it { is_expected.not_to be_able_to(:download, file) } - it { is_expected.to be_able_to(:download, image) } - it { is_expected.to be_able_to(:download, media) } - it { is_expected.not_to be_able_to(:read, file) } - it { is_expected.to be_able_to(:read, image) } - it { is_expected.to be_able_to(:read, media) } - it { is_expected.to be_able_to(:read, tile) } - it { is_expected.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 'as a stanford webauth user' do - let(:user) { User.new(id: 'a', webauth_user: true, ldap_groups: %w(stanford:stanford)) } - - 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(:download, media) } - it { is_expected.not_to be_able_to(:read, file) } - it { is_expected.not_to be_able_to(:read, image) } - it { is_expected.not_to be_able_to(:read, media) } - 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 'as an app user' do - let(:user) { User.new(id: 'a', app_user: true) } - - it { is_expected.to be_able_to(:download, file) } - it { is_expected.not_to be_able_to(:download, image) } - it { is_expected.not_to be_able_to(:download, media) } - it { is_expected.to be_able_to(:read, file) } - it { is_expected.not_to be_able_to(:read, image) } - it { is_expected.not_to be_able_to(:read, media) } - it { is_expected.not_to be_able_to(:read, tile) } - it { is_expected.not_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 end describe 'for an object with CDL rights' do