Skip to content
Browse files

tweak a spec so it's clearer, and add another

  • Loading branch information...
1 parent 16fde36 commit fb652de17554fde7f01c586d044e2ee9410e7248 Dave Steinberg committed May 26, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 spec/auth-hmac_spec.rb
View
9 spec/auth-hmac_spec.rb
@@ -290,10 +290,17 @@ def signature(value, secret)
body_str = "foo=bar&baz=qux"
request = Net::HTTP::Put.new("/")
request.body = mock("Body", :read => body_str, :rewind => nil, :to_str => body_str)
- content_md5 = OpenSSL::Digest::MD5.hexdigest(request.body)
+ content_md5 = OpenSSL::Digest::MD5.hexdigest(body_str)
AuthHMAC::CanonicalString.new(request).should match(/#{content_md5}/)
end
+ it "should not generate the content-md5 if the rack-compatible body is empty" do
+ body_str = ""
+ request = Net::HTTP::Put.new("/")
+ request.body = mock("Body", :read => body_str, :rewind => nil, :to_str => body_str)
+ AuthHMAC::CanonicalString.new(request).should match(/^PUT\n\n\n/)
+ end
+
it "should not generate a content-md5 when there is no request body" do
request = Net::HTTP::Get.new("/")
AuthHMAC::CanonicalString.new(request).should match(/^GET\n\n\n/)

0 comments on commit fb652de

Please sign in to comment.
Something went wrong with that request. Please try again.