summaryrefslogtreecommitdiff
path: root/spec/unit/file_serving
AgeCommit message (Collapse)AuthorFilesLines
2014-04-28(maint) replace `using_checksums_describe` with `with_digest_algorithms`Adrien Thebo1-71/+73
2014-04-28(PUP-1840) Respect digest_algorithm in file metadataAdrien Thebo1-19/+17
Original code implemented by Jared Jennings <jared.jennings.ctr@us.af.mil>
2014-03-07(Maint) Remove some duplication in testsAndrew Parker1-5/+8
This duplication actually bit me when writing the test for PUP-1885.
2014-03-07(PUP-1885) Stringify ignores for file servingAndrew Parker1-2/+16
Commit 6353ebbbc0d3804e30e9961559b01c9a69a74a93 introduced non-yaml encoding for arrays of HTTP parameters. Unfortunately this also exposed those values to the type conversion that is done to parameters in the HTTP layer, which caused an ignore for a file matching "0" to be turned into the number 0. The file serving code didn't handle getting non-string ignore patterns and would then raise an error. This changes the file server to stringify all of the parameters that it recieves for ignores, which solves both the number problem as well as a related one for booleans. An alternative solution to this would have been to change the HTTP handler so that it didn't try to convert arrays of values. I didn't go for that because it would have caused the parameter handling to be inconsistent.
2014-02-06(maint) Change name from from_pson to from_data_hashErik Dalén1-2/+2
This is because these methods are also used for deserialization from other formats than PSON. The method for serializing a object is called to_data_hash, so makes sense to call this from_data_hash.
2014-01-31PUP-1450 Windows file resource Invalid DACL errorsEthan J. Brown1-0/+65
- When the source of a file resource is referred to through a symlink it's possible the volume for the real file does not support ACLs. Unfortunately it's not possible to simply readlink the path to determine the real path / volume, so the best thing to do is attempt to read the DACL of the file, catch the exception when it's invalid and fallback to default owner / group / mode on Windows. - Furthermore, under VirtualBox, the standard ERROR_INVALID_DACL is not the error that propagates, but rather ERROR_INVALID_FUNCTION, so there is special handling for that scenario. - Note that this particular issue also affects paths like the Puppet module path puppet:///modules that may be symlinked in environments like Vagrant.
2014-01-14(PUP-1151) Consolidate JSON schema validationAndrew Parker1-24/+10
This adds a new matcher to the JSONMatchers to validate json against a given json-schema. All of the json schema validation now goes through this one matcher, which also handles skipping the checks on windows.
2014-01-06(PUP-716) Change back to stubs from mocksAndrew Parker1-1/+1
During changes a few calls had been inadvertently changed from stubs (any number of calls allowed, including 0) to mocks (at least one call required). In the case of the file_set this caused a problem for when there was no expectaiton of the methods being called. In the daemontools case, this exposed a mistake that was originally in the tests where the stub was not even needed.
2014-01-06(PUP-716) Remove references to FileSystem::File in non codeHenrik Lindberg1-2/+2
2014-01-06(PUP-716) Fix typos after change of FileSystem APIHenrik Lindberg1-1/+1
writable? is spelled just like that A BucketFile is not a Pathname Removed reference to FileSystem::File
2014-01-06(PUP-716) Fix up base_spec tests after FileSystem API changeHenrik Lindberg1-3/+2
2014-01-06(PUP-716) Fix up metadata_spec after refactored FileSystem changesHenrik Lindberg1-6/+6
2014-01-06(PUP-716) Fix up content_spec.rbHenrik Lindberg1-15/+7
2014-01-06(PUP-716) Fix up fileset_spec (1 failing test remains)Henrik Lindberg1-18/+7
One test is still failing.
2014-01-06(PUP-716) Make more tests in fileset_spec passHenrik Lindberg1-3/+3
2014-01-06(PUP-716) Change more tests after refactoringHenrik Lindberg1-33/+23
This also fixes the spec_helper which had a reference to FileSystem::File
2014-01-06(PUP-716) Change Puppet::FileSystem::File to module methodsHenrik Lindberg4-30/+30
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-12-26(maint) Update test to work on non-UTF-8 systemsAndrew Parker1-1/+1
Not all systems run as UTF-8 (our solaris tests run as US-ASCII). In those cases \xc2\xa0 (NO-BREAK SPACE) is not a valid character. This causes the test to fail because of encoding problems. By using \x01 (a control character) we can check the same scenario, but using a character sequence that is valid in all of our setups.
2013-12-26(PUP-1246) Update tests to show line numbersAndrew Parker1-9/+3
The previous tests didn't check that the correct line number was being reported. This updates the checks so that we can verify the line number.
2013-12-26(PUP-1246) Fixed hiding error details in fileserver.conf parserAlexei Romanoff1-0/+12
This patch fixes wrong parser behavior in case when fileserver.conf contains some broken lines. It helps to debug configuration problems and makes puppet's user life a little bit easier. Also added 2 unit tests for validating these buggy cases.
2013-11-14(#19447) Skip symlink test if provider doesn't support itJosh Cooper1-1/+1
Confine the tests to when the provider supports symlinks. Note how the shared examples are invoked if the windows host supports symlinks. Putting the check inside the "metadata collector symlinks" shared example causes the "on Windows" outer example groups before each block to be executed on non-windows platforms.
2013-11-14(#19447) check Puppet.features.manages_symlinks?Ethan J. Brown1-1/+1
- Replace calls to the specific :file provider with the global Puppet.features call
2013-11-14(#19447) Puppet::FileSystem::File Windows symlinkEthan J. Brown1-2/+17
- Windows symlink support has been added to exist?, symlink, symlink?, readlink, stat, and lstat. This overrides any usage of Ruby File or FileTest classes which are completely borked on Windows. - :manages_symlinks feature of the file provider is enabled with a check against Puppet.features.manages_symlinks? which checks for the existence of the CreateSymbolicLink call in kernel32.dll - FFI wrappers for Win32 API calls CreateSymbolicLink, CreateFile, GetFileAttributes, DeviceIoControl and CloseHandle added to windows/file NOTE: The DeviceIoControl method of resolving symlinks was used instead of GetFinalPathNameByHandle, which is known to misbehave with UNC paths - Any tests against :manages_symlinks feature are automatically turned on for Windows, increasing test count by approximately 42 new tests - Removed a few symlink tests that were confined to any OS other than Windows since they must now be adjusted to run on Windows versions that we know support symlinks - Updated symlink documentation based on ileUtils.symlink behavior
2013-11-08(#19447) Puppet::FileSystem::File.exist?Ethan J. Brown3-20/+20
- 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-11-08(#19447) Puppet::FileSystem::File#stat / lstatEthan J. Brown4-48/+90
- All calls to File class stat / lstat go through the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-11-08(#19447) Puppet::FileSystem::File#readlinkEthan J. Brown1-3/+2
- All calls to File readlink go through the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-11-08(#19447) Puppet::FileSystem::File#symlink(?)Ethan J. Brown1-1/+1
- All calls to File / FileTest class methods symlink and symlink? go through instance methods on the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-11-08(#19447) Add :manages_symlinks to file typeIristyle1-2/+14
- The ensure => :link feature of the file type is now restricted by the :manages_symlinks feature - Only the existing POSIX provider allows symlink support - Updated relevant tests to check a provider for .feature?(:manages_symlinks) over Puppet.features.microsoft_windows? - metadata_spec.rb was refactored as RSpec nested tests can override their ability to run with true :if conditions. Shared examples intended to be run on Windows only were also being executed under OSX because provider feature :manages_symlinks check was true, despite the enclosing test scope being restricted to Windows - file_spec.rb unit tests had 5 new manages_symlinks guards enabled on tests, preventing 10 existing tests from running on Windows that likely should never have been run in that environment (these tests will be re-enabled with Windows symlink support)
2013-10-27Merge pull request #1998 from jjulien/feature9546kylo1-0/+73
(#9546) Add external fact pluginsync
2013-10-23(Maint) Convert uses of IO.binread to P::FS::FileAndrew Parker1-2/+6
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.
2013-10-14(#9546) Add spec tests for external fact pluginsyncJohn Julien1-0/+73
2013-10-08(maint) Rename validate_as_json to be specificPatrick Carlisle1-5/+5
This renames validate_as_json methods to be specific to the schema they are validating (since that's embedded in each definition) and inlines the implementations that didn't need to be abstracted.
2013-10-01(#22643) Document the file_metadata endpoint.Kylo Ginsberg1-1/+32
This patch documents the file_metadata endpoint (a find operation) and the file_metadatas endpoint (a search operation). It includes a json schema for the returned file_metadata object, and spec tests for validating some variants of file metadata against that schema.
2013-09-168657 Support UNC paths for file objects on Windowspocams1-0/+17
Before this change, UNC paths as the source for files under Windows were not supported and caused errors. This limited the usefulness of the file type under Windows. This patch adjusts the logic used to handle UNC paths so they can be successfully used.
2013-07-11(maint) Fix rspec warningsPatrick Carlisle2-6/+6
Running specs with rspec 2.13 caused a lot of warnings. Many of them actually exposed preexisting bugs, the most common being a syntax error when expecting an Exception. These are worth fixing even if we don't bump to rspec 2.13.
2013-06-18Merge branch 'stable'Matthaus Owens1-28/+20
Conflicts: spec/unit/file_serving/metadata_spec.rb
2013-06-03(#20584) Only deserialize expected objects from YAMLPatrick Carlisle1-28/+20
Puppet no longer allows the base YAML library to deserialize arbitrary objects. By using the safe_yaml package, we deserialize only primitive data structures. The remainder of the deserialization process is now unified between YAML and PSON. This code will explicitly create only the expected objects from the primitive data types. As a side effect of this change the code for REST indirections now allows specialized deserialization routines per method. The save method now returns nil by default, and is only overridden in a couple of cases where Puppet was using the return value to preserve previous behavior.
2013-04-26Merge branch 'stable'Jeff McCune1-2/+2
* stable: Revert "Merge branch 'nicklewis-rcS-is-a-jerk' into stable" (#20308) Try again to fix fileset tests on Windows (#20308) Fix fileset spec for Windows
2013-04-26(#20308) Try again to fix fileset tests on WindowsPatrick Carlisle1-1/+1
2013-04-26(#20308) Fix fileset spec for WindowsPatrick Carlisle1-1/+1
2013-04-25Merge remote-tracking branch 'pcarlisle/ticket/20308-file-serving-recursion'Andrew Parker1-305/+255
* pcarlisle/ticket/20308-file-serving-recursion: (#20308) Clean up the fileset specs (#20308) Refactor fileset recursion for clarity (#20308) Fix dropping paths from fileset results (#20308) Make more of Fileset private (#20308) Add failing test for incomplete file list
2013-04-25(#20308) Clean up the fileset specsPatrick Carlisle1-261/+243
Paired-with: Andrew Parker <andy@puppetlabs.com>
2013-04-25(#20308) Refactor fileset recursion for clarityPatrick Carlisle1-19/+18
The previous expression of the algorithm for traversing the file structure and producing the available files was hard to understand and therefore error prone (see the bug that is being fixed here). This refactors it to be better separated and should be easier to see any problems in it. Another part of the cleanup was to make checks against the filesystem more explicit: either the path is valid or not, whether the path is a directory. Paired-with: Andrew Parker <andy@puppetlabs.com>
2013-04-25(#20308) Make more of Fileset privatePatrick Carlisle1-68/+0
Several of the public methods on fileset only seemed to be there for testing. There is no need for this as the behavior of the file listing already checks the conditions controlled by those internal methods. Paired-with: Andrew Parker <andy@puppetlabs.com>
2013-04-25(#20308) Add failing test for incomplete file listPatrick Carlisle1-0/+37
Under certain circumstances the fileset will drop subdirectories from its results. This adds a test showing this failure. Paired-with: Andrew Parker <andy@puppetlabs.com>
2013-04-25Refactor how files are watchedNick Lewis1-33/+23
LoadedFile is now WatchedFile (since it has nothing to do with loading files, only with telling when they change), and some of its internal variables have been renamed for clarity. Also added a FileWatcher class whose entire purpose is to track a set of LoadedFiles in aggregate. This is now used by TypeCollection in place of its own hash. Puppet::FileServing::Configuration::Parser and Puppet::Util::NetworkDevice::Config were inheriting LoadedFile, simply for its changed? method, even though neither of them really has file properties. Now they wrap a WatchedFile instance instead.
2013-04-23spelling/grammatical fixesRichard Soderberg1-1/+1
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune12-12/+12
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-31Remove deprecated method of accessing files in modulesPatrick Carlisle1-15/+1
It was possible to refer to a file in a module without including the '/module/' path component. This has been deprecated for at least one major release. Paired-with: Jeff McCune <jeff@puppetlabs.com>
2012-07-23Reduce stubs and expectations on settingsPatrick Carlisle1-5/+5
Many tests set stubs or expectations on configuration values. This is unnecessary, as settings are reset before each test. Because creating a stub stubs out the entire value method on settings, stubbing any individual setting interferes with retrieving any other setting. This makes for weird errors and fragile tests. This commit changes most cases to just set each setting directly. Expectations on settings were often used to verify that a setting is used. This is not a good way of testing this, since it checks that the value is accessed but not that it is actually used correctly. Most expecations on settings are better expressed by changing the setting and then verifying a returned value.