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

Follow redirects when the response is 302 #14

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions lib/fido_metadata/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def get(uri)
response = http(uri).request(get)
response.value
response.body
rescue Net::HTTPRetriableError => e
if e.response.is_a? Net::HTTPResponse
get(URI(e.response["location"]))
end
end

def http(uri)
Expand Down
15 changes: 15 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,20 @@
expect { subject }.to raise_error(described_class::UnverifiedSigningKeyError, error)
end
end

context "when a CRL url redirects to another url" do
let(:redirecting_url) do
{ status: 302, headers: { location: "http://crl.globalsign.com/gs/redirected.crl" } }
end

before(:each) do
stub_request(:get, "http://crl.globalsign.com/gs/gsextendvalsha2g3r3.crl").to_return(redirecting_url)
stub_request(:get, "http://crl.globalsign.com/gs/redirected.crl").to_return(extendval_crl)
end

specify do
expect(subject).to include("nextUpdate", "entries", "no")
end
end
end
end