summaryrefslogtreecommitdiffstats
path: root/spec/integration/indirector
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-23 12:10:35 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-24 11:34:38 +1000
commitc0da3bfebb40198703d7d99f2809b315682e28fc (patch)
treeb58b7ebf1cddc3516049d7b178b010cc2025acac /spec/integration/indirector
parentff39bc707e7f37ddeb28203a9e1bfaddcb9dc641 (diff)
downloadpuppet-c0da3bfebb40198703d7d99f2809b315682e28fc.tar.gz
puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.tar.xz
puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.zip
Fixing #2558 - propagating recent fileserving changes
I'd made changes to the internals of the fileserving system to fix #2544 (mostly switched from passing the node around and then calculating the environment to just passing the environment around), but those changes weren't consistent throughout the fileserving code. In the process of making them consistent, I realized that the plain file server actually needs the node name rather than the environment, so I switched to passing the request around, because it has both pieces of information. Also added further integration tests which will hopefully keep this from cropping up again. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/integration/indirector')
-rwxr-xr-xspec/integration/indirector/file_content/file_server.rb52
1 files changed, 51 insertions, 1 deletions
diff --git a/spec/integration/indirector/file_content/file_server.rb b/spec/integration/indirector/file_content/file_server.rb
index b3c63fc33..ea892302e 100755
--- a/spec/integration/indirector/file_content/file_server.rb
+++ b/spec/integration/indirector/file_content/file_server.rb
@@ -19,7 +19,7 @@ describe Puppet::Indirector::FileContent::FileServer, " when finding files" do
@test_class = Puppet::FileServing::Content
end
- it "should find file content in the environment specified in the request" do
+ it "should find plugin file content in the environment specified in the request" do
path = tmpfile("file_content_with_env")
Dir.mkdir(path)
@@ -40,4 +40,54 @@ describe Puppet::Indirector::FileContent::FileServer, " when finding files" do
result[1].should be_instance_of(Puppet::FileServing::Content)
result[1].content.should == "1\n"
end
+
+ it "should find file content in modules" do
+ path = tmpfile("file_content")
+
+ Dir.mkdir(path)
+
+ modpath = File.join(path, "mymod")
+ FileUtils.mkdir_p(File.join(modpath, "files"))
+ file = File.join(modpath, "files", "myfile")
+ File.open(file, "w") { |f| f.puts "1" }
+
+ Puppet.settings[:modulepath] = path
+
+ result = Puppet::FileServing::Content.find("modules/mymod/myfile")
+
+ result.should_not be_nil
+ result.should be_instance_of(Puppet::FileServing::Content)
+ result.content.should == "1\n"
+ end
+
+ it "should find file content in files when node name expansions are used" do
+ Puppet::Util::Cacher.expire
+ FileTest.stubs(:exists?).returns true
+ FileTest.stubs(:exists?).with(Puppet[:fileserverconfig]).returns(true)
+
+ @path = tmpfile("file_server_testing")
+
+ Dir.mkdir(@path)
+ subdir = File.join(@path, "mynode")
+ Dir.mkdir(subdir)
+ File.open(File.join(subdir, "myfile"), "w") { |f| f.puts "1" }
+
+ # Use a real mount, so the integration is a bit deeper.
+ @mount1 = Puppet::FileServing::Configuration::Mount::File.new("one")
+ @mount1.stubs(:allowed?).returns true
+ @mount1.path = File.join(@path, "%h")
+
+ @parser = stub 'parser', :changed? => false
+ @parser.stubs(:parse).returns("one" => @mount1)
+
+ Puppet::FileServing::Configuration::Parser.stubs(:new).returns(@parser)
+
+ path = File.join(@path, "myfile")
+
+ result = Puppet::FileServing::Content.find("one/myfile", :environment => "foo", :node => "mynode")
+
+ result.should_not be_nil
+ result.should be_instance_of(Puppet::FileServing::Content)
+ result.content.should == "1\n"
+ end
end