diff options
| author | Rick Bradley <rick@rickbradley.com> | 2007-10-16 14:04:38 -0500 |
|---|---|---|
| committer | Rick Bradley <rick@rickbradley.com> | 2007-10-16 14:04:38 -0500 |
| commit | abbc824ff4a565f0a0f1362b779252e876b86168 (patch) | |
| tree | a8f3da778bfcc213e6976c131b9dd080b370d2eb /spec | |
| parent | 2a497fff66a7827059b712e84dcaff171ccab6be (diff) | |
| download | puppet-abbc824ff4a565f0a0f1362b779252e876b86168.tar.gz puppet-abbc824ff4a565f0a0f1362b779252e876b86168.tar.xz puppet-abbc824ff4a565f0a0f1362b779252e876b86168.zip | |
Tweak to move model lookup functionality into the Handler base class where it belongs. Robustifying the request sanitization a bit more.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/unit/network/http/mongrel/rest.rb | 12 | ||||
| -rw-r--r-- | spec/unit/network/http/webrick/rest.rb | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb index c45ca8d66..5bb40d777 100644 --- a/spec/unit/network/http/mongrel/rest.rb +++ b/spec/unit/network/http/mongrel/rest.rb @@ -89,6 +89,18 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'POST', Mongrel::Const::REQUEST_PATH => '/foo'}) Proc.new { @handler.process(@mock_request, @mock_response) }.should raise_error(ArgumentError) end + + it "should fail if the request's pluralization is wrong" do + @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'DELETE', Mongrel::Const::REQUEST_PATH => '/foos'}) + Proc.new { @handler.process(@mock_request, @mock_response) }.should raise_error(ArgumentError) + @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'PUT', Mongrel::Const::REQUEST_PATH => '/foos'}) + Proc.new { @handler.process(@mock_request, @mock_response) }.should raise_error(ArgumentError) + end + + it "should fail if the request is for an unknown path" do + @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'GET', Mongrel::Const::REQUEST_PATH => '/bar'}) + Proc.new { @handler.process(@mock_request, @mock_response) }.should raise_error(ArgumentError) + end it "should unpack request information from Mongrel" diff --git a/spec/unit/network/http/webrick/rest.rb b/spec/unit/network/http/webrick/rest.rb index 472a09aca..6eb44f4be 100644 --- a/spec/unit/network/http/webrick/rest.rb +++ b/spec/unit/network/http/webrick/rest.rb @@ -94,6 +94,21 @@ describe Puppet::Network::HTTP::WEBrickREST, "when receiving a request" do @mock_request.stubs(:path).returns('/foo') Proc.new { @handler.service(@mock_request, @mock_response) }.should raise_error(ArgumentError) end + + it "should fail if the request's pluralization is wrong" do + @mock_request.stubs(:request_method).returns('DELETE') + @mock_request.stubs(:path).returns('/foos') + Proc.new { @handler.process(@mock_request, @mock_response) }.should raise_error(ArgumentError) + @mock_request.stubs(:request_method).returns('PUT') + @mock_request.stubs(:path).returns('/foos') + Proc.new { @handler.process(@mock_request, @mock_response) }.should raise_error(ArgumentError) + end + + it "should fail if the request is for an unknown path" do + @mock_request.stubs(:request_method).returns('GET') + @mock_request.stubs(:path).returns('/bar') + Proc.new { @handler.process(@mock_request, @mock_response) }.should raise_error(ArgumentError) + end it "should unpack request information from WEBrick" |
