This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Webfinger spec now mandates a standard URL. Check that URL first,…
… instead of checking host-meta first (which may actually not be present). Bump to 1.2.0
- Loading branch information
Showing
6 changed files
with
69 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
context 'with HTTPS available' do | ||
describe '#finger' do | ||
before do | ||
stub_request(:get, 'https://quitter.no/.well-known/host-meta').to_return(body: fixture('quitter.no_.well-known_host-meta'), headers: { content_type: 'application/xrd+xml' }) | ||
stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:[email protected]').to_return(body: fixture('quitter.no_.well-known_webfinger.json'), headers: { content_type: 'application/jrd+json' }) | ||
end | ||
|
||
|
@@ -11,36 +10,48 @@ | |
it 'returns a result' do | ||
expect(subject.finger).to be_instance_of Goldfinger::Result | ||
end | ||
|
||
it 'performs a single HTTP request' do | ||
subject.finger | ||
expect(a_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:[email protected]')).to have_been_made.once | ||
end | ||
end | ||
end | ||
|
||
context 'with only HTTP available' do | ||
describe '#finger' do | ||
before do | ||
stub_request(:get, 'https://quitter.no/.well-known/host-meta').to_raise(HTTP::Error) | ||
stub_request(:get, 'http://quitter.no/.well-known/host-meta').to_return(body: fixture('quitter.no_.well-known_host-meta'), headers: { content_type: 'application/xrd+xml' }) | ||
stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:[email protected]').to_return(body: fixture('quitter.no_.well-known_webfinger.json'), headers: { content_type: 'application/jrd+json' }) | ||
stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:[email protected]').to_raise(HTTP::Error) | ||
stub_request(:get, 'http://quitter.no/.well-known/webfinger?resource=acct:[email protected]').to_return(body: fixture('quitter.no_.well-known_webfinger.json'), headers: { content_type: 'application/jrd+json' }) | ||
end | ||
|
||
subject { Goldfinger::Client.new('acct:[email protected]') } | ||
|
||
it 'returns a result' do | ||
expect(subject.finger).to be_instance_of Goldfinger::Result | ||
end | ||
|
||
it 'performs two HTTP requests' do | ||
subject.finger | ||
expect(a_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:[email protected]')).to have_been_made.once | ||
expect(a_request(:get, 'http://quitter.no/.well-known/webfinger?resource=acct:[email protected]')).to have_been_made.once | ||
end | ||
end | ||
end | ||
|
||
context 'with XRD missing' do | ||
describe '#finger' do | ||
before do | ||
stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:[email protected]').to_raise(HTTP::Error) | ||
stub_request(:get, 'http://quitter.no/.well-known/webfinger?resource=acct:[email protected]').to_raise(HTTP::Error) | ||
stub_request(:get, 'https://quitter.no/.well-known/host-meta').to_raise(HTTP::Error) | ||
stub_request(:get, 'http://quitter.no/.well-known/host-meta').to_raise(HTTP::Error) | ||
end | ||
|
||
subject { Goldfinger::Client.new('acct:[email protected]') } | ||
|
||
it 'raises an error' do | ||
expect {subject.finger }.to raise_error(Goldfinger::NotFoundError) | ||
expect { subject.finger }.to raise_error(Goldfinger::NotFoundError) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters