Skip to content

Commit

Permalink
Merge pull request #321 from samvera/use-https
Browse files Browse the repository at this point in the history
Changes LoC authorities to use https
  • Loading branch information
elrayle authored Aug 13, 2020
2 parents 267ce94 + e75bf79 commit 4b571ee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/qa/authorities/loc/generic_authority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def search(q)
def build_query_url(q)
escaped_query = ERB::Util.url_encode(q)
authority_fragment = Loc.get_url_for_authority(subauthority) + ERB::Util.url_encode(subauthority)
"http://id.loc.gov/search/?q=#{escaped_query}&q=#{authority_fragment}&format=json"
"https://id.loc.gov/search/?q=#{escaped_query}&q=#{authority_fragment}&format=json"
end

def find(id)
json(find_url(id))
end

def find_url(id)
"http://id.loc.gov/authorities/#{@subauthority}/#{id}.json"
"https://id.loc.gov/authorities/#{@subauthority}/#{id}.json"
end

private
Expand Down
8 changes: 4 additions & 4 deletions lib/qa/authorities/loc_subauthority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ def preservation # rubocop:disable Metrics/MethodLength
private

def vocab_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F"
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fvocabulary%2F"
end

def authority_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F"
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2F"
end

def datatype_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F"
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fdatatypes%2F"
end

def vocab_preservation_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F"
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F"
end
end
4 changes: 2 additions & 2 deletions spec/controllers/terms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def search(_arg1, _arg2)

context "loc" do
before do
stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:https://id.loc.gov/authorities/names")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
end
Expand Down Expand Up @@ -188,7 +188,7 @@ def search(_arg1, _arg2)
describe "#show" do
context "with supported authorities" do
before do
stub_request(:get, "http://id.loc.gov/authorities/subjects/sh85077565.json")
stub_request(:get, "https://id.loc.gov/authorities/subjects/sh85077565.json")
.with(headers: { 'Accept' => 'application/json' })
.to_return(status: 200, body: webmock_fixture("loc-names-response.txt"), headers: {})
end
Expand Down
18 changes: 9 additions & 9 deletions spec/lib/authorities/loc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
end

context "for searching" do
let(:url) { 'http://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
it "returns a url" do
expect(authority.build_query_url("foo")).to eq(url)
end
end

context "for returning single terms" do
let(:url) { "http://id.loc.gov/authorities/subjects/sh2002003586.json" }
let(:url) { "https://id.loc.gov/authorities/subjects/sh2002003586.json" }
it "returns a url with an authority and id" do
expect(authority.find_url("sh2002003586")).to eq(url)
end
Expand All @@ -49,15 +49,15 @@
end

before do
stub_request(:get, "http://id.loc.gov/search/?format=json&q=cs:http://id.loc.gov/authorities/subjects")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=cs:https://id.loc.gov/authorities/subjects")
.with(headers: { 'Accept' => 'application/json' })
.to_return(status: 200, body: "")
end

context "with flat params encoded" do
let(:url) { 'http://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
it "returns a response" do
flat_params_url = "http://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
flat_params_url = "https://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
expect(subject.env.url.to_s).to eq(flat_params_url)
end
end
Expand All @@ -66,7 +66,7 @@
describe "#search" do
context "any LOC authorities" do
let :authority do
stub_request(:get, "http://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=s&q=cs:https://id.loc.gov/vocabulary/geographicAreas")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-response.txt"), status: 200)
described_class.subauthority_for("geographicAreas")
Expand Down Expand Up @@ -95,7 +95,7 @@

context "subject terms" do
let :results do
stub_request(:get, "http://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=History--&q=cs:https://id.loc.gov/authorities/subjects")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-subjects-response.txt"), status: 200)
described_class.subauthority_for("subjects").search("History--")
Expand All @@ -111,7 +111,7 @@

context "name terms" do
let :results do
stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:https://id.loc.gov/authorities/names")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
described_class.subauthority_for("names").search("Berry")
Expand All @@ -125,7 +125,7 @@
describe "#find" do
context "using a subject id" do
let :results do
stub_request(:get, "http://id.loc.gov/authorities/subjects/sh2002003586.json")
stub_request(:get, "https://id.loc.gov/authorities/subjects/sh2002003586.json")
.with(headers: { 'Accept' => 'application/json' })
.to_return(status: 200, body: webmock_fixture("loc-subject-find-response.txt"), headers: {})
described_class.subauthority_for("subjects").find("sh2002003586")
Expand Down

0 comments on commit 4b571ee

Please sign in to comment.