summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/http
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-01-19 17:36:23 -0800
committerMatt Robinson <matt@puppetlabs.com>2011-01-19 17:36:23 -0800
commit6d9cae2e9ca6a56506f679db02ba9abb30a4df91 (patch)
tree854c260815825a8d5368296aecf7bc86f8ea8ff9 /spec/unit/network/http
parent27abd84611564ac573c5fde8abb6b98e6bd3d9b7 (diff)
parent517c6794606e9adde7f2912d3b949cfcc18a446a (diff)
Merge branch '2.6.x' into next
* 2.6.x: (21 commits) (#5900) Include ResourceStatus#failed in serialized reports (#5882) Added error-handling for bucketing files in puppet inspect (#5882) Added error-handling to puppet inspect when auditing (#5171) Made "puppet inspect" upload audited files to a file bucket Prep for #5171: Added a missing require to inspect application. Locked Puppet license to GPLv2 (#5838) Support paths as part of file bucket requests. (#5838) Improve the quality of file bucket specs. (#5838) Make file bucket dipper efficient when saving a file that already exists (#5838) Implemented the "head" method for FileBucketFile::File terminus. (#5838) Reworked file dipper spec to perform less stubbing. (#5838) Added support for HEAD requests to the indirector. (#5838) Refactored error handling logic into find_in_cache. (#5838) Refactored Puppet::Network::Rights#fail_on_deny maint: Remove unused Rakefile in spec directory (#5171) Made filebucket able to perform diffs (#5710) Removed unnecessary calls to insync? Prep for fixing #5710: Refactor stub provider in resource harness spec Maint: test partial resource failure maint: Inspect reports should have audited = true on events ... Manually Resolved Conflicts: lib/puppet/file_bucket/dipper.rb lib/puppet/indirector.rb lib/puppet/network/rest_authconfig.rb spec/unit/file_bucket/dipper_spec.rb spec/unit/file_bucket/file_spec.rb spec/unit/indirector_spec.rb
Diffstat (limited to 'spec/unit/network/http')
-rw-r--r--spec/unit/network/http/api/v1_spec.rb4
-rwxr-xr-xspec/unit/network/http/handler_spec.rb39
2 files changed, 43 insertions, 0 deletions
diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb
index 84b98ddaf..a1cb75841 100644
--- a/spec/unit/network/http/api/v1_spec.rb
+++ b/spec/unit/network/http/api/v1_spec.rb
@@ -68,6 +68,10 @@ describe Puppet::Network::HTTP::API::V1 do
@tester.uri2indirection("GET", "/env/foo/bar", {})[1].should == :find
end
+ it "should choose 'head' as the indirection method if the http method is a HEAD and the indirection name is singular" do
+ @tester.uri2indirection("HEAD", "/env/foo/bar", {})[1].should == :head
+ end
+
it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is plural" do
@tester.uri2indirection("GET", "/env/foos/bar", {})[1].should == :search
end
diff --git a/spec/unit/network/http/handler_spec.rb b/spec/unit/network/http/handler_spec.rb
index ff60c78fc..97d17fcf8 100755
--- a/spec/unit/network/http/handler_spec.rb
+++ b/spec/unit/network/http/handler_spec.rb
@@ -192,6 +192,12 @@ describe Puppet::Network::HTTP::Handler do
@handler.do_find("my_handler", "my_result", {}, @request, @response)
end
+ it "should pass the result through without rendering it if the result is a string" do
+ @indirection.stubs(:find).returns "foo"
+ @handler.expects(:set_response).with(@response, "foo")
+ @handler.do_find("my_handler", "my_result", {}, @request, @response)
+ end
+
it "should use the default status when a model find call succeeds" do
@handler.expects(:set_response).with { |response, body, status| status.nil? }
@handler.do_find("my_handler", "my_result", {}, @request, @response)
@@ -233,6 +239,39 @@ describe Puppet::Network::HTTP::Handler do
end
end
+ describe "when performing head operation" do
+ before do
+ @irequest = stub 'indirection_request', :method => :head, :indirection_name => "my_handler", :to_hash => {}, :key => "my_result", :model => @model_class
+
+ @model_class.stubs(:head).returns true
+ end
+
+ it "should use the indirection request to find the model class" do
+ @irequest.expects(:model).returns @model_class
+
+ @handler.do_head(@irequest, @request, @response)
+ end
+
+ it "should use the escaped request key" do
+ @model_class.expects(:head).with do |key, args|
+ key == "my_result"
+ end.returns true
+ @handler.do_head(@irequest, @request, @response)
+ end
+
+ it "should not generate a response when a model head call succeeds" do
+ @handler.expects(:set_response).never
+ @handler.do_head(@irequest, @request, @response)
+ end
+
+ it "should return a 404 when the model head call returns false" do
+ @model_class.stubs(:name).returns "my name"
+ @handler.expects(:set_response).with { |response, body, status| status == 404 }
+ @model_class.stubs(:head).returns(false)
+ @handler.do_head(@irequest, @request, @response)
+ end
+ end
+
describe "when searching for model instances" do
before do
Puppet::Indirector::Indirection.expects(:instance).with(:my_handler).returns( stub "indirection", :model => @model_class )