summaryrefslogtreecommitdiffstats
path: root/spec/unit/indirector
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-07-09 20:59:41 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-07-18 10:31:10 +1000
commitb2a008e30ea57f0c94d605de855c45c0fdf0e5ce (patch)
treec64527d7d056c9d67e0ed78e44234b07e3082c36 /spec/unit/indirector
parent8f8240763b0a8ab74b5b78eeb2372a2aa7848049 (diff)
downloadpuppet-b2a008e30ea57f0c94d605de855c45c0fdf0e5ce.tar.gz
puppet-b2a008e30ea57f0c94d605de855c45c0fdf0e5ce.tar.xz
puppet-b2a008e30ea57f0c94d605de855c45c0fdf0e5ce.zip
Fix #2391 - Exported resources never make to the storeconfigs db
The issue is that when we convert Puppet::Parser::Resource catalog to a Puppet::Resource catalog before storing it to the database, we don't allow virtual resource to be converted. Unfortunately exported resources are virtual by design, and as such aren't converted, and we lose them, so it isn't possible to store them in the database. Unfortunately, the client will get the exported resources too. The fix is dual-fold: * we make sure exported resource are skipped when the transaction is applied as a last safeguard * we filter-out the catalog through the catalog compiler terminus before the catalog is returned to the client Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/indirector')
-rwxr-xr-xspec/unit/indirector/catalog/compiler.rb34
-rwxr-xr-xspec/unit/indirector/indirection.rb8
2 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/indirector/catalog/compiler.rb b/spec/unit/indirector/catalog/compiler.rb
index 6e49a6529..78a8028a8 100755
--- a/spec/unit/indirector/catalog/compiler.rb
+++ b/spec/unit/indirector/catalog/compiler.rb
@@ -223,4 +223,38 @@ describe Puppet::Resource::Catalog::Compiler do
@compiler.find(@request)
end
end
+
+ describe "when filtering resources" do
+ before :each do
+ @compiler = Puppet::Resource::Catalog::Compiler.new
+ @catalog = stub_everything 'catalog'
+ @catalog.stubs(:respond_to?).with(:filter).returns(true)
+ end
+
+ it "should delegate to the catalog instance filtering" do
+ @catalog.expects(:filter)
+ @compiler.filter(@catalog)
+ end
+
+ it "should filter out exported resources" do
+ resource = mock 'resource', :exported? => true
+ @catalog.stubs(:filter).yields(resource)
+
+ @compiler.filter(@catalog)
+ end
+
+ it "should return the same catalog if it doesn't support filtering" do
+ @catalog.stubs(:respond_to?).with(:filter).returns(false)
+
+ @compiler.filter(@catalog).should == @catalog
+ end
+
+ it "should return the filtered catalog" do
+ catalog = stub 'filtered catalog'
+ @catalog.stubs(:filter).returns(catalog)
+
+ @compiler.filter(@catalog).should == catalog
+ end
+
+ end
end
diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb
index 5d9efd2ea..220aa24fe 100755
--- a/spec/unit/indirector/indirection.rb
+++ b/spec/unit/indirector/indirection.rb
@@ -243,6 +243,14 @@ describe Puppet::Indirector::Indirection do
@indirection.find("/my/key")
end
+ it "should filter the result instance if the terminus supports it" do
+ @terminus.stubs(:find).returns(@instance)
+ @terminus.stubs(:respond_to?).with(:filter).returns(true)
+
+ @terminus.expects(:filter).with(@instance)
+
+ @indirection.find("/my/key")
+ end
describe "when caching is enabled" do
before do
@indirection.cache_class = :cache_terminus