WIP certs

This commit is contained in:
Ilya Zhitomirskiy 2011-06-08 18:46:38 -07:00
parent 808754f8bd
commit b575983c22
4 changed files with 15 additions and 14 deletions

View file

@ -8,6 +8,10 @@ class AppConfig < Settingslogic
source File.join(Rails.root, "config", "application.yml")
namespace Rails.env
if self[:ca_file].blank? && Rails.env.development?
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end
def self.load!
if no_config_file? && !have_old_config_file?
$stderr.puts <<-HELP
@ -37,9 +41,6 @@ HELP
super
if self[:ca_file].blank? && Rails.env.development?
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end
if no_cert_file_in_prod?
$stderr.puts <<-HELP

View file

@ -47,7 +47,7 @@ class Webfinger
private
def get_xrd
begin
http = RestClient.get xrd_url, OPTS
http = Faraday.get xrd_url, OPTS
profile_url = webfinger_profile_url(http.body)
if profile_url
@ -69,7 +69,7 @@ class Webfinger
def get_webfinger_profile(profile_url)
begin
http = RestClient.get(profile_url, OPTS)
http = Faraday.get(profile_url, OPTS)
rescue
raise I18n.t('webfinger.fetch_failed', :profile_url => profile_url)
@ -83,7 +83,7 @@ class Webfinger
@wf_profile = WebfingerProfile.new(@account, webfinger_profile)
begin
hcard = RestClient.get(@wf_profile.hcard, OPTS)
hcard = Faraday.get(@wf_profile.hcard, OPTS)
rescue
return I18n.t('webfinger.hcard_fetch_failed', :account => @account)
end

View file

@ -78,7 +78,7 @@ describe Webfinger do
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
hcard_xml.stub!(:body).and_return(hcard_xml)
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")
# http://tom.joindiaspora.com/.well-known/host-meta
f = Webfinger.new("alice@example.org").fetch
@ -90,7 +90,7 @@ describe Webfinger do
f = Webfinger.new("tom@tom.joindiaspora.com")
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.send(:get_xrd)
f.instance_variable_get(:@ssl).should == false

View file

@ -11,16 +11,16 @@ describe Services::Facebook do
describe '#post' 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)
end
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)
end
it 'should call public message' do
RestClient.stub!(:post)
Faraday.stub!(:post)
url = "foo"
@service.should_receive(:public_message).with(@post, url)
@service.post(@post, url)
@ -53,12 +53,12 @@ describe Services::Facebook do
JSON
@web_mock = mock()
@web_mock.stub!(:body).and_return(@fb_list_hash)
RestClient.stub!(:get).and_return(@web_mock)
Faraday.stub!(:get).and_return(@web_mock)
end
describe '#save_friends' 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
end