Skip to content

Commit e8cfc06

Browse files
author
Justin Roberts
authored
Merge pull request pardot#37 from jpearson-sfdc/master
W-5653730: Change to pass auth parameters in body.
2 parents fdc4dc8 + 28b2368 commit e8cfc06

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

Gemfile.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
PATH
22
remote: .
33
specs:
4-
ruby-pardot (1.1.0)
5-
crack
6-
httparty
4+
ruby-pardot (1.2.0)
5+
crack (= 0.4.3)
6+
httparty (= 0.13.1)
77

88
GEM
99
remote: http://rubygems.org/
1010
specs:
11-
crack (0.4.2)
11+
crack (0.4.3)
1212
safe_yaml (~> 1.0.0)
1313
diff-lcs (1.1.2)
1414
fakeweb (1.3.0)
1515
httparty (0.13.1)
1616
json (~> 1.8)
1717
multi_xml (>= 0.5.2)
18-
json (1.8.3)
19-
multi_xml (0.5.5)
18+
json (1.8.6)
19+
multi_xml (0.6.0)
2020
rspec (2.5.0)
2121
rspec-core (~> 2.5.0)
2222
rspec-expectations (~> 2.5.0)
@@ -37,4 +37,4 @@ DEPENDENCIES
3737
ruby-pardot!
3838

3939
BUNDLED WITH
40-
1.11.2
40+
2.0.1

lib/pardot/authentication.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Pardot
22
module Authentication
33

44
def authenticate
5-
resp = post "login", nil, :email => @email, :password => @password, :user_key => @user_key
5+
resp = post "login", nil, nil, nil, :email => @email, :password => @password, :user_key => @user_key
66
update_version(resp["version"]) if resp && resp["version"]
77
@api_key = resp && resp["api_key"]
88
end

lib/pardot/http.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ def get object, path, params = {}, num_retries = 0
1313
raise Pardot::NetError.new(e)
1414
end
1515

16-
def post object, path, params = {}, num_retries = 0
16+
def post object, path, params = {}, num_retries = 0, bodyParams = {}
1717
smooth_params object, params
1818
full_path = fullpath object, path
19-
check_response self.class.post(full_path, :query => params)
19+
check_response self.class.post(full_path, :query => params, :body => bodyParams)
2020

2121
rescue Pardot::ExpiredApiKeyError => e
2222
handle_expired_api_key :post, object, path, params, num_retries, e

lib/pardot/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Pardot
2-
VERSION = "1.1.0"
2+
VERSION = "1.2.0"
33
end

ruby-pardot.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
1414
s.required_rubygems_version = ">= 1.3.6"
1515
s.rubyforge_project = "ruby-pardot"
1616

17-
s.add_dependency "crack"
18-
s.add_dependency "httparty"
17+
s.add_dependency "crack", "0.4.3"
18+
s.add_dependency "httparty", "0.13.1"
1919

2020
s.add_development_dependency "bundler", ">= 1.10"
2121
s.add_development_dependency "rspec"

spec/pardot/authentication_spec.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ def create_client
1111
before do
1212
@client = create_client
1313

14-
fake_post "/api/login/version/3?email=user%40test.com&password=foo&user_key=bar",
14+
fake_post "/api/login/version/3",
1515
%(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">\n <api_key>my_api_key</api_key>\n</rsp>\n)
1616
end
1717

1818
def authenticate
1919
@client.authenticate
2020
end
21+
22+
def verifyBody
23+
FakeWeb.last_request.body.should == 'email=user%40test.com&password=foo&user_key=bar'
24+
end
2125

2226
it "should return the api key" do
2327
authenticate.should == "my_api_key"
@@ -26,16 +30,19 @@ def authenticate
2630
it "should set the api key" do
2731
authenticate
2832
@client.api_key.should == "my_api_key"
33+
verifyBody
2934
end
3035

3136
it "should make authenticated? true" do
3237
authenticate
3338
@client.authenticated?.should == true
39+
verifyBody
3440
end
3541

3642
it "should use version 3" do
3743
authenticate
3844
@client.version.to_i.should == 3
45+
verifyBody
3946
end
4047

4148
end
@@ -45,13 +52,17 @@ def authenticate
4552
before do
4653
@client = create_client
4754

48-
fake_post "/api/login/version/3?email=user%40test.com&password=foo&user_key=bar",
55+
fake_post "/api/login/version/3",
4956
%(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">\n <api_key>my_api_key</api_key>\n<version>4</version>\n</rsp>\n)
5057
end
5158

5259
def authenticate
5360
@client.authenticate
5461
end
62+
63+
def verifyBody
64+
FakeWeb.last_request.body.should == 'email=user%40test.com&password=foo&user_key=bar'
65+
end
5566

5667
it "should return the api key" do
5768
authenticate.should == "my_api_key"
@@ -60,16 +71,19 @@ def authenticate
6071
it "should set the api key" do
6172
authenticate
6273
@client.api_key.should == "my_api_key"
74+
verifyBody
6375
end
6476

6577
it "should make authenticated? true" do
6678
authenticate
6779
@client.authenticated?.should == true
80+
verifyBody
6881
end
6982

7083
it "should use version 4" do
7184
authenticate
7285
@client.version.to_i.should == 4
86+
verifyBody
7387
end
7488

7589
end

0 commit comments

Comments
 (0)