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

verify location rights work with properly escaped m&m location #1072

Merged
merged 1 commit into from
Dec 8, 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
49 changes: 36 additions & 13 deletions spec/requests/iiif/auth/v2/probe_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
'access' => {
'view' => 'location-based',
'download' => 'location_based',
'location' => 'spec'
'location' => location
}
}
]
Expand All @@ -166,7 +166,7 @@
<rightsMetadata>
<access type="read">
<machine>
<location>spec</location>
<location>#{xml_location}</location>
</machine>
</access>
</rightsMetadata>
Expand All @@ -178,17 +178,40 @@
get "/iiif/auth/v2/probe?id=#{stacks_uri}"
end

it 'returns a not authorized response' do
expect(response).to have_http_status :ok
expect(response.parsed_body).to include({
"@context" => "http://iiif.io/api/auth/2/context.json",
"type" => "AuthProbeResult2",
"status" => 401,
"heading" => {
"en" => ["Content is restricted to location Special Collections reading room"]
},
"note" => { "en" => ["Access restricted"] }
})
context 'when special collections' do
let(:location) { 'spec' }
let(:xml_location) { 'spec' }

it 'returns a not authorized response' do
expect(response).to have_http_status :ok
expect(response.parsed_body).to include({
"@context" => "http://iiif.io/api/auth/2/context.json",
"type" => "AuthProbeResult2",
"status" => 401,
"heading" => {
"en" => ["Content is restricted to location Special Collections reading room"]
},
"note" => { "en" => ["Access restricted"] }
})
end
end

context 'when media & microtext' do
let(:location) { 'm&m' }
let(:xml_location) { 'm&amp;m' }

it 'returns a not authorized response' do
expect(response).to have_http_status :ok
expect(response.parsed_body).to include({
"@context" => "http://iiif.io/api/auth/2/context.json",
"type" => "AuthProbeResult2",
"status" => 401,
"heading" => {
"en" => ["Content is restricted to location Media & Microtext"]
},
"note" => { "en" => ["Access restricted"] }
})
end
end
end

Expand Down