From 4b29a5ea234e2c0c36ab5fca8fa0f6dee0085a7e Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 11 Jun 2008 18:52:05 -0500 Subject: Fixing how the indirection tests for whether the request has node info. My request authorization code changed the request to set its 'node' instance variable, rather than using its options, and I apparently didn't change the Indirection class to do this. I have *no* idea how these tests were passing before -- they passed for me yesterday but failed for Andrew, and today they started failing for me. Frightening. --- lib/puppet/indirector/indirection.rb | 2 +- spec/unit/indirector/indirection.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 05464f8c9..4841ec532 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -267,7 +267,7 @@ class Puppet::Indirector::Indirection def check_authorization(request, terminus) # At this point, we're assuming authorization makes no sense without # client information. - return unless request.options[:node] + return unless request.node # This is only to authorize via a terminus-specific authorization hook. return unless terminus.respond_to?(:authorized?) diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb index cefd0557e..5d4539e95 100755 --- a/spec/unit/indirector/indirection.rb +++ b/spec/unit/indirector/indirection.rb @@ -6,7 +6,7 @@ require 'puppet/indirector/indirection' describe "Indirection Delegator", :shared => true do it "should create a request object with the appropriate method name and all of the passed arguments" do - request = stub 'request', :options => {} + request = stub 'request', :node => nil @indirection.expects(:request).with(@method, "mystuff", :one => :two).returns request @@ -339,7 +339,7 @@ describe Puppet::Indirector::Indirection do end it "should use a request to save the object to the cache" do - request = stub 'request', :instance => @instance, :options => {} + request = stub 'request', :instance => @instance, :node => nil @indirection.expects(:request).returns request @@ -370,8 +370,8 @@ describe Puppet::Indirector::Indirection do end it "should use a request instance to search in and remove objects from the cache" do - destroy = stub 'destroy_request', :key => "/my/key", :options => {} - find = stub 'destroy_request', :key => "/my/key", :options => {} + destroy = stub 'destroy_request', :key => "/my/key", :node => nil + find = stub 'destroy_request', :key => "/my/key", :node => nil @indirection.expects(:request).with(:destroy, "/my/key").returns destroy @indirection.expects(:request).with(:find, "/my/key").returns find -- cgit From fb5f09bc347553b2744e5d3b24ddfa26bc0b3c9e Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 11 Jun 2008 18:56:36 -0500 Subject: Fixing how the Indirector::Request sets its options. I wasn't testing whether the options where still a hash, and an 'inject' loop wasn't returning correctly, so the options weren't being set correctly. --- lib/puppet/indirector/request.rb | 1 + spec/unit/indirector/request.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 45c06670b..98fa38885 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -24,6 +24,7 @@ class Puppet::Indirector::Request else result[param] = value end + result end if key.is_a?(String) or key.is_a?(Symbol) diff --git a/spec/unit/indirector/request.rb b/spec/unit/indirector/request.rb index 4f0ad8b6a..f7702f821 100755 --- a/spec/unit/indirector/request.rb +++ b/spec/unit/indirector/request.rb @@ -67,6 +67,14 @@ describe Puppet::Indirector::Request do it "should set be marked authenticated if configured in the options" do Puppet::Indirector::Request.new(:ind, :method, :key, :authenticated => "eh").should be_authenticated end + + it "should keep its options as a hash even if a node is specified" do + Puppet::Indirector::Request.new(:ind, :method, :key, :node => "eh").options.should be_instance_of(Hash) + end + + it "should keep its options as a hash even if another option is specified" do + Puppet::Indirector::Request.new(:ind, :method, :key, :foo => "bar").options.should be_instance_of(Hash) + end end it "should look use the Indirection class to return the appropriate indirection" do -- cgit