The environment returned by uri2indirection used to be a
Puppet::Node::Environment.  When this changed to simply being the
string of the environment name, this broke assumptions made in other
areas of the code.

Paired-with: Nick Lewis <[email protected]>
Signed-off-by: Jacob Helwig <[email protected]>
---

Local-branch: tickets/2.7.x/7117-authconf-should-respect-environment

 lib/puppet/network/http/api/v1.rb     |    2 +-
 spec/unit/network/http/api/v1_spec.rb |    8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/network/http/api/v1.rb 
b/lib/puppet/network/http/api/v1.rb
index 61307f0..388d549 100644
--- a/lib/puppet/network/http/api/v1.rb
+++ b/lib/puppet/network/http/api/v1.rb
@@ -30,7 +30,7 @@ module Puppet::Network::HTTP::API::V1
 
     method = indirection_method(http_method, indirection)
 
-    params[:environment] = environment
+    params[:environment] = Puppet::Node::Environment.new(environment)
 
     raise ArgumentError, "No request key specified in #{uri}" if key == "" or 
key.nil?
 
diff --git a/spec/unit/network/http/api/v1_spec.rb 
b/spec/unit/network/http/api/v1_spec.rb
index bd95071..a952f24 100755
--- a/spec/unit/network/http/api/v1_spec.rb
+++ b/spec/unit/network/http/api/v1_spec.rb
@@ -31,7 +31,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", 
{})[3][:environment].should == "env"
+      @tester.uri2indirection("GET", "/env/foo/bar", 
{})[3][:environment].to_s.should == "env"
     end
 
     it "should fail if the environment is not alphanumeric" do
@@ -39,7 +39,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"})[3][:environment].should == "env"
+      @tester.uri2indirection("GET", "/env/foo/bar", {:environment => 
"otherenv"})[3][:environment].to_s.should == "env"
+    end
+
+    it "should return the environment as a Puppet::Node::Environment" do
+      @tester.uri2indirection("GET", "/env/foo/bar", 
{})[3][:environment].should be_a Puppet::Node::Environment
     end
 
     it "should use the second field of the URI as the indirection name" do
-- 
1.7.5

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to