summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/handler
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-07-29 12:29:51 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-07-29 12:52:02 -0700
commit94f0b93b6065d1818f0f3b99d12d651655247c30 (patch)
tree3cab88d68ec7f2f4ac0347cec997d172ef04cc33 /spec/unit/network/handler
parent5682125e1800f4c7b69b20fdd28f97a473d5d93c (diff)
downloadpuppet-94f0b93b6065d1818f0f3b99d12d651655247c30.tar.gz
puppet-94f0b93b6065d1818f0f3b99d12d651655247c30.tar.xz
puppet-94f0b93b6065d1818f0f3b99d12d651655247c30.zip
(#8704) Give better errors for invalid fileserver.conf
If you tried to just put an allow or deny line in the fileserver.conf without a mount point, you got a really confusing error message: lib/puppet/network/handler/fileserver.rb:285:in `readconfig': undefined method `info' for nil:NilClass (NoMethodError) Now instead we give an error saying no mount point was specified. Reviewed-by: Josh Cooper <josh@puppetlabs.com>
Diffstat (limited to 'spec/unit/network/handler')
-rwxr-xr-xspec/unit/network/handler/fileserver_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb
index 08852634d..851736e76 100755
--- a/spec/unit/network/handler/fileserver_spec.rb
+++ b/spec/unit/network/handler/fileserver_spec.rb
@@ -25,6 +25,38 @@ describe Puppet::Network::Handler::FileServer do
@mount = Puppet::Network::Handler::FileServer::Mount.new("some_path", @basedir)
end
+ describe "when parsing the fileserver.conf" do
+ it "should create a valid mount when a valid conf is read" do
+ config_file = tmpfile('fileserver.conf')
+ mountdir = tmpdir('mountdir')
+
+ conf_text = <<-HEREDOC
+ [mymount]
+ path #{mountdir}
+ allow anyone.com
+ deny nobody.com
+ HEREDOC
+ File.open(config_file, 'w') { |f| f.write conf_text }
+
+ fs = Puppet::Network::Handler::FileServer.new(:Config => config_file)
+ mounts = fs.instance_variable_get(:@mounts)
+ mount = mounts["mymount"]
+ mount.path == mountdir
+ mount.instance_variable_get(:@declarations).map {|d| d.pattern}.should =~ [["com", "nobody"], ["com", "anyone"]]
+ end
+
+ ['path', 'allow', 'deny'].each do |arg|
+ it "should error if config file doesn't specify a mount for #{arg} argument" do
+ config_file = tmpfile('fileserver.conf')
+ File.open(config_file, 'w') { |f| f.puts "#{arg} 127.0.0.1/24" }
+
+ expect {
+ Puppet::Network::Handler::FileServer.new(:Config => config_file)
+ }.should raise_error(Puppet::Network::Handler::FileServerError, "No mount specified for argument #{arg} 127.0.0.1/24")
+ end
+ end
+ end
+
it "should list a single directory" do
@mount.list("/", false, false).should == [["/", "directory"]]
end