summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/http/api
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-11-01 18:03:02 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-11-02 11:11:47 -0700
commitcfe202539018b27c35ff833152f237bc30569a5f (patch)
tree2ca24f5af952c5ef5456ec85ad4fe9e5acf14ac3 /spec/unit/network/http/api
parenta82f4d23fe5a025b8a9e893d29933f092973f014 (diff)
downloadpuppet-cfe202539018b27c35ff833152f237bc30569a5f.tar.gz
puppet-cfe202539018b27c35ff833152f237bc30569a5f.tar.xz
puppet-cfe202539018b27c35ff833152f237bc30569a5f.zip
Maint: Remove Indirector::Request objects from HTTP Handler and API V1
This is a maintenance refactor to reduce the dependencies between the rest API and the implementation of the Indirector. The HTTP Handler code was creating temporary Request objects that were not actually being passed to the Indirector.
Diffstat (limited to 'spec/unit/network/http/api')
-rw-r--r--spec/unit/network/http/api/v1_spec.rb27
1 files changed, 14 insertions, 13 deletions
diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb
index 8d507046f..84b98ddaf 100644
--- a/spec/unit/network/http/api/v1_spec.rb
+++ b/spec/unit/network/http/api/v1_spec.rb
@@ -32,7 +32,7 @@ describe Puppet::Network::HTTP::API::V1 do
end
it "should use the first field of the URI as the environment" do
- @tester.uri2indirection("GET", "/env/foo/bar", {}).environment.should == Puppet::Node::Environment.new("env")
+ @tester.uri2indirection("GET", "/env/foo/bar", {})[3][:environment].should == "env"
end
it "should fail if the environment is not alphanumeric" do
@@ -40,11 +40,11 @@ describe Puppet::Network::HTTP::API::V1 do
end
it "should use the environment from the URI even if one is specified in the parameters" do
- @tester.uri2indirection("GET", "/env/foo/bar", {:environment => "otherenv"}).environment.should == Puppet::Node::Environment.new("env")
+ @tester.uri2indirection("GET", "/env/foo/bar", {:environment => "otherenv"})[3][:environment].should == "env"
end
it "should use the second field of the URI as the indirection name" do
- @tester.uri2indirection("GET", "/env/foo/bar", {}).indirection_name.should == :foo
+ @tester.uri2indirection("GET", "/env/foo/bar", {})[0].should == "foo"
end
it "should fail if the indirection name is not alphanumeric" do
@@ -52,11 +52,11 @@ describe Puppet::Network::HTTP::API::V1 do
end
it "should use the remainder of the URI as the indirection key" do
- @tester.uri2indirection("GET", "/env/foo/bar", {}).key.should == "bar"
+ @tester.uri2indirection("GET", "/env/foo/bar", {})[2].should == "bar"
end
it "should support the indirection key being a /-separated file path" do
- @tester.uri2indirection("GET", "/env/foo/bee/baz/bomb", {}).key.should == "bee/baz/bomb"
+ @tester.uri2indirection("GET", "/env/foo/bee/baz/bomb", {})[2].should == "bee/baz/bomb"
end
it "should fail if no indirection key is specified" do
@@ -65,31 +65,31 @@ describe Puppet::Network::HTTP::API::V1 do
end
it "should choose 'find' as the indirection method if the http method is a GET and the indirection name is singular" do
- @tester.uri2indirection("GET", "/env/foo/bar", {}).method.should == :find
+ @tester.uri2indirection("GET", "/env/foo/bar", {})[1].should == :find
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", {}).method.should == :search
+ @tester.uri2indirection("GET", "/env/foos/bar", {})[1].should == :search
end
it "should choose 'find' as the indirection method if the http method is a GET and the indirection name is facts" do
- @tester.uri2indirection("GET", "/env/facts/bar", {}).method.should == :find
+ @tester.uri2indirection("GET", "/env/facts/bar", {})[1].should == :find
end
it "should choose 'save' as the indirection method if the http method is a PUT and the indirection name is facts" do
- @tester.uri2indirection("PUT", "/env/facts/bar", {}).method.should == :save
+ @tester.uri2indirection("PUT", "/env/facts/bar", {})[1].should == :save
end
it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is inventory" do
- @tester.uri2indirection("GET", "/env/inventory/search", {}).method.should == :search
+ @tester.uri2indirection("GET", "/env/inventory/search", {})[1].should == :search
end
it "should choose 'delete' as the indirection method if the http method is a DELETE and the indirection name is singular" do
- @tester.uri2indirection("DELETE", "/env/foo/bar", {}).method.should == :destroy
+ @tester.uri2indirection("DELETE", "/env/foo/bar", {})[1].should == :destroy
end
it "should choose 'save' as the indirection method if the http method is a PUT and the indirection name is singular" do
- @tester.uri2indirection("PUT", "/env/foo/bar", {}).method.should == :save
+ @tester.uri2indirection("PUT", "/env/foo/bar", {})[1].should == :save
end
it "should fail if an indirection method cannot be picked" do
@@ -98,7 +98,8 @@ describe Puppet::Network::HTTP::API::V1 do
it "should URI unescape the indirection key" do
escaped = URI.escape("foo bar")
- @tester.uri2indirection("GET", "/env/foo/#{escaped}", {}).key.should == "foo bar"
+ indirection_name, method, key, params = @tester.uri2indirection("GET", "/env/foo/#{escaped}", {})
+ key.should == "foo bar"
end
end