Skip to content

Commit

Permalink
W-5653730: Change to pass auth parameters in body.
Browse files Browse the repository at this point in the history
Passing parameters using query string to auth is deprecated.
  • Loading branch information
Jared committed Jan 30, 2019
1 parent fdc4dc8 commit 28b2368
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
PATH
remote: .
specs:
ruby-pardot (1.1.0)
crack
httparty
ruby-pardot (1.2.0)
crack (= 0.4.3)
httparty (= 0.13.1)

GEM
remote: http://rubygems.org/
specs:
crack (0.4.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.1.2)
fakeweb (1.3.0)
httparty (0.13.1)
json (~> 1.8)
multi_xml (>= 0.5.2)
json (1.8.3)
multi_xml (0.5.5)
json (1.8.6)
multi_xml (0.6.0)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
Expand All @@ -37,4 +37,4 @@ DEPENDENCIES
ruby-pardot!

BUNDLED WITH
1.11.2
2.0.1
2 changes: 1 addition & 1 deletion lib/pardot/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Pardot
module Authentication

def authenticate
resp = post "login", nil, :email => @email, :password => @password, :user_key => @user_key
resp = post "login", nil, nil, nil, :email => @email, :password => @password, :user_key => @user_key
update_version(resp["version"]) if resp && resp["version"]
@api_key = resp && resp["api_key"]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pardot/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def get object, path, params = {}, num_retries = 0
raise Pardot::NetError.new(e)
end

def post object, path, params = {}, num_retries = 0
def post object, path, params = {}, num_retries = 0, bodyParams = {}
smooth_params object, params
full_path = fullpath object, path
check_response self.class.post(full_path, :query => params)
check_response self.class.post(full_path, :query => params, :body => bodyParams)

rescue Pardot::ExpiredApiKeyError => e
handle_expired_api_key :post, object, path, params, num_retries, e
Expand Down
2 changes: 1 addition & 1 deletion lib/pardot/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Pardot
VERSION = "1.1.0"
VERSION = "1.2.0"
end
4 changes: 2 additions & 2 deletions ruby-pardot.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Gem::Specification.new do |s|
s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "ruby-pardot"

s.add_dependency "crack"
s.add_dependency "httparty"
s.add_dependency "crack", "0.4.3"
s.add_dependency "httparty", "0.13.1"

s.add_development_dependency "bundler", ">= 1.10"
s.add_development_dependency "rspec"
Expand Down
18 changes: 16 additions & 2 deletions spec/pardot/authentication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ def create_client
before do
@client = create_client

fake_post "/api/login/version/3?email=user%40test.com&password=foo&user_key=bar",
fake_post "/api/login/version/3",
%(<?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)
end

def authenticate
@client.authenticate
end

def verifyBody
FakeWeb.last_request.body.should == 'email=user%40test.com&password=foo&user_key=bar'
end

it "should return the api key" do
authenticate.should == "my_api_key"
Expand All @@ -26,16 +30,19 @@ def authenticate
it "should set the api key" do
authenticate
@client.api_key.should == "my_api_key"
verifyBody
end

it "should make authenticated? true" do
authenticate
@client.authenticated?.should == true
verifyBody
end

it "should use version 3" do
authenticate
@client.version.to_i.should == 3
verifyBody
end

end
Expand All @@ -45,13 +52,17 @@ def authenticate
before do
@client = create_client

fake_post "/api/login/version/3?email=user%40test.com&password=foo&user_key=bar",
fake_post "/api/login/version/3",
%(<?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)
end

def authenticate
@client.authenticate
end

def verifyBody
FakeWeb.last_request.body.should == 'email=user%40test.com&password=foo&user_key=bar'
end

it "should return the api key" do
authenticate.should == "my_api_key"
Expand All @@ -60,16 +71,19 @@ def authenticate
it "should set the api key" do
authenticate
@client.api_key.should == "my_api_key"
verifyBody
end

it "should make authenticated? true" do
authenticate
@client.authenticated?.should == true
verifyBody
end

it "should use version 4" do
authenticate
@client.version.to_i.should == 4
verifyBody
end

end
Expand Down

0 comments on commit 28b2368

Please sign in to comment.