Age | Commit message (Collapse) | Author | Files | Lines |
|
The tests had their own way of creating files and directories for
testing. All of these different ways of creating files and directories
already existed in PuppetSpec::Files. This unifies them.
|
|
It is helpful to have a simple helper method to match desired file modes
from spec tests.
|
|
This makes it easy to mock a directory structure by giving it
a hash, where non hash entries are content, and hashes are directories.
|
|
- Previously tests were writing to the shared
%ALLUSERSPROFILE%\PuppetLabs\puppet directory, and would blow
up if this directory did not exist
- Because this directory was shared from one run to the next, failing
tests could be masked by data generated / used by a locally installed
Puppet
- The stubbing of FileSystem::File.exist? to return true was causing
some tests to treat files like c:\dev\null\foo to attempt to be
loaded, which would cause these tests to fail in isolation, but not
when run within the suite
- Had to change some doc specs under Ruby 1.9 / OSX to verify a value
instead of asserting a method was called, to prevent a stack overflow
- In some unit tests, the process of reading / writing settings caused
issues with test loading, so Puppet.settings.use has been stubbed
|
|
Because the temp directory is not immediately created with the discovered name,
there might be a race condition between tests running on the same machine.
|
|
The parser face had no spec test coverage. This creates some coverage
around the code. This coverage replaces what is currently being done in
an acceptance test.
|
|
* upstream/2.7.x:
(#16208): Correct spec test to match new failed parameter message
Maint: Fix inconsistent expect-should usage
Maint: Fix leaked tempfile handle
Conflicts:
spec/unit/util_spec.rb
|
|
This test failed on Windows because we were creating a tempfile, but not
closing the underlying file descriptor. So later attempts to cleanup fail
on Windows (unlike POSIX).
This commit modifies the `.tmpfile` and `#tmpfile` methods on the
PuppetSpec::Files module to accept an optional directory in which to
create the temp file.
|
|
* 2.7.x: (26 commits)
Extract host validation in store report processor
Use cross-platform absolute paths in file_serving tests
(#15221) Create /etc/puppet/modules directory for puppet module tool
(Maint:) Fix bad doc strings for two settings ("wether")
Try again to avoid circular dependency in file indirections
Remove useless tests for Envelope
Clear deprecation warnings between tests
Avoid circular requirement in FileMetadata indirection
(Maint) Document common Windows issues
Update CHANGELOG lib/puppet.rb conf/redhat/puppet.spec for 2.7.18
Maint: Note in docs that the file type's "replace" attribute defaults to true
Reject directory traversal in store report processor
Tighten permissions on classfile, resourcefile, lastrunfile, and lastrunreport.
Use "inspect" when listing certificates
Don't allow the creation of SSL objects with invalid certnames
Validate CSR CN and provided certname before signing
Add specs for selector terminuses of file_{content,metadata}
Fix whitespace inside parentheses
Use head method to determine if file is in file bucket
Always use the local file_bucket on master
...
Conflicts:
CHANGELOG
conf/redhat/puppet.spec
lib/puppet.rb
lib/puppet/application/master.rb
lib/puppet/defaults.rb
lib/puppet/file_serving/terminus_selector.rb
lib/puppet/reports/store.rb
lib/puppet/test/test_helper.rb
spec/integration/file_serving/content_spec.rb
spec/integration/file_serving/metadata_spec.rb
spec/shared_behaviours/file_serving.rb
spec/unit/file_serving/terminus_selector_spec.rb
spec/unit/network/handler/ca_spec.rb
test/ral/manager/attributes.rb
|
|
The file_serving tests were failing on windows because they used unix style
paths. This makes them absolute on both posix and windows.
|
|
We have some test helpers, and they allow us to create scratch files and
directories that will be politely destroyed at the end of the run.
We also have some tests that result in permissions on files being changed; we
still want those destroyed, and turning on "force" mode for the delete
operation gives us what we need with no real cost - we have plenty of other
safety factors in place.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Previously you could only access the `tmpfile` and `tmpdir` helpers by mixing
the module in somewhere, despite them exclusively mutating global state.
This became inconvenient when trying to centralize the database setup, so I
moved them to module functions and made the helpers that mix in defer to the
module level methods.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Previously, when managing owner, group, and/or mode on a file whose
volume does not support ACLs, Puppet would raise an error when trying
to get/set the ACL.
This commit allows a file provider to optionally perform validation of
the resource. On Windows, the provider ensures that if owner, group,
and/or mode are being managed, but the underlying volume does not
support ACLs, then we fail early with an appropriate error message.
This is a noop for the POSIX file provider as no validation is
required.
File.expand_path uses the current working directory to generate
absolute paths. This was causing failures when running the specs from
a mapped network drive, e.g. HGFS, since the volume does not support
ACLs. This commit changes these tests to use make_absolute method
instead, and changes that method to always use the local 'C:\' volume.
Paired-with: Nick Lewis <nick@puppetlabs.com>
|
|
A Puppet::Parameter::Path's value is valid if it is fully qualified (or
in the case of an array, if each of its elements is fully qualified).
This class was previously using its own method to validate whether a
path was fully qualified, which was different from the rules applied by
absolute_path?. Now that we have a dedicated method for this,
it is used here for consistency.
|
|
Previously, we were always using string comparisons, and hard-coded
paths to temp locations on non-Windows platforms. This was
problematic for a few reasons. We had to maintain a list of temp
locations for the various platforms, and the string comparisons were
unreliable on Windows, since paths have two string representations
(the "short" name containing a ~ followed by a number, and the "full"
name).
By getting the current temp location using Dir.tempdir (the same
mechanism our temp creation code uses), we no longer need to maintain
the list of temp locations. Also, rather than doing string
comparisons on file paths, we can use a combination of
Pathname#ascend, and File.identical? to determine if the path
registered as a temp file for deletion was actually created in the
temp location.
With this refactoring, the same code now works for both Windows, and
non-Windows platforms.
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
(cherry picked from commit 3aec02ba0e4bda8ba4e9fffbc6defaae4e4e2ba1)
|
|
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
|
|
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.
|
|
We used to shell out to chmod and rm to clean up temporary files; this lead to
the cleanup method here being one of the largest consumers of walltime.
Replacing that with FileUtil calls is as, or more, secure, and performs
sufficiently well that we can just delegate.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
|
|
We move the tempfile cleanup support off into the module that uses it, which
removes some of the dependency on magic globals from configure. It still
exists, but is hidden in the same module that uses it, which helps.
Reviewed-By: Nick Lewis <nick@puppetlabs.com>
|
|
The function import_if_possible, which was supposed to be responsible
for making sure that no two threads tried to import the same file at
the same time, was not making this decision based on the full pathname
of the file, since it was being invoked before pathnames were
resolved. As a result, if we attempted to import two distinct files
with the same name at the same time (either in two threads or in a
single thread due to recursion), one of the files would not always get
imported.
Fixed this problem by moving the thread-safety logic to happen after
filenames are resolved to absolute paths. This made it possible to
simplify the thread-safety logic significantly.
|
|
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
|
|
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
We had a common pattern for creating a temporary
file during integration tests, and this just
makes that common pattern explicit by
moving it to a module in the newly-created
lib directory in the spec directory.
We definitely don't want to go overboard in
using libraries in our tests, but sometimes
it gets a bit excessive to completely avoid them.
Signed-off-by: Luke Kanies <luke@madstop.com>
|