spec/rack/contrib/sign/middleware_spec.rb in rack-contrib-sign-0.0.1 vs spec/rack/contrib/sign/middleware_spec.rb in rack-contrib-sign-0.0.2

- old
+ new

@@ -27,20 +27,25 @@ describe "#build_receipt" do it "sets various options" do env = { 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => 'foo/bar', + 'HTTP_HOST' => '127.0.0.1:9292', + 'rack.url_scheme' => 'http', + 'HTTP_CONTENT_TYPE' => 'text/plain', + 'REQUEST_URI' => '/foo/bar', 'HTTP_HI_FOOO' => 'YIPEE', 'rack.input' => StringIO.new('foo=bar') } cred_provider['123'] = 'abc' creds = { key: '123', signature: 'foo' } receipt = ware.build_receipt(env, creds) - receipt.uri.should eq('foo/bar') + receipt.host.should eq('http://127.0.0.1:9292') + receipt.content_type.should eq('text/plain') + receipt.uri.should eq('/foo/bar') receipt.request_method.should eq('POST') receipt.body.should eq('foo=bar') receipt.api_key.should eq('123') receipt.api_secret.should eq('abc') receipt.headers.should eq({ @@ -128,10 +133,12 @@ it "abandons ship if the API key is not known" do env = { 'HTTP_AUTHORIZATION' => 'foo-bar 123:foo', 'REQUEST_METHOD' => '?', + 'HTTP_HOST' => '127.0.0.1:9292', + 'rack.url_scheme' => 'http', 'rack.input' => StringIO.new() } returned = ware.call(env) @@ -141,23 +148,28 @@ it "401s when I don't sign it right" do env = { 'HTTP_AUTHORIZATION' => 'foo-bar abc:YABBA DABBA DOOO', 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => 'http://foo/bar/baz', + 'HTTP_HOST' => '127.0.0.1:9292', + 'rack.url_scheme' => 'http', + 'REQUEST_URI' => '/foo/bar/baz', 'rack.input' => StringIO.new('foo=bar'), } returned = ware.call(env) returned.should eq([401, {}, []]) end it "works when I sign it right" do cred_provider['123'] = 'abc' env = { - 'HTTP_AUTHORIZATION' => 'foo-bar 123:0d501b6934dc0ec5f1452947a7afd108e41c91af', + 'HTTP_AUTHORIZATION' => 'foo-bar 123:75e8d7d1c4eeb07a049f9f7c1395aa2e61e5a879', 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => 'http://foo/bar/baz', + 'HTTP_HOST' => '127.0.0.1:9292', + 'HTTP_CONTENT_TYPE' => 'text/plain', + 'rack.url_scheme' => 'http', + 'REQUEST_URI' => '/foo/bar/baz', 'rack.input' => StringIO.new('foo=bar'), 'HTTP_HI_FOOOO' => 'aoenuoneuh', 'HTTP_BYE_FOOO' => 'oeucorgcgc' }