diff options
| author | Luke Kanies <luke@madstop.com> | 2008-07-29 00:46:11 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-07-29 00:46:11 -0500 |
| commit | 40375a8fc34dbd85d87f507ba72c7394b25b7271 (patch) | |
| tree | efd5a93980b042b73322bd31e6fdb41203d07576 /spec | |
| parent | 93eeff59d807261ed154cc104e318ae604602430 (diff) | |
| parent | 8f5800f0608dff46407cb5f23ee73f314fe051e8 (diff) | |
| download | puppet-40375a8fc34dbd85d87f507ba72c7394b25b7271.tar.gz puppet-40375a8fc34dbd85d87f507ba72c7394b25b7271.tar.xz puppet-40375a8fc34dbd85d87f507ba72c7394b25b7271.zip | |
Merge branch '0.24.x' into merging
Conflicts:
test/ral/type/filesources.rb
Diffstat (limited to 'spec')
25 files changed, 385 insertions, 230 deletions
diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb index eba58a3d5..fcf8ccf22 100755 --- a/spec/integration/defaults.rb +++ b/spec/integration/defaults.rb @@ -47,4 +47,8 @@ describe "Puppet defaults" do Puppet.settings.element(:rundir).owner.should be_nil Puppet.settings.element(:rundir).group.should be_nil end + + it "should default to yaml as the catalog format" do + Puppet.settings[:catalog_format].should == "yaml" + end end diff --git a/spec/integration/file_serving/metadata.rb b/spec/integration/file_serving/metadata.rb index 5600365f1..067cb566a 100755 --- a/spec/integration/file_serving/metadata.rb +++ b/spec/integration/file_serving/metadata.rb @@ -16,4 +16,3 @@ describe Puppet::FileServing::Metadata, " when finding files" do @indirection = Puppet::FileServing::Metadata.indirection end end - diff --git a/spec/integration/indirector/module_files.rb b/spec/integration/indirector/module_files.rb index 1831bffbc..ae14aa5a7 100755 --- a/spec/integration/indirector/module_files.rb +++ b/spec/integration/indirector/module_files.rb @@ -20,7 +20,9 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with Puppet::Module FileTest.expects(:exists?).with(filepath).returns(true) - @terminus.find("puppetmounts://host/modules/mymod/myfile").should be_instance_of(Puppet::FileServing::Content) + @request = Puppet::Indirector::Request.new(:content, :find, "puppetmounts://host/modules/mymod/myfile") + + @terminus.find(@request).should be_instance_of(Puppet::FileServing::Content) end end @@ -45,7 +47,9 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with FileServing::F Dir.expects(:entries).with(filepath).returns(%w{one two}) - result = @terminus.search("puppetmounts://host/modules/mymod/myfile", :recurse => true) + @request = Puppet::Indirector::Request.new(:content, :search, "puppetmounts://host/modules/mymod/myfile", :recurse => true) + + result = @terminus.search(@request) result.should be_instance_of(Array) result.length.should == 3 result.each { |r| r.should be_instance_of(Puppet::FileServing::Content) } diff --git a/spec/integration/node/catalog.rb b/spec/integration/node/catalog.rb index 87d62ea6a..75be9501a 100755 --- a/spec/integration/node/catalog.rb +++ b/spec/integration/node/catalog.rb @@ -40,5 +40,15 @@ describe Puppet::Node::Catalog do Puppet::Node::Catalog.find("me").should be_nil end + + it "should pass provided node information directly to the terminus" do + terminus = mock 'terminus' + + Puppet::Node::Catalog.indirection.stubs(:terminus).returns terminus + + node = mock 'node' + terminus.expects(:find).with { |request| request.options[:use_node] == node } + Puppet::Node::Catalog.find("me", :use_node => node) + end end end diff --git a/spec/shared_behaviours/file_server_terminus.rb b/spec/shared_behaviours/file_server_terminus.rb index 883db58f5..0230d39e8 100644 --- a/spec/shared_behaviours/file_server_terminus.rb +++ b/spec/shared_behaviours/file_server_terminus.rb @@ -24,6 +24,8 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do # Stub out the modules terminus @modules = mock 'modules terminus' + + @request = Puppet::Indirector::Request.new(:indirection, :method, "puppetmounts://myhost/one/my/file") end it "should use the file server configuration to find files" do @@ -35,6 +37,6 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do 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) + @terminus.find(@request).should be_instance_of(@test_class) end end diff --git a/spec/shared_behaviours/file_serving.rb b/spec/shared_behaviours/file_serving.rb index 82f207243..ba01f75a1 100644 --- a/spec/shared_behaviours/file_serving.rb +++ b/spec/shared_behaviours/file_serving.rb @@ -5,13 +5,13 @@ 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" + uri = "puppet://myhost/fakemod/my/file" @indirection.terminus(:rest).expects(:find) @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" + uri = "puppet:///fakemod/my/file" Puppet.settings.stubs(:value).with(:name).returns("puppetd") Puppet.settings.stubs(:value).with(:modulepath).returns("") @indirection.terminus(:rest).expects(:find) @@ -19,7 +19,7 @@ describe "Puppet::FileServing::Files", :shared => true do 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" + uri = "puppet:///fakemod/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("") @@ -33,22 +33,32 @@ describe "Puppet::FileServing::Files", :shared => true do end it "should use the file_server terminus when the 'puppetmounts' URI scheme is used" do - uri = "puppetmounts:///mymod/my/file" + uri = "puppetmounts:///fakemod/my/file" @indirection.terminus(:file_server).expects(:find) @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" + uri = "file:///fakemod/my/file" @indirection.terminus(:file).expects(:find) @test_class.find(uri) end it "should use the file terminus when a fully qualified path is provided" do - uri = "/mymod/my/file" + uri = "/fakemod/my/file" @indirection.terminus(:file).expects(:find) @test_class.find(uri) end + + it "should use the configuration to test whether the request is allowed" do + uri = "puppetmounts:///fakemod/my/file" + config = mock 'configuration' + @indirection.terminus(:file_server).stubs(:configuration).returns config + + @indirection.terminus(:file_server).expects(:find) + config.expects(:authorized?).returns(true) + @test_class.find(uri, :node => "foo", :ip => "bar") + end end diff --git a/spec/unit/file_serving/terminus_helper.rb b/spec/unit/file_serving/terminus_helper.rb index b919469a2..763ce9eb0 100755 --- a/spec/unit/file_serving/terminus_helper.rb +++ b/spec/unit/file_serving/terminus_helper.rb @@ -14,65 +14,63 @@ describe Puppet::FileServing::TerminusHelper do @model = mock 'model' @helper.stubs(:model).returns(@model) + + @request = stub 'request', :key => "url", :options => {} end it "should use a fileset to find paths" do fileset = mock 'fileset', :files => [] Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(fileset) - @helper.path2instances("url", "/my/file") + @helper.path2instances(@request, "/my/file") end it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do fileset = mock 'fileset', :files => [] Puppet::FileServing::Fileset.expects(:new).with("/my/file", :links => :a, :ignore => :b, :recurse => :c).returns(fileset) - @helper.path2instances("url", "/my/file", :links => :a, :ignore => :b, :recurse => :c) - end -end - - -describe Puppet::FileServing::TerminusHelper, " when creating instances" do - before do - @helper = Object.new - @helper.extend(Puppet::FileServing::TerminusHelper) - - @model = mock 'model' - @helper.stubs(:model).returns(@model) - - @key = "puppet://host/mount/dir" - - @fileset = mock 'fileset', :files => %w{one two} - Puppet::FileServing::Fileset.expects(:new).returns(@fileset) - end - - it "should create an instance of the model for each path returned by the fileset" do - @model.expects(:new).returns(:one) - @model.expects(:new).returns(:two) - @helper.path2instances(@key, "/my/file").length.should == 2 - end - - it "should set each instance's key to be the original key plus the file-specific path" do - @model.expects(:new).with { |key, options| key == @key + "/one" }.returns(:one) - @model.expects(:new).with { |key, options| key == @key + "/two" }.returns(:two) - @helper.path2instances(@key, "/my/file") - end - - it "should set each returned instance's path to the original path" do - @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one) - @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two) - @helper.path2instances(@key, "/my/file") - end - - it "should set each returned instance's relative path to the file-specific path" do - @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one) - @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two) - @helper.path2instances(@key, "/my/file") + @request.stubs(:options).returns(:links => :a, :ignore => :b, :recurse => :c) + @helper.path2instances(@request, "/my/file") end - it "should set the links value on each instance if one is provided" do - one = mock 'one', :links= => :manage - two = mock 'two', :links= => :manage - @model.expects(:new).returns(one) - @model.expects(:new).returns(two) - @helper.path2instances(@key, "/my/file", :links => :manage) + describe "when creating instances" do + before do + @request.stubs(:key).returns "puppet://host/mount/dir" + + @fileset = mock 'fileset', :files => %w{one two} + Puppet::FileServing::Fileset.expects(:new).returns(@fileset) + end + + it "should create an instance of the model for each path returned by the fileset" do + @model.expects(:new).returns(:one) + @model.expects(:new).returns(:two) + @helper.path2instances(@request, "/my/file").length.should == 2 + end + + it "should set each instance's key to be the original key plus the file-specific path" do + @model.expects(:new).with { |key, options| key == @request.key + "/one" }.returns(:one) + @model.expects(:new).with { |key, options| key == @request.key + "/two" }.returns(:two) + @helper.path2instances(@request, "/my/file") + end + + it "should set each returned instance's path to the original path" do + @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one) + @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two) + @helper.path2instances(@request, "/my/file") + end + + it "should set each returned instance's relative path to the file-specific path" do + @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one) + @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two) + @helper.path2instances(@request, "/my/file") + end + + it "should set the links value on each instance if one is provided" do + one = mock 'one', :links= => :manage + two = mock 'two', :links= => :manage + @model.expects(:new).returns(one) + @model.expects(:new).returns(two) + + @request.options[:links] = :manage + @helper.path2instances(@request, "/my/file") + end end end diff --git a/spec/unit/indirector/catalog/compiler.rb b/spec/unit/indirector/catalog/compiler.rb index cf7186a5a..8cd3c72f4 100755 --- a/spec/unit/indirector/catalog/compiler.rb +++ b/spec/unit/indirector/catalog/compiler.rb @@ -114,13 +114,12 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do @node = Puppet::Node.new @name @node.stubs(:merge) @request = stub 'request', :key => @name, :options => {} - Puppet::Node.stubs(:find).with(@name).returns(@node) end it "should directly use provided nodes" do Puppet::Node.expects(:find).never - @compiler.interpreter.expects(:compile).with(@node) - @request.stubs(:options).returns(:node => @node) + @compiler.expects(:compile).with(@node) + @request.stubs(:options).returns(:use_node => @node) @compiler.find(@request) end @@ -130,12 +129,14 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do end it "should pass the found node to the interpreter for compiling" do + Puppet::Node.expects(:find).with(@name).returns(@node) config = mock 'config' @compiler.interpreter.expects(:compile).with(@node) @compiler.find(@request) end it "should return the results of compiling as the catalog" do + Puppet::Node.stubs(:find).returns(@node) config = mock 'config' result = mock 'result' @@ -144,6 +145,7 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do end it "should benchmark the compile process" do + Puppet::Node.stubs(:find).returns(@node) @compiler.stubs(:networked?).returns(true) @compiler.expects(:benchmark).with do |level, message| level == :notice and message =~ /^Compiled catalog/ diff --git a/spec/unit/indirector/direct_file_server.rb b/spec/unit/indirector/direct_file_server.rb index a8583716a..0753f1bbe 100755 --- a/spec/unit/indirector/direct_file_server.rb +++ b/spec/unit/indirector/direct_file_server.rb @@ -69,29 +69,20 @@ describe Puppet::Indirector::DirectFileServer do end describe Puppet::Indirector::DirectFileServer, "when searching for multiple files" do - it "should return nil if the file does not exist" do FileTest.expects(:exists?).with("/my/local").returns false @server.find(@request).should be_nil end - it "should pass the original key to :path2instances" do - FileTest.expects(:exists?).with("/my/local").returns true - @server.expects(:path2instances).with { |uri, path, options| uri == @uri } - @server.search(@request) - end - it "should use :path2instances from the terminus_helper to return instances if the file exists" do FileTest.expects(:exists?).with("/my/local").returns true @server.expects(:path2instances) @server.search(@request) end - it "should pass any options on to :path2instances" do + it "should pass the original request to :path2instances" do FileTest.expects(:exists?).with("/my/local").returns true - @server.expects(:path2instances).with { |uri, path, options| options == {:testing => :one, :other => :two}} - - @request.stubs(:options).returns(:testing => :one, :other => :two) + @server.expects(:path2instances).with(@request, "/my/local") @server.search(@request) end end diff --git a/spec/unit/indirector/file_metadata/modules.rb b/spec/unit/indirector/file_metadata/modules.rb index 62f01832c..3905a49ad 100755 --- a/spec/unit/indirector/file_metadata/modules.rb +++ b/spec/unit/indirector/file_metadata/modules.rb @@ -23,11 +23,13 @@ describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do @finder.stubs(:environment).returns(nil) @module = Puppet::Module.new("mymod", "/path/to") @finder.stubs(:find_module).returns(@module) + + @request = Puppet::Indirector::Request.new(:metadata, :find, "puppetmounts://hostname/modules/mymod/my/file") end it "should return nil if the file is not found" do FileTest.expects(:exists?).with("/path/to/files/my/file").returns false - @finder.find("puppetmounts://hostname/modules/mymod/my/file").should be_nil + @finder.find(@request).should be_nil end it "should retrieve the instance's attributes if the file is found" do @@ -35,6 +37,6 @@ describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do instance = mock 'metadta' Puppet::FileServing::Metadata.expects(:new).returns instance instance.expects :collect_attributes - @finder.find("puppetmounts://hostname/modules/mymod/my/file") + @finder.find(@request) end end diff --git a/spec/unit/indirector/file_server.rb b/spec/unit/indirector/file_server.rb index 79be8cc29..ba951737a 100755 --- a/spec/unit/indirector/file_server.rb +++ b/spec/unit/indirector/file_server.rb @@ -27,34 +27,37 @@ describe Puppet::Indirector::FileServer do @uri = "puppetmounts://host/my/local/file" @configuration = mock 'configuration' Puppet::FileServing::Configuration.stubs(:create).returns(@configuration) + + @request = Puppet::Indirector::Request.new(:myind, :mymethod, @uri) end describe Puppet::Indirector::FileServer, " when finding files" do it "should use the path portion of the URI as the file name" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.find(@uri) + @file_server.find(@request) end it "should use the FileServing configuration to convert the file name to a fully qualified path" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.find(@uri) + @file_server.find(@request) end it "should pass the node name to the FileServing configuration if one is provided" do @configuration.expects(:file_path).with("/my/local/file", :node => "testing") - @file_server.find(@uri, :node => "testing") + @request.node = "testing" + @file_server.find(@request) end it "should return nil if no fully qualified path is found" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil) - @file_server.find(@uri).should be_nil + @file_server.find(@request).should be_nil end it "should return an instance of the model created with the full path if a file is found" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file") @model.expects(:new).returns(:myinstance) - @file_server.find(@uri).should == :myinstance + @file_server.find(@request).should == :myinstance end end @@ -66,23 +69,24 @@ describe Puppet::Indirector::FileServer do it "should create the instance with the key used to find the instance" do @model.expects(:new).with { |key, *options| key == @uri } - @file_server.find(@uri) + @file_server.find(@request) end it "should create the instance with the path at which the instance was found" do @model.expects(:new).with { |key, options| options[:path] == "/some/file" } - @file_server.find(@uri) + @file_server.find(@request) end it "should set the provided :links setting on to the instance if one is provided" do @model.expects(:new).returns(@instance) @instance.expects(:links=).with(:mytest) - @file_server.find(@uri, :links => :mytest) + @request.options[:links] = :mytest + @file_server.find(@request) end it "should not set a :links value if no :links parameter is provided" do @model.expects(:new).returns(@instance) - @file_server.find(@uri) + @file_server.find(@request) end end @@ -93,41 +97,52 @@ describe Puppet::Indirector::FileServer do end it "should deny the :destroy method" do - @file_server.authorized?(:destroy, "whatever").should be_false + @request.method = :destroy + @file_server.authorized?(@request).should be_false end it "should deny the :save method" do - @file_server.authorized?(:save, "whatever").should be_false - end + @request.method = :save + @file_server.authorized?(@request).should be_false + end + + describe "and finding file information" do + before do + @request.key = "puppetmounts://host/my/file" + @request.method = :find + end - it "should use the file server configuration to determine authorization" do - @configuration.expects(:authorized?) - @file_server.authorized?(:find, "puppetmounts://host/my/file") - end + it "should use the file server configuration to determine authorization" do + @configuration.expects(:authorized?) + @file_server.authorized?(@request) + end - it "should pass the file path from the URI to the file server configuration" do - @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" } - @file_server.authorized?(:find, "puppetmounts://host/my/file") - end + it "should pass the file path from the URI to the file server configuration" do + @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" } + @file_server.authorized?(@request) + end - it "should pass the node name to the file server configuration" do - @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" } - @file_server.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode") - end + it "should pass the node name to the file server configuration" do + @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" } + @request.node = "mynode" + @file_server.authorized?(@request) + end - it "should pass the IP address to the file server configuration" do - @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" } - @file_server.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip") - end + it "should pass the IP address to the file server configuration" do + @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" } + @request.ip = "myip" + @file_server.authorized?(@request) + end - it "should return false if the file server configuration denies authorization" do - @configuration.expects(:authorized?).returns(false) - @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_false - end + it "should return false if the file server configuration denies authorization" do + @configuration.expects(:authorized?).returns(false) + @file_server.authorized?(@request) + end - it "should return true if the file server configuration approves authorization" do - @configuration.expects(:authorized?).returns(true) - @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_true + it "should return true if the file server configuration approves authorization" do + @configuration.expects(:authorized?).returns(true) + @file_server.authorized?(@request) + end end end @@ -135,34 +150,35 @@ describe Puppet::Indirector::FileServer do it "should use the path portion of the URI as the file name" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.search(@uri) + @file_server.search(@request) end it "should use the FileServing configuration to convert the file name to a fully qualified path" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.search(@uri) + @file_server.search(@request) end it "should pass the node name to the FileServing configuration if one is provided" do @configuration.expects(:file_path).with("/my/local/file", :node => "testing") - @file_server.search(@uri, :node => "testing") + @request.node = "testing" + @file_server.search(@request) end it "should return nil if no fully qualified path is found" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil) - @file_server.search(@uri).should be_nil + @file_server.search(@request).should be_nil end it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file") - @file_server.expects(:path2instances).with(@uri, "/my/file", {}) - @file_server.search(@uri) + @file_server.expects(:path2instances) + @file_server.search(@request) end - it "should pass any options on to :path2instances" do + it "should pass the request on to :path2instances" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file") - @file_server.expects(:path2instances).with(@uri, "/my/file", :testing => :one, :other => :two) - @file_server.search(@uri, :testing => :one, :other => :two) + @file_server.expects(:path2instances).with(@request, "/my/file") + @file_server.search(@request) end end end diff --git a/spec/unit/indirector/module_files.rb b/spec/unit/indirector/module_files.rb index f5b92e1fd..32dedd4f1 100755 --- a/spec/unit/indirector/module_files.rb +++ b/spec/unit/indirector/module_files.rb @@ -27,61 +27,66 @@ describe Puppet::Indirector::ModuleFiles do @uri = "puppetmounts://host/modules/my/local/file" @module = Puppet::Module.new("mymod", "/module/path") + + @request = stub 'request', :key => @uri, :options => {}, :node => nil, :ip => nil, :method => :find end describe Puppet::Indirector::ModuleFiles, " when finding files" do it "should strip off the leading '/modules' mount name" do Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.find(@uri) + @module_files.find(@request) end it "should not strip off leading terms that start with '/modules' but are longer words" do + @request.stubs(:key).returns "puppetmounts://host/modulestart/my/local/file" Puppet::Module.expects(:find).with('modulestart', "myenv").returns nil - @module_files.find("puppetmounts://host/modulestart/my/local/file") + @module_files.find(@request) end it "should search for a module whose name is the first term in the remaining file path" do Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.find(@uri) + @module_files.find(@request) end it "should search for a file relative to the module's files directory" do Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file") - @module_files.find(@uri) + @module_files.find(@request) end it "should return nil if the module does not exist" do Puppet::Module.expects(:find).with('my', "myenv").returns nil - @module_files.find(@uri).should be_nil + @module_files.find(@request).should be_nil end it "should return nil if the module exists but the file does not" do Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(false) - @module_files.find(@uri).should be_nil + @module_files.find(@request).should be_nil end it "should return an instance of the model if a module is found and the file exists" do Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) @model.expects(:new).returns(:myinstance) - @module_files.find(@uri).should == :myinstance + @module_files.find(@request).should == :myinstance end it "should use the node's environment to look up the module if the node name is provided" do node = stub "node", :environment => "testing" Puppet::Node.expects(:find).with("mynode").returns(node) Puppet::Module.expects(:find).with('my', "testing") - @module_files.find(@uri, :node => "mynode") + + @request.stubs(:node).returns "mynode" + @module_files.find(@request) end it "should use the default environment setting to look up the module if the node name is not provided" do env = stub "environment", :name => "testing" Puppet::Node::Environment.stubs(:new).returns(env) Puppet::Module.expects(:find).with('my', "testing") - @module_files.find(@uri) + @module_files.find(@request) end end @@ -95,23 +100,25 @@ describe Puppet::Indirector::ModuleFiles do it "should create the instance with the key used to find the instance" do @model.expects(:new).with { |key, *options| key == @uri } - @module_files.find(@uri) + @module_files.find(@request) end it "should create the instance with the path at which the instance was found" do @model.expects(:new).with { |key, options| options[:path] == "/module/path/files/local/file" } - @module_files.find(@uri) + @module_files.find(@request) end it "should set the provided :links setting on to the instance if one is provided" do @model.expects(:new).returns(@instance) @instance.expects(:links=).with(:mytest) - @module_files.find(@uri, :links => :mytest) + + @request.options[:links] = :mytest + @module_files.find(@request) end it "should not set a :links value if no :links parameter is provided" do @model.expects(:new).returns(@instance) - @module_files.find(@uri) + @module_files.find(@request) end end @@ -127,46 +134,53 @@ describe Puppet::Indirector::ModuleFiles do end it "should deny the :destroy method" do - @module_files.authorized?(:destroy, "whatever").should be_false + @request.expects(:method).returns :destroy + @module_files.authorized?(@request).should be_false end it "should deny the :save method" do - @module_files.authorized?(:save, "whatever").should be_false + @request.expects(:method).returns :save + @module_files.authorized?(@request).should be_false end it "should use the file server configuration to determine authorization" do @configuration.expects(:authorized?) - @module_files.authorized?(:find, "puppetmounts://host/my/file") + @module_files.authorized?(@request) end it "should use the path directly from the URI if it already includes /modules" do + @request.expects(:key).returns "puppetmounts://host/modules/my/file" @configuration.expects(:authorized?).with { |uri, *args| uri == "/modules/my/file" } - @module_files.authorized?(:find, "puppetmounts://host/modules/my/file") + @module_files.authorized?(@request) end it "should add /modules to the file path if it's not included in the URI" do + @request.expects(:key).returns "puppetmounts://host/my/file" @configuration.expects(:authorized?).with { |uri, *args| uri == "/modules/my/file" } - @module_files.authorized?(:find, "puppetmounts://host/my/file") + @module_files.authorized?(@request) end it "should pass the node name to the file server configuration" do + @request.expects(:key).returns "puppetmounts://host/my/file" @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" } - @module_files.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode") + @request.stubs(:node).returns "mynode" + @module_files.authorized?(@request) end it "should pass the IP address to the file server configuration" do + @request.expects(:ip).returns "myip" @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" } - @module_files.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip") + @module_files.authorized?(@request) end it "should return false if the file server configuration denies authorization" do @configuration.expects(:authorized?).returns(false) - @module_files.authorized?(:find, "puppetmounts://host/my/file").should be_false + @module_files.authorized?(@request).should be_false end it "should return true if the file server configuration approves authorization" do @configuration.expects(:authorized?).returns(true) - @module_files.authorized?(:find, "puppetmounts://host/my/file").should be_true + @module_files.authorized?(@request).should be_true end end @@ -175,69 +189,71 @@ describe Puppet::Indirector::ModuleFiles do it "should strip off the leading '/modules' mount name" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.search(@uri) + @module_files.search(@request) end it "should not strip off leading terms that start with '/modules' but are longer words" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('modulestart', "myenv").returns nil - @module_files.search("puppetmounts://host/modulestart/my/local/file") + @request.stubs(:key).returns "puppetmounts://host/modulestart/my/local/file" + @module_files.search @request end it "should search for a module whose name is the first term in the remaining file path" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.search(@uri) + @module_files.search(@request) end it "should search for a file relative to the module's files directory" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file") - @module_files.search(@uri) + @module_files.search(@request) end it "should return nil if the module does not exist" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns nil - @module_files.search(@uri).should be_nil + @module_files.search(@request).should be_nil end it "should return nil if the module exists but the file does not" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(false) - @module_files.search(@uri).should be_nil + @module_files.search(@request).should be_nil end it "should use the node's environment to look up the module if the node name is provided" do node = stub "node", :environment => "testing" Puppet::Node.expects(:find).with("mynode").returns(node) Puppet::Module.expects(:find).with('my', "testing") - @module_files.search(@uri, :node => "mynode") + @request.stubs(:node).returns "mynode" + @module_files.search(@request) end it "should use the default environment setting to look up the module if the node name is not provided and the environment is not set to ''" do env = stub 'env', :name => "testing" Puppet::Node::Environment.stubs(:new).returns(env) Puppet::Module.expects(:find).with('my', "testing") - @module_files.search(@uri) + @module_files.search(@request) end it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", {}) - @module_files.search(@uri) + @module_files.expects(:path2instances).with(@request, "/module/path/files/local/file") + @module_files.search(@request) end - it "should pass any options on to :path2instances" do + it "should pass the request directly to :path2instances" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", :testing => :one, :other => :two) - @module_files.search(@uri, :testing => :one, :other => :two) + @module_files.expects(:path2instances).with(@request, "/module/path/files/local/file") + @module_files.search(@request) end end end diff --git a/spec/unit/indirector/node/exec.rb b/spec/unit/indirector/node/exec.rb index 2276e4298..09f13ab90 100755 --- a/spec/unit/indirector/node/exec.rb +++ b/spec/unit/indirector/node/exec.rb @@ -49,12 +49,6 @@ describe Puppet::Node::Exec do @searcher.find(@request) end - it "should convert all parameters into strings" do - @result[:parameters] = {"a" => true, "c" => 100} - @node.expects(:parameters=).with "a" => "true", "c" => "100" - @searcher.find(@request) - end - it "should set the resulting classes as the node classes" do @result[:classes] = %w{one two} @node.expects(:classes=).with %w{one two} diff --git a/spec/unit/module.rb b/spec/unit/module.rb index 2dadaa501..e79001ae1 100755 --- a/spec/unit/module.rb +++ b/spec/unit/module.rb @@ -143,8 +143,8 @@ describe Puppet::Module, " when searching for manifests when no module is found" it "should look for files relative to the current directory" do cwd = Dir.getwd - Dir.expects(:glob).with("#{cwd}/mymod/init.pp").returns(["#{cwd}/mymod/init.pp"]) - Puppet::Module.find_manifests("mymod/init.pp").should == ["#{cwd}/mymod/init.pp"] + Dir.expects(:glob).with("#{cwd}/foobar/init.pp").returns(["#{cwd}/foobar/init.pp"]) + Puppet::Module.find_manifests("foobar/init.pp").should == ["#{cwd}/foobar/init.pp"] end it "should only return files, not directories" do diff --git a/spec/unit/network/client/master.rb b/spec/unit/network/client/master.rb index 79ab8c86f..754fd0583 100755 --- a/spec/unit/network/client/master.rb +++ b/spec/unit/network/client/master.rb @@ -59,34 +59,92 @@ describe Puppet::Network::Client::Master, " when retrieving the catalog" do @client.getconfig end - it "should load the retrieved catalog using YAML" do - @client.stubs(:dostorage) - @client.class.stubs(:facts).returns(@facts) - @master.stubs(:getconfig).returns("myconfig") + describe "when the catalog format is set to yaml" do + before do + Puppet.settings.stubs(:value).returns "foo" + Puppet.settings.stubs(:value).with(:pluginsync).returns false + Puppet.settings.stubs(:value).with(:configtimeout).returns 10 + Puppet.settings.stubs(:value).with(:factsync).returns false + Puppet.settings.stubs(:value).with(:catalog_format).returns "yaml" + end - config = mock 'config' - YAML.expects(:load).with("myconfig").returns(config) + it "should request a yaml-encoded catalog" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.expects(:getconfig).with { |*args| args[1] == "yaml" } - @client.stubs(:setclasses) + @client.getconfig + end - config.stubs(:classes) - config.stubs(:to_catalog).returns(config) - config.stubs(:host_config=) - config.stubs(:from_cache).returns(true) + it "should load the retrieved catalog using YAML" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") - @client.getconfig + config = mock 'config' + YAML.expects(:load).with("myconfig").returns(config) + + @client.stubs(:setclasses) + + config.stubs(:classes) + config.stubs(:to_catalog).returns(config) + config.stubs(:host_config=) + config.stubs(:from_cache).returns(true) + + @client.getconfig + end + + it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") + + YAML.expects(:load).with("myconfig").raises(ArgumentError) + + @client.expects(:use_cached_config).with(true) + + @client.getconfig + end end - it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do - @client.stubs(:dostorage) - @client.class.stubs(:facts).returns(@facts) - @master.stubs(:getconfig).returns("myconfig") + describe "from Marshal" do + before do + Puppet.settings.stubs(:value).returns "foo" + Puppet.settings.stubs(:value).with(:pluginsync).returns false + Puppet.settings.stubs(:value).with(:configtimeout).returns 10 + Puppet.settings.stubs(:value).with(:factsync).returns false + Puppet.settings.stubs(:value).with(:catalog_format).returns "marshal" + end - YAML.expects(:load).with("myconfig").raises(ArgumentError) + it "should load the retrieved catalog using Marshal" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") - @client.expects(:use_cached_config).with(true) + config = mock 'config' + Marshal.expects(:load).with("myconfig").returns(config) - @client.getconfig + @client.stubs(:setclasses) + + config.stubs(:classes) + config.stubs(:to_catalog).returns(config) + config.stubs(:host_config=) + config.stubs(:from_cache).returns(true) + + @client.getconfig + end + + it "should use the cached catalog if the retrieved catalog cannot be converted from Marshal" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") + + Marshal.expects(:load).with("myconfig").raises(ArgumentError) + + @client.expects(:use_cached_config).with(true) + + @client.getconfig + end end it "should set the classes.txt file with the classes listed in the retrieved catalog" do diff --git a/spec/unit/network/http.rb b/spec/unit/network/http.rb index 79a0a88d4..1fa025b0b 100755 --- a/spec/unit/network/http.rb +++ b/spec/unit/network/http.rb @@ -12,9 +12,15 @@ describe Puppet::Network::HTTP do Puppet::Network::HTTP.server_class_by_type(:webrick).should be(Puppet::Network::HTTP::WEBrick) end - if Puppet.features.mongrel? - it "should return the mongrel HTTP server class when asked for a mongrel server" do - Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel) + describe "when asked for a mongrel server" do + if Puppet.features.mongrel? + it "should return the mongrel server class" do + Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel) + end + else + it "should fail" do + lambda { Puppet::Network::HTTP.server_class_by_type(:mongrel) }.should raise_error(ArgumentError) + end end end diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb index 1f87fd943..9c708067a 100755 --- a/spec/unit/network/http/mongrel.rb +++ b/spec/unit/network/http/mongrel.rb @@ -6,18 +6,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/network/http' -describe Puppet::Network::HTTP::Mongrel, "after initializing" do +describe "Puppet::Network::HTTP::Mongrel", "after initializing" do confine "Mongrel is not available" => Puppet.features.mongrel? it "should not be listening" do + require 'puppet/network/http/mongrel' + Puppet::Network::HTTP::Mongrel.new.should_not be_listening end end -describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do +describe "Puppet::Network::HTTP::Mongrel", "when turning on listening" do confine "Mongrel is not available" => Puppet.features.mongrel? before do + require 'puppet/network/http/mongrel' + @server = Puppet::Network::HTTP::Mongrel.new @mock_mongrel = mock('mongrel') @mock_mongrel.stubs(:run) @@ -109,7 +113,7 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do end end -describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do +describe "Puppet::Network::HTTP::Mongrel", "when turning off listening" do confine "Mongrel is not available" => Puppet.features.mongrel? before do diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb index 3df925133..de5254a7a 100755 --- a/spec/unit/network/http/mongrel/rest.rb +++ b/spec/unit/network/http/mongrel/rest.rb @@ -3,10 +3,12 @@ require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/network/http' -describe Puppet::Network::HTTP::MongrelREST, "when initializing" do +describe "Puppet::Network::HTTP::MongrelREST", "when initializing" do confine "Mongrel is not available" => Puppet.features.mongrel? before do + require 'puppet/network/http/mongrel/rest' + @mock_mongrel = mock('Mongrel server') @mock_mongrel.stubs(:register) @mock_model = mock('indirected model') @@ -33,7 +35,7 @@ describe Puppet::Network::HTTP::MongrelREST, "when initializing" do end end -describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do +describe "Puppet::Network::HTTP::MongrelREST", "when receiving a request" do confine "Mongrel is not available" => Puppet.features.mongrel? before do @@ -131,6 +133,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "and determining the request parameters", :shared => true do + confine "Mongrel is not available" => Puppet.features.mongrel? + before do @mock_request.stubs(:params).returns({}) end @@ -198,6 +202,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when finding a model instance" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should fail to find model if key is not specified" do @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'GET', Mongrel::Const::REQUEST_PATH => '/foo'}) @mock_response.expects(:start).with(404) @@ -236,6 +242,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when destroying a model instance" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should fail to destroy model if key is not specified" do @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'DELETE', Mongrel::Const::REQUEST_PATH => '/foo'}) @mock_response.expects(:start).with(404) @@ -281,6 +289,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when saving a model instance" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should fail to save model if data is not specified" do @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'PUT', Mongrel::Const::REQUEST_PATH => '/foo'}) @mock_request.stubs(:body).returns('') @@ -319,6 +329,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when searching for model instances" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should use a common method for determining the request parameters" do setup_search_request('QUERY_STRING' => 'foo=baz&bar=xyzzy') @handler.expects(:params).returns(:foo => :baz, :bar => :xyzzy) diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb index e3c3b81c0..7e5084bbc 100755 --- a/spec/unit/network/http/webrick.rb +++ b/spec/unit/network/http/webrick.rb @@ -5,6 +5,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/network/http' +require 'puppet/network/http/webrick' describe Puppet::Network::HTTP::WEBrick, "after initializing" do it "should not be listening" do diff --git a/spec/unit/network/http/webrick/rest.rb b/spec/unit/network/http/webrick/rest.rb index 45e5f0bd2..17d47e54c 100755 --- a/spec/unit/network/http/webrick/rest.rb +++ b/spec/unit/network/http/webrick/rest.rb @@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/network/http' +require 'puppet/network/http/webrick/rest' describe Puppet::Network::HTTP::WEBrickREST, "when initializing" do before do diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb index c35ddc513..16efc5b58 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed.rb @@ -71,4 +71,25 @@ describe provider_class do genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n" end + + it "should prefetch ~user/.ssh/authorized_keys when user is given" do + key = Puppet::Type.type(:ssh_authorized_key).create( + :name => "Test", + :key => "AA", + :type => "rsa", + :ensure => :present, + :user => "root") + prov = @provider.new key + + prov.prefetch + prov.target.should == File.expand_path("~root/.ssh/authorized_keys") + end + + it "should create destination dir" do + # No idea how to test the flush method + end + + it "should set correct default permissions" do + # No idea how to test the flush method + end end diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb index 4a4667543..533236772 100755 --- a/spec/unit/rails.rb +++ b/spec/unit/rails.rb @@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../spec_helper' require 'puppet/rails' describe Puppet::Rails, "when initializing any connection" do - confine Puppet.features.rails? => "Cannot test without ActiveRecord" + confine "Cannot test without ActiveRecord" => Puppet.features.rails? before do @logger = stub 'logger', :level= => nil diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index 128e14a01..7f9688f0b 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -64,6 +64,11 @@ describe Puppet::Type.type(:file) do @file.property(:source).retrieve lambda { @file.property(:source).sync }.should raise_error(Puppet::Error) end + + it "should fail if it cannot describe remote contents" do + @filesource.server.stubs(:describe).raises(Puppet::Network::XMLRPCClientError.new("Testing")) + lambda { @file.retrieve }.should raise_error(Puppet::Error) + end end describe "when managing links" do diff --git a/spec/unit/type/group.rb b/spec/unit/type/group.rb new file mode 100755 index 000000000..d7e06dcd8 --- /dev/null +++ b/spec/unit/type/group.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +describe Puppet::Type.type(:group) do + before do + @class = Puppet::Type.type(:group) + end + + after do + @class.clear + end + + it "should have a default provider" do + @class.defaultprovider.should_not be_nil + end + + it "should have a default provider inheriting from Puppet::Provider" do + @class.defaultprovider.ancestors.should be_include(Puppet::Provider) + end + + describe "when validating attributes" do + [:name, :allowdupe].each do |param| + it "should have a #{param} parameter" do + @class.attrtype(param).should == :param + end + end + + [:ensure, :gid].each do |param| + it "should have a #{param} property" do + @class.attrtype(param).should == :property + end + end + end + + # #1407 - we need to declare the allowdupe param as boolean. + it "should have a boolean method for determining if duplicates are allowed" do + @class.create(:name => "foo").methods.should be_include("allowdupe?") + end +end diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb index bb38fafce..1860f2714 100755 --- a/spec/unit/type/ssh_authorized_key.rb +++ b/spec/unit/type/ssh_authorized_key.rb @@ -77,47 +77,6 @@ describe ssh_authorized_key do @class.attrtype(:target).should == :property end - it "should autorequire parent directories when user is given" do - @catalog.add_resource @class.create( - :name => "Test", - :key => "AAA", - :type => "ssh-rsa", - :ensure => :present, - :user => "root") - @catalog.apply - - target = File.expand_path("~root/.ssh") - @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file)) - end - - it "should set target when user is given" do - @catalog.add_resource @class.create( - :name => "Test", - :key => "AAA", - :type => "ssh-rsa", - :ensure => :present, - :user => "root") - @catalog.apply - - target = File.expand_path("~root/.ssh/authorized_keys") - @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file)) - end - - - it "should autorequire parent directories when target is given" do - target = "/tmp/home/foo/bar/.ssh/authorized_keys" - - @catalog.add_resource @class.create( - :name => "Test", - :key => "AAA", - :type => "ssh-rsa", - :ensure => :present, - :target => target) - @catalog.apply - - @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file)) - end - it "should raise an error when neither user nor target is given" do proc do @class.create( |
