summaryrefslogtreecommitdiffstats
path: root/spec/shared_behaviours
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-01-02 11:01:24 +1100
committerJames Turnbull <james@lovedthanlost.net>2008-01-02 11:01:24 +1100
commitebe5cc0979b57517f81c84a4d3ee771c12c6a19f (patch)
treed528a4ede6b06cf66e4e1ac9e24c844d73630ed1 /spec/shared_behaviours
parentaed51b4818d64e97778e7e959f258586a36519ad (diff)
parentefd035b73299efd19302cd47edacd5b860a2af55 (diff)
downloadpuppet-ebe5cc0979b57517f81c84a4d3ee771c12c6a19f.tar.gz
puppet-ebe5cc0979b57517f81c84a4d3ee771c12c6a19f.tar.xz
puppet-ebe5cc0979b57517f81c84a4d3ee771c12c6a19f.zip
Merge branch 'master' of git://reductivelabs.com/puppet
Diffstat (limited to 'spec/shared_behaviours')
-rw-r--r--spec/shared_behaviours/file_server_terminus.rb40
-rw-r--r--spec/shared_behaviours/file_serving.rb54
2 files changed, 94 insertions, 0 deletions
diff --git a/spec/shared_behaviours/file_server_terminus.rb b/spec/shared_behaviours/file_server_terminus.rb
new file mode 100644
index 000000000..de08f29fc
--- /dev/null
+++ b/spec/shared_behaviours/file_server_terminus.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#
+# Created by Luke Kanies on 2007-10-18.
+# Copyright (c) 2007. All rights reserved.
+
+describe "Puppet::Indirector::FileServerTerminus", :shared => true do
+ # This only works if the shared behaviour is included before
+ # the 'before' block in the including context.
+ before do
+ Puppet::FileServing::Configuration.clear_cache
+ FileTest.stubs(:exists?).with(Puppet[:fileserverconfig]).returns(true)
+ FileTest.stubs(:exists?).with("/my/mount/path").returns(true)
+ FileTest.stubs(:directory?).with("/my/mount/path").returns(true)
+ FileTest.stubs(:readable?).with("/my/mount/path").returns(true)
+
+ # Use a real mount, so the integration is a bit deeper.
+ @mount1 = Puppet::FileServing::Configuration::Mount.new("one")
+ @mount1.path = "/my/mount/path"
+
+ @parser = stub 'parser', :changed? => false
+ @parser.stubs(:parse).returns("one" => @mount1)
+
+ Puppet::FileServing::Configuration::Parser.stubs(:new).returns(@parser)
+
+ # Stub out the modules terminus
+ @modules = mock 'modules terminus'
+ end
+
+ it "should use the file server configuration to find files" do
+ @modules.stubs(:find).returns(nil)
+ @terminus.indirection.stubs(:terminus).with(:modules).returns(@modules)
+
+ path = "/my/mount/path/my/file"
+ FileTest.stubs(:exists?).with(path).returns(true)
+ FileTest.stubs(:exists?).with("/my/mount/path").returns(true)
+ @mount1.expects(:file).with("my/file", :node => nil).returns(path)
+
+ @terminus.find("puppetmounts://myhost/one/my/file").should be_instance_of(@test_class)
+ end
+end
diff --git a/spec/shared_behaviours/file_serving.rb b/spec/shared_behaviours/file_serving.rb
new file mode 100644
index 000000000..b5ab6b0fd
--- /dev/null
+++ b/spec/shared_behaviours/file_serving.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+#
+# Created by Luke Kanies on 2007-10-18.
+# Copyright (c) 2007. All rights reserved.
+
+describe "Puppet::FileServing::Files", :shared => true do
+ it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do
+ uri = "puppet://myhost/mymod/my/file"
+ @indirection.terminus(:rest).expects(:find).with(uri)
+ @test_class.find(uri)
+ end
+
+ it "should use the rest terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is not 'puppet'" do
+ uri = "puppet:///mymod/my/file"
+ Puppet.settings.stubs(:value).with(:name).returns("puppetd")
+ Puppet.settings.stubs(:value).with(:modulepath).returns("")
+ @indirection.terminus(:rest).expects(:find).with(uri)
+ @test_class.find(uri)
+ end
+
+ it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'puppet'" do
+ uri = "puppet:///mymod/my/file"
+ Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing"))
+ Puppet.settings.stubs(:value).with(:name).returns("puppet")
+ Puppet.settings.stubs(:value).with(:modulepath, "testing").returns("")
+ Puppet.settings.stubs(:value).with(:modulepath).returns("")
+ Puppet.settings.stubs(:value).with(:libdir).returns("")
+ Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
+ Puppet.settings.stubs(:value).with(:environment).returns("")
+ @indirection.terminus(:file_server).expects(:find).with(uri)
+ @indirection.terminus(:file_server).stubs(:authorized?).returns(true)
+ @test_class.find(uri)
+ end
+
+ it "should use the file_server terminus when the 'puppetmounts' URI scheme is used" do
+ uri = "puppetmounts:///mymod/my/file"
+ @indirection.terminus(:file_server).expects(:find).with(uri)
+ @indirection.terminus(:file_server).stubs(:authorized?).returns(true)
+ @test_class.find(uri)
+ end
+
+ it "should use the file terminus when the 'file' URI scheme is used" do
+ uri = "file:///mymod/my/file"
+ @indirection.terminus(:file).expects(:find).with(uri)
+ @test_class.find(uri)
+ end
+
+ it "should use the file terminus when a fully qualified path is provided" do
+ uri = "/mymod/my/file"
+ @indirection.terminus(:file).expects(:find).with(uri)
+ @test_class.find(uri)
+ end
+end
+