Permalink
Browse files

Adding ssl support

  • Loading branch information...
1 parent 0a6042a commit d863bd210a4232ec478c7964cc47697dfd86a8f8 @jc00ke jc00ke committed Dec 14, 2010
Showing with 32 additions and 4 deletions.
  1. +1 −2 .rvmrc
  2. +14 −2 lib/story.rb
  3. +4 −0 slurper_config_https.yml
  4. +13 −0 spec/story_spec.rb
View
3 .rvmrc
@@ -1,2 +1 @@
-rvm_gemset_create_on_use_flag=1
-rvm gemset use slurper
+rvm --create rbx-head@slurper
View
16 lib/story.rb
@@ -2,11 +2,23 @@
class Story < ActiveResource::Base
+ def self.yaml
+ YAML.load_file('slurper_config.yml')
+ end
+
def self.config
- @@config ||= YAML.load_file('slurper_config.yml')
+ @@config = yaml
+ scheme = if !!@@config['ssl']
+ self.ssl_options = { :verify_mode => OpenSSL::SSL::VERIFY_PEER }
+ "https"
+ else
+ "http"
+ end
+ self.site = "#{scheme}://www.pivotaltracker.com/services/v3/projects/#{@@config['project_id']}"
+ @@config
end
- self.site = "http://www.pivotaltracker.com/services/v3/projects/#{config['project_id']}"
+
headers['X-TrackerToken'] = config.delete("token")
def prepare
View
4 slurper_config_https.yml
@@ -0,0 +1,4 @@
+project_id: 12345 # found in the project settings or address bar in Tracker
+token: 123abc123abc123abc123abc # found on your profile page in Tracker
+requested_by: Johnny Hashrocket # must be a user on the project
+ssl: true # set to true if the project has ssl required
View
13 spec/story_spec.rb
@@ -18,6 +18,19 @@
story.should_receive(:default_requested_by)
story.prepare
end
+
+ it "uses http by default" do
+ Story.site.scheme.should == "http"
+ Story.yaml['ssl'].should be_nil
+ end
+
+ it "uses https if set in the config" do
+ Story.stub!(:yaml).and_return(YAML.load_file('slurper_config_https.yml'))
+ Story.yaml['ssl'].should be_true
+ Story.config['ssl'].should be_true
+ Story.site.scheme.should == "https"
+ Story.ssl_options[:verify_mode].should == 1
+ end
end
context "requested_by attribute" do

0 comments on commit d863bd2

Please sign in to comment.