Skip to content

Commit

Permalink
Merge pull request #26 from tdegrunt/master
Browse files Browse the repository at this point in the history
Day of the month should be zero-padded, not blank-padded
  • Loading branch information
Xylakant committed Apr 8, 2013
2 parents 009df28 + bf3db17 commit 0bfdcc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/hmac/signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def sign_request(url, secret, opts = {})
headers = opts[:headers] || {}

date = opts[:date] || Time.now.gmtime
date = date.gmtime.strftime('%a, %e %b %Y %T GMT') if date.respond_to? :strftime
date = date.gmtime.strftime('%a, %d %b %Y %T GMT') if date.respond_to? :strftime

method = opts[:method] ? opts[:method].to_s.upcase : "GET"

Expand Down
12 changes: 6 additions & 6 deletions test/faraday/request/hmac_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def reset
m.call({ :request_headers => {}, :url => 'http://www.example.com' })
end

asserts("authorization header") {topic[:request_headers]["Authorization"]}.equals("HMAC 539263f4f83878a4917d2f9c1521320c28b926a9")
asserts("date header") {topic[:request_headers]["Date"]}.equals("Fri, 1 Jul 2011 20:28:55 GMT")
asserts("authorization header") {topic[:request_headers]["Authorization"]}.equals("HMAC 22827f18be7d4b702d402f294516c0461f4994d0")
asserts("date header") {topic[:request_headers]["Date"]}.equals("Fri, 01 Jul 2011 20:28:55 GMT")
asserts("query values") {topic[:url].query}.nil

context "> using a different auth header format" do
Expand All @@ -41,8 +41,8 @@ def reset
m.call({ :request_headers => {}, :url => 'http://www.example.com' })
end

asserts("authorization header") {topic[:request_headers]["Authorization"]}.equals("HMAC TESTKEYID 539263f4f83878a4917d2f9c1521320c28b926a9")
asserts("date header") {topic[:request_headers]["Date"]}.equals("Fri, 1 Jul 2011 20:28:55 GMT")
asserts("authorization header") {topic[:request_headers]["Authorization"]}.equals("HMAC TESTKEYID 22827f18be7d4b702d402f294516c0461f4994d0")
asserts("date header") {topic[:request_headers]["Date"]}.equals("Fri, 01 Jul 2011 20:28:55 GMT")
asserts("query values") {topic[:url].query}.nil
end

Expand All @@ -63,9 +63,9 @@ def reset
Rack::Utils.parse_nested_query(topic[:url].query)
end

asserts("auth date") {topic["auth"]["date"]}.equals("Fri, 1 Jul 2011 20:28:55 GMT")
asserts("auth date") {topic["auth"]["date"]}.equals("Fri, 01 Jul 2011 20:28:55 GMT")
asserts("auth_key") {topic["auth"]["auth_key"]}.equals("TESTKEYID")
asserts("auth signature") {topic["auth"]["signature"]}.equals("539263f4f83878a4917d2f9c1521320c28b926a9")
asserts("auth signature") {topic["auth"]["signature"]}.equals("22827f18be7d4b702d402f294516c0461f4994d0")
end

end
Expand Down

0 comments on commit 0bfdcc3

Please sign in to comment.