summaryrefslogtreecommitdiff
path: root/spec/integration/indirector/direct_file_server_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-03-21(maint) Check for files by full nameAndrew Parker1-23/+20
Periodically this test would fail with a message about some path being a directory. It turns out that what was happening was that that generated name for the temp directory would end in "one" or "two". This caused the test to detect the directory entry in the response from the search request to be one of the files and so it would try to read the contents, which wasn't possible because it was the directory. This changes it to check for the files by the full path and use "include_in_any_order" to pull together two tests into one.
2014-01-06(PUP-716) Change Puppet::FileSystem::File to module methodsHenrik Lindberg1-1/+1
This changes the API in a new implementation in a file called file_.rb The intent is that it should replace the implemntation in File, or perhaps directly in a Puppet::FileSystem class.
2013-11-08(#19447) Puppet::FileSystem::File.exist?Ethan J. Brown1-1/+1
- All previous File and FileTest calls to exist? or exists? go through the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-10-23(Maint) Convert uses of IO.binread to P::FS::FileAndrew Parker1-4/+2
Now that we have Puppet::FileSystem::File we can start using it in more places and start getting rid of some of the monkey patches that puppet has been doing.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
Without this patch some spec files are using `ruby -S rspec` and others are using `rspec`. We should standardize on a single form of the interpreter used for spec files. `ruby -S rspec` is the best choice because it correctly informs editors such as Vim with Syntastic that the file is a Ruby file rather than an Rspec file.
2012-04-23Make positional arguments distinct in Request#initializePatrick Carlisle1-3/+3
Puppet::Indirector::Request#initialize had a weird implementation giving variable semantics to positional arguments. This makes it normal again.
2012-04-18Use conditional pending to block out "fails_on_windows" tests.Daniel Pittman1-8/+12
A whole bunch of tests scattered through the system fail on Windows, around features that are not supported on that platform. (They are things that only the master does, which an agent-only platform doesn't need to support.) These were tagged `fails_on_windows` to allow filtering them from rspec runs, which is great, but doesn't actually communicate nearly as much useful information as it would if we used the "conditionally pending" facilities that rspec has supported since 2.3. That gives us two key things: one, it works automatically based on our knowledge of the platform, which means you can't forget to turn off failing tests. Two, it means that if the test starts unexpectedly passing we also get a failure, since we should respond to "works when it shouldn't" as seriously as "fails when it shouldn't". Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-01-23(#11955) Refactor to use IO.binreadJosh Cooper1-1/+1
Previously, I had created a utility method `Puppet::Util.binread`, since `IO.binread` was added in ruby 1.9. This commit monkey patches the method, if it's not defined, to make the transition to ruby 1.9 seamless. And while I was at it, I add the corresponding `IO.binwrite` method. The motivation for these methods is that, in general, we should always be using binary mode when performing file I/O. However, text mode is the default on Windows, and using text mode can corrupt binary data, e.g. executables. So use binary mode, unless you know what text mode is and why you need to use it. Conflicts: spec/unit/file_serving/content_spec.rb
2012-01-12(#11929) Always serve files in binary modeJosh Cooper1-1/+1
Previously, Windows agents were reading files in text mode when serving them locally, such as when serving files from a local module, corrupting binary files in the process. This commit reads files in binary mode, which is a noop on Unix. Serving files from remote puppet masters was fixed in #9983.
2011-10-05Change test to not call 'rm -rf'Josh Cooper1-15/+9
Previously the test was failing on Windows because there were problems with local file serving on Windows. That part was fixed, so the only remaining issue was changing the test to not call 'rm -rf'. This commit converts the tests to the new style, using tmpfile, etc. and removes the fails_on_windows tag.
2011-08-19Maint: Tagged spec tests that are known to fail on WindowsJosh Cooper1-1/+1
Many spec tests fail on Windows because there are no default providers implemented for Windows yet. Several others are failing due to Puppet::Util::Cacher not working correctly, so for now the tests that are known to fail are marked with :fails_on_windows => true. To skip these tests, you can run: rspec --tag ~fails_on_windows spec Reviewed-by: Jacob Helwig <jacob@puppetlabs.com> (cherry picked from commit 255c5b4663bd389d2c87a2d39ec350034421a6f0) Conflicts: spec/unit/resource/catalog_spec.rb
2011-08-19Fix tests with "relative" paths on WindowsJosh Cooper1-2/+4
Absolute paths on Unix, e.g. /foo/bar, are not absolute on Windows, which breaks many test cases. This commit adds a method to PuppetSpec::Files.make_absolute that makes the path absolute in test cases. On Unix (Puppet.features.posix?) it is a no-op. On Windows, (Puppet.features.microsoft_windows?) the drive from the current working directory is prepended. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com> (cherry picked from commit 462a95e3d077b1915a919399b846068816c84583) Conflicts: spec/unit/parser/functions/extlookup_spec.rb
2011-08-18maint: remove inaccurate copyright and license statements.Daniel Pittman1-4/+0
For a while Luke, and other authors, injected a created tag, copyright statement, and "All rights reserved" into every new file they added to the Puppet project. This isn't really true, and we have a global license covering the code, so we have now stripped out all those old tags. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-1/+1
We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2010-12-06maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson1-1/+1
Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe
2010-07-09Code smell: Two space indentationMarkus Roberts1-52/+52
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
2010-07-09Code smell: Use string interpolationMarkus Roberts1-3/+3
* Replaced 83 occurances of (.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[]) with \1#{\2}" 3 Examples: The code: puts "PUPPET " + status + ": " + process + ", " + state becomes: puts "PUPPET " + status + ": " + process + ", #{state}" The code: puts "PUPPET " + status + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" The code: }.compact.join( "\n" ) + "\n" + t + "]\n" becomes: }.compact.join( "\n" ) + "\n#{t}" + "]\n" * Replaced 21 occurances of (.*)" *[+] *" with \1 3 Examples: The code: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}, #{state}" The code: puts "PUPPET #{status}" + ": #{process}, #{state}" becomes: puts "PUPPET #{status}: #{process}, #{state}" The code: res = self.class.name + ": #{@name}" + "\n" becomes: res = self.class.name + ": #{@name}\n" * Don't use string concatenation to split lines unless they would be very long. Replaced 11 occurances of (.*)(['"]) *[+] *(['"])(.*) with 3 Examples: The code: o.define_head "The check_puppet Nagios plug-in checks that specified " + "Puppet process is running and the state file is no " + becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + The code: o.separator "Mandatory arguments to long options are mandatory for " + "short options too." becomes: o.separator "Mandatory arguments to long options are mandatory for short options too." The code: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + "older than specified interval." becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval." * Replaced no occurances of do (.*?) end with {\1} * Replaced 1488 occurances of "([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b) with 20 Examples: The code: args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") becomes: args[0].split(/\./).map do |s| "dc=#{s}" end.join(",") The code: puts "%s" % Puppet.version becomes: puts "#{Puppet.version}" The code: raise "Could not find information for %s" % node becomes: raise "Could not find information for #{node}" The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file" The code: Puppet.err "Could not run %s: %s" % [client_class, detail] becomes: Puppet.err "Could not run #{client_class}: #{detail}" The code: raise "Could not find handler for %s" % arg becomes: raise "Could not find handler for #{arg}" The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" The code: raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail becomes: raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}" The code: raise "Could not find facts for %s" % Puppet[:certname] becomes: raise "Could not find facts for #{Puppet[:certname]}" The code: raise ArgumentError, "%s is not readable" % path becomes: raise ArgumentError, "#{path} is not readable" The code: raise ArgumentError, "Invalid handler %s" % name becomes: raise ArgumentError, "Invalid handler #{name}" The code: debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str] becomes: debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'" The code: raise Puppet::Error, "unknown cert type '%s'" % hash[:type] becomes: raise Puppet::Error, "unknown cert type '#{hash[:type]}'" The code: Puppet.info "Creating a new certificate request for %s" % Puppet[:certname] becomes: Puppet.info "Creating a new certificate request for #{Puppet[:certname]}" The code: "Cannot create alias %s: object already exists" % [name] becomes: "Cannot create alias #{name}: object already exists" The code: return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum] becomes: return "replacing from source #{metadata.source} with contents #{metadata.checksum}" The code: it "should have a %s parameter" % param do becomes: it "should have a #{param} parameter" do The code: describe "when registring '%s' messages" % log do becomes: describe "when registring '#{log}' messages" do The code: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l } becomes: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" } The code: assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do becomes: assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
2010-06-28[#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts1-0/+73
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700