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)
|
def initialize(account)
|
||||||
@account = account.strip.gsub('acct:','').to_s
|
@account = account.strip.gsub('acct:','').to_s
|
||||||
@callbacks = []
|
@callbacks = []
|
||||||
@ssl = false
|
@ssl = true
|
||||||
# Raise an error if identifier has a port number
|
# Raise an error if identifier has a port number
|
||||||
raise "Identifier is invalid" if(@account.strip.match(/\:\d+$/))
|
raise "Identifier is invalid" if(@account.strip.match(/\:\d+$/))
|
||||||
# Raise an error if identifier is not a valid email (generous regexp)
|
# Raise an error if identifier is not a valid email (generous regexp)
|
||||||
|
|
@ -44,8 +44,12 @@ class EMWebfinger
|
||||||
}
|
}
|
||||||
|
|
||||||
http.errback {
|
http.errback {
|
||||||
|
if @ssl
|
||||||
process_callbacks "there was an error getting the xrd from account#{@account}" }
|
@ssl = false
|
||||||
|
get_xrd
|
||||||
|
else
|
||||||
|
process_callbacks "there was an error getting the xrd from account#{@account}"
|
||||||
|
end }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,6 @@ describe EMWebfinger do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'must try https first' do
|
it 'must try https first' do
|
||||||
single_request = FakeHttpRequest.new(:success)
|
single_request = FakeHttpRequest.new(:success)
|
||||||
single_request.callbacks = [diaspora_xrd]
|
single_request.callbacks = [diaspora_xrd]
|
||||||
|
|
@ -172,6 +171,23 @@ describe EMWebfinger do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue