WIP certs
This commit is contained in:
parent
808754f8bd
commit
b575983c22
4 changed files with 15 additions and 14 deletions
|
|
@ -8,6 +8,10 @@ class AppConfig < Settingslogic
|
||||||
source File.join(Rails.root, "config", "application.yml")
|
source File.join(Rails.root, "config", "application.yml")
|
||||||
namespace Rails.env
|
namespace Rails.env
|
||||||
|
|
||||||
|
if self[:ca_file].blank? && Rails.env.development?
|
||||||
|
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
||||||
|
end
|
||||||
|
|
||||||
def self.load!
|
def self.load!
|
||||||
if no_config_file? && !have_old_config_file?
|
if no_config_file? && !have_old_config_file?
|
||||||
$stderr.puts <<-HELP
|
$stderr.puts <<-HELP
|
||||||
|
|
@ -37,9 +41,6 @@ HELP
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
if self[:ca_file].blank? && Rails.env.development?
|
|
||||||
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
|
||||||
end
|
|
||||||
|
|
||||||
if no_cert_file_in_prod?
|
if no_cert_file_in_prod?
|
||||||
$stderr.puts <<-HELP
|
$stderr.puts <<-HELP
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class Webfinger
|
||||||
private
|
private
|
||||||
def get_xrd
|
def get_xrd
|
||||||
begin
|
begin
|
||||||
http = RestClient.get xrd_url, OPTS
|
http = Faraday.get xrd_url, OPTS
|
||||||
|
|
||||||
profile_url = webfinger_profile_url(http.body)
|
profile_url = webfinger_profile_url(http.body)
|
||||||
if profile_url
|
if profile_url
|
||||||
|
|
@ -69,7 +69,7 @@ class Webfinger
|
||||||
|
|
||||||
def get_webfinger_profile(profile_url)
|
def get_webfinger_profile(profile_url)
|
||||||
begin
|
begin
|
||||||
http = RestClient.get(profile_url, OPTS)
|
http = Faraday.get(profile_url, OPTS)
|
||||||
|
|
||||||
rescue
|
rescue
|
||||||
raise I18n.t('webfinger.fetch_failed', :profile_url => profile_url)
|
raise I18n.t('webfinger.fetch_failed', :profile_url => profile_url)
|
||||||
|
|
@ -83,7 +83,7 @@ class Webfinger
|
||||||
@wf_profile = WebfingerProfile.new(@account, webfinger_profile)
|
@wf_profile = WebfingerProfile.new(@account, webfinger_profile)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
hcard = RestClient.get(@wf_profile.hcard, OPTS)
|
hcard = Faraday.get(@wf_profile.hcard, OPTS)
|
||||||
rescue
|
rescue
|
||||||
return I18n.t('webfinger.hcard_fetch_failed', :account => @account)
|
return I18n.t('webfinger.hcard_fetch_failed', :account => @account)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ describe Webfinger do
|
||||||
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
|
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
|
||||||
hcard_xml.stub!(:body).and_return(hcard_xml)
|
hcard_xml.stub!(:body).and_return(hcard_xml)
|
||||||
diaspora_finger.stub!(:body).and_return(diaspora_finger)
|
diaspora_finger.stub!(:body).and_return(diaspora_finger)
|
||||||
RestClient.stub!(:get).and_return(diaspora_xrd, diaspora_finger, hcard_xml)
|
Faraday.stub!(:get).and_return(diaspora_xrd, diaspora_finger, hcard_xml)
|
||||||
#new_person = Factory.build(:person, :diaspora_handle => "tom@tom.joindiaspora.com")
|
#new_person = Factory.build(:person, :diaspora_handle => "tom@tom.joindiaspora.com")
|
||||||
# http://tom.joindiaspora.com/.well-known/host-meta
|
# http://tom.joindiaspora.com/.well-known/host-meta
|
||||||
f = Webfinger.new("alice@example.org").fetch
|
f = Webfinger.new("alice@example.org").fetch
|
||||||
|
|
@ -90,7 +90,7 @@ describe Webfinger do
|
||||||
f = Webfinger.new("tom@tom.joindiaspora.com")
|
f = Webfinger.new("tom@tom.joindiaspora.com")
|
||||||
|
|
||||||
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
|
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
|
||||||
RestClient.should_receive(:get).twice.and_return(nil, diaspora_xrd)
|
Faraday.should_receive(:get).twice.and_return(nil, diaspora_xrd)
|
||||||
f.should_receive(:xrd_url).twice
|
f.should_receive(:xrd_url).twice
|
||||||
f.send(:get_xrd)
|
f.send(:get_xrd)
|
||||||
f.instance_variable_get(:@ssl).should == false
|
f.instance_variable_get(:@ssl).should == false
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,16 @@ describe Services::Facebook do
|
||||||
|
|
||||||
describe '#post' do
|
describe '#post' do
|
||||||
it 'posts a status message to facebook' do
|
it 'posts a status message to facebook' do
|
||||||
RestClient.should_receive(:post).with("https://graph.facebook.com/me/feed", :message => @post.text, :access_token => @service.access_token)
|
Faraday.should_receive(:post).with("https://graph.facebook.com/me/feed", :message => @post.text, :access_token => @service.access_token)
|
||||||
@service.post(@post)
|
@service.post(@post)
|
||||||
end
|
end
|
||||||
it 'swallows exception raised by facebook always being down' do
|
it 'swallows exception raised by facebook always being down' do
|
||||||
RestClient.should_receive(:post).and_raise
|
Faraday.should_receive(:post).and_raise
|
||||||
@service.post(@post)
|
@service.post(@post)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should call public message' do
|
it 'should call public message' do
|
||||||
RestClient.stub!(:post)
|
Faraday.stub!(:post)
|
||||||
url = "foo"
|
url = "foo"
|
||||||
@service.should_receive(:public_message).with(@post, url)
|
@service.should_receive(:public_message).with(@post, url)
|
||||||
@service.post(@post, url)
|
@service.post(@post, url)
|
||||||
|
|
@ -53,12 +53,12 @@ describe Services::Facebook do
|
||||||
JSON
|
JSON
|
||||||
@web_mock = mock()
|
@web_mock = mock()
|
||||||
@web_mock.stub!(:body).and_return(@fb_list_hash)
|
@web_mock.stub!(:body).and_return(@fb_list_hash)
|
||||||
RestClient.stub!(:get).and_return(@web_mock)
|
Faraday.stub!(:get).and_return(@web_mock)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#save_friends' do
|
describe '#save_friends' do
|
||||||
it 'requests a friend list' do
|
it 'requests a friend list' do
|
||||||
RestClient.should_receive(:get).with("https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=yeah").and_return(@web_mock)
|
Faraday.should_receive(:get).with("https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=yeah").and_return(@web_mock)
|
||||||
@service.save_friends
|
@service.save_friends
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue