diff options
| author | Josh Cooper <josh@puppetlabs.com> | 2011-07-26 14:57:33 -0700 |
|---|---|---|
| committer | Josh Cooper <josh@puppetlabs.com> | 2011-07-26 14:57:33 -0700 |
| commit | 770e30d620271f988321ea45c108fb167ab55ad7 (patch) | |
| tree | 48a4bcd382919164b3938e9a20de97cf6ab89a2b | |
| parent | b13427b56d8529731d0334d420b24a592ecb43ea (diff) | |
| parent | 9279d0954eb20d75e18a666fd572b5492e157608 (diff) | |
| download | puppet-770e30d620271f988321ea45c108fb167ab55ad7.tar.gz puppet-770e30d620271f988321ea45c108fb167ab55ad7.tar.xz puppet-770e30d620271f988321ea45c108fb167ab55ad7.zip | |
Merge branch 'feature/master/8268-puppet-agent-windows'
* feature/master/8268-puppet-agent-windows:
Fix issue with forward and backslashes in Windows paths
Disable spec tests for unsupported functionality on Windows
Update certificate spec tests for Windows
22 files changed, 81 insertions, 75 deletions
diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index f25bb65a9..4fc314a6a 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -131,9 +131,12 @@ class Puppet::Node::Environment def validate_dirs(dirs) dir_regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ : /^#{File::SEPARATOR}/ + # REMIND: Dir.getwd on windows returns a path containing backslashes, which when joined with + # dir containing forward slashes, breaks our regex matching. In general, path validation needs + # to be refactored which will be handled in a future commit. dirs.collect do |dir| if dir !~ dir_regex - File.join(Dir.getwd, dir) + File.expand_path(File.join(Dir.getwd, dir)) else dir end diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb index 762ce25f0..a8996ee9a 100644 --- a/lib/puppet/util/rdoc/parser.rb +++ b/lib/puppet/util/rdoc/parser.rb @@ -113,7 +113,9 @@ class Parser Puppet::Module.modulepath.each do |mp| # check that fullpath is a descendant of mp dirname = fullpath - while (dirname = File.dirname(dirname)) != '/' + previous = dirname + while (dirname = File.dirname(previous)) != previous + previous = dirname return nil if File.identical?(dirname,mp) end end diff --git a/spec/integration/application/doc_spec.rb b/spec/integration/application/doc_spec.rb index 47fd93a03..2cf5fd1e9 100755 --- a/spec/integration/application/doc_spec.rb +++ b/spec/integration/application/doc_spec.rb @@ -5,7 +5,7 @@ require 'puppet_spec/files' describe Puppet::Application::Doc do include PuppetSpec::Files - it "should not generate an error when module dir overlaps parent of site.pp (#4798)", :'fails_on_ruby_1.9.2' => true, :fails_on_windows => true do + it "should not generate an error when module dir overlaps parent of site.pp (#4798)", :'fails_on_ruby_1.9.2' => true, :unless => Puppet.features.microsoft_windows? do begin # Note: the directory structure below is more complex than it # needs to be, but it's representative of the directory structure diff --git a/spec/integration/network/server/webrick_spec.rb b/spec/integration/network/server/webrick_spec.rb index 2390fcab1..7365462d3 100755 --- a/spec/integration/network/server/webrick_spec.rb +++ b/spec/integration/network/server/webrick_spec.rb @@ -4,7 +4,9 @@ require 'puppet/network/server' require 'puppet/ssl/certificate_authority' require 'socket' -describe Puppet::Network::Server do +describe Puppet::Network::Server, :unless => Puppet.features.microsoft_windows? do + include PuppetSpec::Files + describe "when using webrick" do before :each do Puppet[:servertype] = 'webrick' @@ -12,11 +14,10 @@ describe Puppet::Network::Server do @params = { :port => 34343, :handlers => [ :node ], :xmlrpc_handlers => [ :status ] } # Get a safe temporary file - @tmpfile = Tempfile.new("webrick_integration_testing") - @dir = @tmpfile.path + "_dir" + dir = tmpdir("webrick_integration_testing") - Puppet.settings[:confdir] = @dir - Puppet.settings[:vardir] = @dir + Puppet.settings[:confdir] = dir + Puppet.settings[:vardir] = dir Puppet.settings[:group] = Process.gid Puppet::SSL::Host.ca_location = :local @@ -26,11 +27,8 @@ describe Puppet::Network::Server do end after do - @tmpfile.delete Puppet.settings.clear - system("rm -rf #{@dir}") - Puppet::SSL::Host.ca_location = :none end diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb index 68b2401fb..dc8af6a7b 100755 --- a/spec/integration/ssl/certificate_authority_spec.rb +++ b/spec/integration/ssl/certificate_authority_spec.rb @@ -6,17 +6,16 @@ require 'spec_helper' require 'puppet/ssl/certificate_authority' -require 'tempfile' -describe Puppet::SSL::CertificateAuthority, :fails_on_windows => true do +describe Puppet::SSL::CertificateAuthority, :unless => Puppet.features.microsoft_windows? do + include PuppetSpec::Files + before do # Get a safe temporary file - file = Tempfile.new("ca_integration_testing") - @dir = file.path - file.delete + dir = tmpdir("ca_integration_testing") - Puppet.settings[:confdir] = @dir - Puppet.settings[:vardir] = @dir + Puppet.settings[:confdir] = dir + Puppet.settings[:vardir] = dir Puppet.settings[:group] = Process.gid Puppet::SSL::Host.ca_location = :local @@ -26,7 +25,6 @@ describe Puppet::SSL::CertificateAuthority, :fails_on_windows => true do after { Puppet::SSL::Host.ca_location = :none - system("rm -rf #{@dir}") Puppet.settings.clear Puppet::SSL::CertificateAuthority.instance_variable_set("@instance", nil) diff --git a/spec/integration/ssl/certificate_request_spec.rb b/spec/integration/ssl/certificate_request_spec.rb index 07a4d9269..6c1c8b964 100755 --- a/spec/integration/ssl/certificate_request_spec.rb +++ b/spec/integration/ssl/certificate_request_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' require 'puppet/ssl/certificate_request' -require 'tempfile' +# REMIND: Fails on windows because there is no user provider yet describe Puppet::SSL::CertificateRequest, :fails_on_windows => true do + include PuppetSpec::Files + before do # Get a safe temporary file - file = Tempfile.new("csr_integration_testing") - @dir = file.path - file.delete - - Dir.mkdir(@dir) + dir = tmpdir("csr_integration_testing") Puppet.settings.clear - Puppet.settings[:confdir] = @dir - Puppet.settings[:vardir] = @dir + Puppet.settings[:confdir] = dir + Puppet.settings[:vardir] = dir Puppet.settings[:group] = Process.gid Puppet::SSL::Host.ca_location = :none @@ -34,7 +32,6 @@ describe Puppet::SSL::CertificateRequest, :fails_on_windows => true do end after do - system("rm -rf #{@dir}") Puppet.settings.clear end diff --git a/spec/integration/ssl/certificate_revocation_list_spec.rb b/spec/integration/ssl/certificate_revocation_list_spec.rb index 5d2b102f5..d140fd950 100755 --- a/spec/integration/ssl/certificate_revocation_list_spec.rb +++ b/spec/integration/ssl/certificate_revocation_list_spec.rb @@ -6,17 +6,17 @@ require 'spec_helper' require 'puppet/ssl/certificate_revocation_list' -require 'tempfile' +# REMIND: Fails on windows because there is no user provider yet describe Puppet::SSL::CertificateRevocationList, :fails_on_windows => true do + include PuppetSpec::Files + before do # Get a safe temporary file - file = Tempfile.new("ca_integration_testing") - @dir = file.path - file.delete + dir = tmpdir("ca_integration_testing") - Puppet.settings[:confdir] = @dir - Puppet.settings[:vardir] = @dir + Puppet.settings[:confdir] = dir + Puppet.settings[:vardir] = dir Puppet.settings[:group] = Process.gid Puppet::SSL::Host.ca_location = :local @@ -25,7 +25,6 @@ describe Puppet::SSL::CertificateRevocationList, :fails_on_windows => true do after { Puppet::SSL::Host.ca_location = :none - system("rm -rf #{@dir}") Puppet.settings.clear # This is necessary so the terminus instances don't lie around. diff --git a/spec/integration/ssl/host_spec.rb b/spec/integration/ssl/host_spec.rb index 53ff88ea4..94e245554 100755 --- a/spec/integration/ssl/host_spec.rb +++ b/spec/integration/ssl/host_spec.rb @@ -6,17 +6,17 @@ require 'spec_helper' require 'puppet/ssl/host' -require 'tempfile' +# REMIND: Fails on windows because there is no user provider yet describe Puppet::SSL::Host, :fails_on_windows => true do + include PuppetSpec::Files + before do # Get a safe temporary file - file = Tempfile.new("host_integration_testing") - @dir = file.path - file.delete + dir = tmpdir("host_integration_testing") - Puppet.settings[:confdir] = @dir - Puppet.settings[:vardir] = @dir + Puppet.settings[:confdir] = dir + Puppet.settings[:vardir] = dir Puppet.settings[:group] = Process.gid Puppet::SSL::Host.ca_location = :local @@ -28,7 +28,6 @@ describe Puppet::SSL::Host, :fails_on_windows => true do after { Puppet::SSL::Host.ca_location = :none - system("rm -rf #{@dir}") Puppet.settings.clear } @@ -80,7 +79,7 @@ describe Puppet::SSL::Host, :fails_on_windows => true do end end - it "should pass the verification of its own SSL store" do + it "should pass the verification of its own SSL store", :unless => Puppet.features.microsoft_windows? do @host.generate @ca = Puppet::SSL::CertificateAuthority.new @ca.sign(@host.name) diff --git a/spec/integration/type/tidy_spec.rb b/spec/integration/type/tidy_spec.rb index 08a24099c..d1bb62d6e 100755 --- a/spec/integration/type/tidy_spec.rb +++ b/spec/integration/type/tidy_spec.rb @@ -12,7 +12,7 @@ describe Puppet::Type.type(:tidy) do end # Testing #355. - it "should be able to remove dead links", :fails_on_windows => true do + it "should be able to remove dead links", :unless => Puppet.features.microsoft_windows? do dir = tmpfile("tidy_link_testing") link = File.join(dir, "link") target = tmpfile("no_such_file_tidy_link_testing") diff --git a/spec/integration/util/autoload_spec.rb b/spec/integration/util/autoload_spec.rb index 771e6a718..92fc6554c 100755 --- a/spec/integration/util/autoload_spec.rb +++ b/spec/integration/util/autoload_spec.rb @@ -94,7 +94,7 @@ describe Puppet::Util::Autoload do } end - it "should be able to load files directly from modules", :fails_on_windows => true do + it "should be able to load files directly from modules" do modulepath = tmpfile("autoload_module_testing") libdir = File.join(modulepath, "mymod", "lib", "foo") FileUtils.mkdir_p(libdir) diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb index be5887f01..750f25ab8 100755 --- a/spec/unit/application/inspect_spec.rb +++ b/spec/unit/application/inspect_spec.rb @@ -148,7 +148,7 @@ describe Puppet::Application::Inspect do @inspect.run_command end - it "should not send unreadable files", :fails_on_windows => true do + it "should not send unreadable files", :unless => Puppet.features.microsoft_windows? do File.open(@file, 'w') { |f| f.write('stuff') } File.chmod(0, @file) Puppet::FileBucketFile::Rest.any_instance.expects(:head).never diff --git a/spec/unit/face/ca_spec.rb b/spec/unit/face/ca_spec.rb index b8c82ce99..1df4d7c53 100755 --- a/spec/unit/face/ca_spec.rb +++ b/spec/unit/face/ca_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'puppet/face' -describe Puppet::Face[:ca, '0.1.0'] do +describe Puppet::Face[:ca, '0.1.0'], :unless => Puppet.features.microsoft_windows? do include PuppetSpec::Files before :each do diff --git a/spec/unit/indirector/certificate_request/ca_spec.rb b/spec/unit/indirector/certificate_request/ca_spec.rb index fb758b59e..36628df9d 100755 --- a/spec/unit/indirector/certificate_request/ca_spec.rb +++ b/spec/unit/indirector/certificate_request/ca_spec.rb @@ -10,7 +10,7 @@ require 'puppet/sslcertificates' require 'puppet/sslcertificates/ca' require 'puppet/indirector/certificate_request/ca' -describe Puppet::SSL::CertificateRequest::Ca, :fails_on_windows => true do +describe Puppet::SSL::CertificateRequest::Ca, :unless => Puppet.features.microsoft_windows? do include PuppetSpec::Files before :each do diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb index 08852634d..93f124882 100755 --- a/spec/unit/network/handler/fileserver_spec.rb +++ b/spec/unit/network/handler/fileserver_spec.rb @@ -41,12 +41,12 @@ describe Puppet::Network::Handler::FileServer do @mount.list("/no_such_file", false, false).should be(nil) end - it "should list a symbolic link as a file when given the link path" do + it "should list a symbolic link as a file when given the link path", :unless => Puppet.features.microsoft_windows? do File.symlink(@file, @link) @mount.list("/aLink", false, false).should == [["/", "file"]] end - it "should return nil for a dangling symbolic link when given the link path" do + it "should return nil for a dangling symbolic link when given the link path", :unless => Puppet.features.microsoft_windows? do File.symlink("/some/where", @link) @mount.list("/aLink", false, false).should be(nil) end @@ -106,18 +106,18 @@ describe Puppet::Network::Handler::FileServer do list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort end - it "should list a valid symbolic link as a file when recursing base dir" do + it "should list a valid symbolic link as a file when recursing base dir", :unless => Puppet.features.microsoft_windows? do File.symlink(@file, @link) list = @mount.list("/", true, false) list.sort.should == [ ["/", "directory"], ["/aFile", "file"], ["/aLink", "file"] ].sort end - it "should not error when a dangling symlink is present" do + it "should not error when a dangling symlink is present", :unless => Puppet.features.microsoft_windows? do File.symlink("/some/where", @link) lambda { @mount.list("/", true, false) }.should_not raise_error end - it "should return the directory contents of valid entries when a dangling symlink is present" do + it "should return the directory contents of valid entries when a dangling symlink is present", :unless => Puppet.features.microsoft_windows? do File.symlink("/some/where", @link) list = @mount.list("/", true, false) list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ].sort diff --git a/spec/unit/network/http/webrick_spec.rb b/spec/unit/network/http/webrick_spec.rb index be74a1052..8504b02e3 100755 --- a/spec/unit/network/http/webrick_spec.rb +++ b/spec/unit/network/http/webrick_spec.rb @@ -8,13 +8,13 @@ require 'puppet/network/handler' require 'puppet/network/http' require 'puppet/network/http/webrick' -describe Puppet::Network::HTTP::WEBrick, "after initializing" do +describe Puppet::Network::HTTP::WEBrick, "after initializing", :unless => Puppet.features.microsoft_windows? do it "should not be listening" do Puppet::Network::HTTP::WEBrick.new.should_not be_listening end end -describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do +describe Puppet::Network::HTTP::WEBrick, "when turning on listening", :unless => Puppet.features.microsoft_windows? do before do @mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running) [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)} @@ -143,7 +143,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do end -describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a protocol" do +describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a protocol", :unless => Puppet.features.microsoft_windows? do it "should require a protocol" do lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol }.should raise_error(ArgumentError) end @@ -161,7 +161,7 @@ describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a end end -describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do +describe Puppet::Network::HTTP::WEBrick, "when turning off listening", :unless => Puppet.features.microsoft_windows? do before do @mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running) [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)} @@ -188,7 +188,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do end end -describe Puppet::Network::HTTP::WEBrick do +describe Puppet::Network::HTTP::WEBrick, :unless => Puppet.features.microsoft_windows? do before do @mock_webrick = stub('webrick', :[] => {}) [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)} diff --git a/spec/unit/node/environment_spec.rb b/spec/unit/node/environment_spec.rb index eb20aa7ef..78d383440 100755 --- a/spec/unit/node/environment_spec.rb +++ b/spec/unit/node/environment_spec.rb @@ -144,7 +144,7 @@ describe Puppet::Node::Environment do FileTest.stubs(:directory?).returns true env = Puppet::Node::Environment.new("testing") - two = File.join(Dir.getwd, "two") + two = File.expand_path(File.join(Dir.getwd, "two")) env.validate_dirs([@path_one, 'two']).should == [@path_one, two] end end diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb index ce783e393..f5f779fbf 100755 --- a/spec/unit/resource/catalog_spec.rb +++ b/spec/unit/resource/catalog_spec.rb @@ -598,11 +598,12 @@ describe Puppet::Resource::Catalog, "when compiling" do end it "should conflict when its uniqueness key matches another resource's title" do - @resource = Puppet::Type.type(:file).new(:title => "/tmp/foo") - @other = Puppet::Type.type(:file).new(:title => "another file", :path => "/tmp/foo") + path = make_absolute("/tmp/foo") + @resource = Puppet::Type.type(:file).new(:title => path) + @other = Puppet::Type.type(:file).new(:title => "another file", :path => path) @catalog.add_resource(@resource) - expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias File\[another file\] to \["\/tmp\/foo"\].*resource \["File", "\/tmp\/foo"\] already defined/) + expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias File\[another file\] to \["#{Regexp.escape(path)}"\].*resource \["File", "#{Regexp.escape(path)}"\] already defined/) end it "should conflict when its uniqueness key matches the uniqueness key derived from another resource's title" do diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb index f00451619..226acdecd 100755 --- a/spec/unit/ssl/host_spec.rb +++ b/spec/unit/ssl/host_spec.rb @@ -5,9 +5,18 @@ require 'puppet/ssl/host' require 'puppet/sslcertificates' require 'puppet/sslcertificates/ca' +# REMIND: Fails on windows because there is no user provider yet describe Puppet::SSL::Host, :fails_on_windows => true do + include PuppetSpec::Files + before do Puppet::SSL::Host.indirection.terminus_class = :file + + # Get a safe temporary file + dir = tmpdir("ssl_host_testing") + Puppet.settings[:confdir] = dir + Puppet.settings[:vardir] = dir + @host = Puppet::SSL::Host.new("myname") end @@ -701,7 +710,7 @@ describe Puppet::SSL::Host, :fails_on_windows => true do end end - describe "when handling PSON" do + describe "when handling PSON", :unless => Puppet.features.microsoft_windows? do include PuppetSpec::Files before do diff --git a/spec/unit/ssl/inventory_spec.rb b/spec/unit/ssl/inventory_spec.rb index 3d141d0cd..000f0a253 100755 --- a/spec/unit/ssl/inventory_spec.rb +++ b/spec/unit/ssl/inventory_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'puppet/ssl/inventory' -describe Puppet::SSL::Inventory do +describe Puppet::SSL::Inventory, :unless => Puppet.features.microsoft_windows? do before do @class = Puppet::SSL::Inventory end diff --git a/spec/unit/sslcertificates/ca_spec.rb b/spec/unit/sslcertificates/ca_spec.rb index 2ff4036dd..7a687b825 100755 --- a/spec/unit/sslcertificates/ca_spec.rb +++ b/spec/unit/sslcertificates/ca_spec.rb @@ -5,27 +5,23 @@ require 'puppet' require 'puppet/sslcertificates' require 'puppet/sslcertificates/ca' -describe Puppet::SSLCertificates::CA, :fails_on_windows => true do +describe Puppet::SSLCertificates::CA, :unless => Puppet.features.microsoft_windows? do + include PuppetSpec::Files + before :all do @hosts = %w{host.domain.com Other.Testing.Com} end before :each do Puppet::Util::SUIDManager.stubs(:asuser).yields - file = Tempfile.new("ca_testing") - @dir = file.path - file.delete + dir = tmpdir("ca_testing") - Puppet.settings[:confdir] = @dir - Puppet.settings[:vardir] = @dir + Puppet.settings[:confdir] = dir + Puppet.settings[:vardir] = dir @ca = Puppet::SSLCertificates::CA.new end - after :each do - system("rm -rf #{@dir}") - end - describe 'when cleaning' do it 'should remove associated files' do dirs = [:csrdir, :signeddir, :publickeydir, :privatekeydir, :certdir] diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb index 7bf92eb02..f2c18896b 100755 --- a/spec/unit/type/cron_spec.rb +++ b/spec/unit/type/cron_spec.rb @@ -1,7 +1,7 @@ #!/usr/bin/env rspec require 'spec_helper' -describe Puppet::Type.type(:cron) do +describe Puppet::Type.type(:cron), :unless => Puppet.features.microsoft_windows? do before do @class = Puppet::Type.type(:cron) diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb index 4c2c79e88..29e3298f0 100755 --- a/spec/unit/util/rdoc/parser_spec.rb +++ b/spec/unit/util/rdoc/parser_spec.rb @@ -149,6 +149,10 @@ describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do File.stubs(:identical?).returns(false) @parser.split_module("/path/to/manifests/init.pp").should == RDoc::Parser::SITE end + + it "should handle windows paths with drive letters", :if => Puppet.features.microsoft_windows? do + @parser.split_module("C:/temp/init.pp").should == RDoc::Parser::SITE + end end describe "when parsing AST elements" do |
