em-webfinger ssl should work
This commit is contained in:
parent
8f5052fe61
commit
545577a950
2 changed files with 24 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ class EMWebfinger
|
|||
def initialize(account)
|
||||
@account = account.strip.gsub('acct:','').to_s
|
||||
@callbacks = []
|
||||
@ssl = false
|
||||
@ssl = true
|
||||
# Raise an error if identifier has a port number
|
||||
raise "Identifier is invalid" if(@account.strip.match(/\:\d+$/))
|
||||
# Raise an error if identifier is not a valid email (generous regexp)
|
||||
|
|
@ -44,8 +44,12 @@ class EMWebfinger
|
|||
}
|
||||
|
||||
http.errback {
|
||||
|
||||
process_callbacks "there was an error getting the xrd from account#{@account}" }
|
||||
if @ssl
|
||||
@ssl = false
|
||||
get_xrd
|
||||
else
|
||||
process_callbacks "there was an error getting the xrd from account#{@account}"
|
||||
end }
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,6 @@ describe EMWebfinger do
|
|||
}
|
||||
end
|
||||
|
||||
|
||||
it 'must try https first' do
|
||||
single_request = FakeHttpRequest.new(:success)
|
||||
single_request.callbacks = [diaspora_xrd]
|
||||
|
|
@ -172,6 +171,23 @@ describe EMWebfinger do
|
|||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'should retry with http if https fails with an http error code' do
|
||||
bad_request = FakeHttpRequest.new(:failure)
|
||||
|
||||
good_request.callbacks = [diaspora_xrd, diaspora_finger, hcard_xml]
|
||||
|
||||
EventMachine::HttpRequest.should_receive(:new).with("https://tom.joindiaspora.com/.well-known/host-meta").and_return(bad_request)
|
||||
EventMachine::HttpRequest.should_receive(:new).exactly(3).and_return(good_request)
|
||||
|
||||
f = EMWebfinger.new("tom@tom.joindiaspora.com")
|
||||
|
||||
EM.run {
|
||||
f.on_person{ |p|
|
||||
EM.stop
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue