summaryrefslogtreecommitdiff
path: root/spec/unit/util
AgeCommit message (Collapse)AuthorFilesLines
2014-05-22(PUP-2544) Util::ADSI -> Util::Windows::ADSIEthan J. Brown1-96/+92
- Move Windows ADSI code out of puppet/util and into puppet/util/windows - Update namespace from Puppet::Util::ADSI to Puppet::Util::Windows::ADSI - Add module / class definitions for ADSI to util/windows.rb to prevent tests from blowing up on non-Windows - Moving Puppet.features.microsoft_windows? checks to top of user and group provider tests for ADSI - Update all dependent code, remove unnecessary references
2014-05-22(PUP-836) FFI Puppet::Util::Windows::UserEthan J. Brown2-0/+28
- LogonUserW, LoadUserProfile, UnloadUserProfile and PROFILEINFO have been converted from manually packing params with Win32API.new to automatically managed with FFI definitions. - Use MemoryPointer where appropriate. - Note that wide character LogonUserW is used rather than platform varying LogonUser as FFI is unable to use that. The pointer widths of PROFILEINFO vary depending on platform, which is handled by using :pointer. With LogonUserW the string pointed to is always wide character, which is properly handled by using wide_string. - Add FFI::MemoryPointer helper read_handle - Add FFI::MemoryPointer.from_wide_string and corresponding tests that ensure that a properly terminated UTF-16LE string is passed in - Add FFI::MemoryPointer#read_wide_string that reads a wide string buffer into a Ruby string with Encoding.default_external and corresponding tests - Add additional tests around User methods that make native Win32 API calls that will intentionally fail - Fix wide_string helper to return nil when given nil so that can be passed directly to Win32 as a null pointer
2014-05-13Merge branch 'stable'Kylo Ginsberg1-4/+4
2014-05-13(PUP-2561) Remove the now obsolete ‘mode’ argument to ::execpipe.Pieter van de Bruggen1-4/+4
Earlier, we’d added a ‘mode’ parameter to the P::U::Execution.execpipe to support writing to the subprocess’ STDIN. This commit removes that functionality since we do not depend on it, we’ve never published it in a supported release, and we do not wish to provide ongoing support for it.
2014-05-12(PUP-2214) Fix spec failures under 1.8.7Josh Partlow1-6/+14
Fixes some rdoc1 spec issues by providing explicit envs in the specs.
2014-04-28(PUP-1699) Use Puppet.override to provide some spec envsJosh Partlow1-4/+5
A few specs relying on mocking Puppet::Node::Environment.new to return a specific test environment were colliding with the new environments cacheing layer. Switched to using puppet override to supply a static environment.
2014-04-24Merge branch 'pr/2477'Josh Cooper1-0/+8
* pr/2477: (PUP-2073) fix for multiple diff_args Closes GH-2477
2014-04-24(PUP-2073) fix for multiple diff_argsMatt Shean1-0/+8
Previously, if you specified multiple arguments in the `diff_args` setting, they would be considered a single argument and quoted to the diff command. Puppet would then try to execute: diff '-u --strip-trailing-cr' pathA pathB But would silently fail without showing any diffs. This commit ensures we can handle multiple diff args.
2014-04-23Merge pull request #2555 from ↵Nick Lewis1-4/+4
pvande/bug/master/pup2278_fix_pmt_handling_of_paths_with_spaces Accept paths with spaces in PMT tarball interactions.
2014-04-21(PUP-2278) Parameterize the mode of Puppet::Util::Execution.execpipe.Pieter van de Bruggen1-4/+4
In the previous commit, the default behavior of `execpipe` was changed to ensure that the pipe was always opened in read/write mode. While we aren't aware of any regressions this change would cause, the cautious route is to maintain the same default behavior for now; to that end, this commit adds a `mode` parameter to `execpipe`, allowing callers to choose the mode the pipe is opened in.
2014-04-18(PUP-2278) Accept paths with spaces in PMT tarball interactions.Pieter van de Bruggen1-4/+4
Prior to this commit, if the module_working_dir or the path to a module being built contained whitespace, our simple string-interpolation would fail to create a valid call to `tar` or `gzip`. This change fixes the bugs resulting from that behavior.
2014-04-16(PUP-2282) Allow deprecation warnings to supply optional keyJosh Partlow1-3/+13
Puppet::Util::Logging#deprecation_warning keeps track of issued deprecations keyed by the originating code line. This works reasonably well for tracing API deprecations, but can cause a problem for notifications coming from internal calls which might happen to be called multiple times by other code sections. It also causes problems if the same line of code issues different deprecation warnings (say by interpolating some parameter into the message). This patch allows an optional key string to be submitted with the deprecation_warning which takes precedence over using the originating call line as the key.
2014-04-10Merge branch 'stable'Josh Partlow1-0/+492
* stable: (packaging) Update PUPPETVERSION to 3.5.1-rc1 (maint) Raise error when parsing duplicate INI section (maint) Yumrepo boolean values are case insensitive. (PUP-2178) Map INI name to yumrepo descr (PUP-2181) Delete ini file entries on absent property (PUP-2179) Replace Puppet::Util::IniConfig::File (PUP-2179) Implement simple INI file collection (PUP-2179) implement storing for single INI files (PUP-2179) Implement INI single file formatting (PUP-2179) Extract standalone INI file class (PUP-2179) Add test coverage for IniConfig::Section (maint) Don't strip whitespace from yumrepo keys (PUP-2162) support yumrepo baseurl/gpgkey multiple values (PUP-2150) allow yumrepo params to be set absent (PUP-2613) Comprehensively test all yumrepo params
2014-04-10Merge pull request #2520 from adrienthebo/bugfix/stable/pup-2163-yumrepo-fixesJosh Partlow1-0/+492
PUP-2163 Smite yumrepo and inifile with the mighty sword of refactoring
2014-04-10(maint) Raise error when parsing duplicate INI sectionAdrien Thebo1-1/+12
2014-04-09(PUP-2179) Implement simple INI file collectionAdrien Thebo1-0/+136
This commit reimplements the Puppet::Util::IniConfig::File interface on top of PhysicalFile objects. This makes for a much simpler and cleaner implemenatation that we can swap out the implementation of the File class.
2014-04-09(PUP-2179) implement storing for single INI filesAdrien Thebo1-11/+85
2014-04-09(PUP-2179) Implement INI single file formattingAdrien Thebo1-0/+50
2014-04-09(PUP-2179) Extract standalone INI file classAdrien Thebo1-0/+137
The existing Puppet::util::IniConfig::File class is responsible for both managing a collection of files as well as parsing, formatting, and storing those files. This overloads the responsibility of this class and makes it hard to make behavior changes. This commit extracts a class that represents a single file. Since the 'File' constant is already used this is named 'PhysicalFile' in contrast to the logical nature of the existing File class. This commit only extracts the parsing and later commits will add more behavior.
2014-04-09(PUP-2179) Add test coverage for IniConfig::SectionAdrien Thebo1-0/+84
2014-04-09Merge remote-tracking branch 'upstream/stable'Andrew Parker2-3/+3
* upstream/stable: (PUP-2158) Unlist configured environment (PUP-2158) Test dynamic environments with an empty environmentpath (PUP-2158) Fix integration apply application spec (PUP-2129) Fix issues with false interpolation start (no-such-method) (PUP-2158) Report 404 for missing environment (PUP-2158) Default a missing manifest to no_manifest (PUP-2158) Hide dir envs behind a feature flag Conflicts: lib/puppet/node/environment.rb spec/unit/environments_spec.rb
2014-04-07(PUP-2158) Default a missing manifest to no_manifestAndrew Parker2-3/+3
The tests were often creating environments that didn't need to have manifests. Since we didn't have a way of specifying that when they were written, we used '' to fill in the blank. This actually caused a large number of tests to try to find code to load in the PWD, which caused tests to break if a developer had parse errors in manifests being used for testing in the root directory of their puppet project. This changes the manifest to be optional and removes '' from those tests. The tests no longer fail if a bad manifest is in the PWD :D
2014-04-01Merge pull request #2491 from ↵Andrew Parker1-1/+1
jpartlow/feature/master/pup-1433-deprecate-implicit-environment-settings Feature/master/pup 1433 deprecate implicit environment settings
2014-03-31(maint) Display full trace to deprecated codeAndrew Parker1-1/+1
Sometimes the location that immediately triggered the deprecation warning isn't enough information to understand what happened. This adds the ability to see the full trace to the deprecation when --trace is enabled.
2014-03-26Merge remote-tracking branch 'jaredjennings/fix/master/add-sha256-20140319'Rob Reynolds1-5/+12
2014-03-19(PUP-1840) Add an sha256 checksum type to Puppet::Util::ChecksumsJared Jennings1-5/+12
Without this patch applied, Puppet doesn't know how to perform checksums of files using the SHA-256 algorithm. This precludes Puppet from being useful on hosts configured for compliance with U.S. Federal Information Processing Standard (FIPS) 140-2. The SHA-2 family of algorithms is recommended for use by the U.S. National Institute of Standards and Technology (NIST) in FIPS 140-2; SHA-256 is the algorithm from this family having the shortest output. This patch makes SHA-256 available for use as a checksum algorithm by other parts of Puppet, alongside MD5 and SHA-1.
2014-03-13(PUP-1879) Clear gem path cache when loading library featuresDominic Cleal2-0/+16
Installing gems during a Puppet run should be picked up by features using the 'libs' option. However gems are installed into separate directories, so rubygems maintains an in-memory directory cache, which needs invalidating when attempting to load a library after installation.
2014-02-14(maint) Improve Puppet::Util::Docs.scrub's handling of one-linersNick Fagerlund1-0/+9
One-liner handling wasn't behaving as expected. Sometimes one-liners are buffered with extra newlines before and/or after, and in these cases, scrub wasn't catching the leading whitespace. This commit makes it behave as intended, and adds a test showing the intended behavior.
2014-02-06(maint) Change name from from_pson to from_data_hashErik Dalén6-8/+8
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-02-05(PUP-1559) Ensure ADSI Group SIDs may be looked upEthan J. Brown1-1/+48
- Previously, calling Puppet::Util::ADSI::Group.exists? for a well-known group SID would return false, because the WinNT:// style URI used to find the group would not examine / lookup the SID, but would instead create a broken Uri that the underlying OS could not understand - Now, the given group name is checked to see if it's a SID before the Uri is constructed, and a SID style Uri is created where appropriate Paired-with: Joshua Partlow <jpartlow@puppetlabs.com>
2014-01-29(PUP-1118) Fix rdoc1 specs to match changes to rdoc puppet_parser_coreJosh Partlow1-27/+28
PuppetParserCore was updated to pass environment, known_resource_types; this just catches up the spec, which runs only on 1.8.7, to match the changes.
2014-01-29(PUP-1118) Stop using Environment.newAndrew Parker1-28/+5
Instead of creating environments directly, we need to go through the configured environment loaders, otherwise environments can't come from other places.
2014-01-28Merge branch 'ticket/master/PUP-1494/remove-native-ruby-encode-UTF-16-windows'Iristyle1-0/+14
* ticket/master/PUP-1494/remove-native-ruby-encode-UTF-16-windows: PUP-1494 Guard against Win32 memory corruption PUP-1494 - Remove Windows iconv from colors.rb
2014-01-28PUP-1494 Guard against Win32 memory corruptionEthan J. Brown1-0/+14
- Ruby's .encode(UTF-16LE) call on String may generate a string that not properly terminated with 2 NULLs, which may result in garbage bytes read from the memory pointer passed into the Win32 API. This can cause memory instability which results in failures in later Win32 calls. These calls have been replaced with an internal helper that properly NULl terminates the string. Note that this bug is fixed in Ruby 2.1: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=41920&view=revision - Don't include the wide NULL character when calculating number of characters to write to the console to properly indent Puppets stdout output (without the -1 calculation, it's indented with two spaces). - Includes a test to ensure that we can detect when `string_encode` is updated in the future, when we move to a version of Ruby where the String#encode bug is fixed for encodings with multi-byte terminators Paired-with Josh Cooper <josh@puppetlabs.com>
2014-01-23(PUP-1118) Load full environments from a directoryAndrew Parker1-11/+11
This changes the loader used by the code to list environments to be a composition of the legacy environments and the new directory environments.
2014-01-22Merge remote-tracking branch 'upstream/stable'Iristyle1-0/+54
* upstream/stable: (maint) Fix rdoc generator for Ruby 2.1.0 (maint) Fix a comment. (maint) Fix can't modify frozen Symbol error on Ruby 2.1.0 (PUP-1389) Embed the extra NULL within the string (PUP-1389) Simplify logic for appending extra NULL (PUP-1389) ReplaceFile to FFI / move wide_string (PUP-1389) Ensure wide strings have double null terminators PUP-1322 Do not fail hard on unparseable files (maint) Correct documentation of each function (maint) Fix acceptance test for scheduled_task deletion Conflicts: lib/puppet/parser/functions/each.rb
2014-01-17Revert "Merge branch 'ticket/master/18342-windows-file-setting-owner-group'"Iristyle2-36/+1
This reverts commit cf4501c7a97c106994c2ef81756c2081f56feeef, reversing changes made to fcf482aa85708fe20f38cd96d6d92fc58ee78cf6.
2014-01-17(PUP-1389) Embed the extra NULL within the stringJosh Cooper1-30/+14
Previously, we were appending a NULL to the wide encoded string to work around a ruby bug fixed in 2.1. However, we were calling `String#strip`, which makes a copy of the string, and in the process only preserves the first NULL. This commit embeds a NULL within the string itself, e.g. "bob\0". Since the NULL is part of the string data, ruby will preserve it. Also, `String#+` cannot combine strings with different encodings, e.g. "a".encode('UTF-16LE') + "\0" results in: incompatible character encodings: UTF-16LE and US-ASCII which is why we need to encode the terminator. The actual message depends on the default encoding, e.g. US-ASCII, UTF-8.
2014-01-15Merge branch 'ticket/master/18342-windows-file-setting-owner-group'Rob Reynolds2-1/+36
2014-01-15Merge branch 'pr/2168'Peter Huene1-5/+47
* pr/2168: (PUP-1150) Fix race condition in Puppet::Util::Lockfile. This closes GH-2168.
2014-01-15(PUP-1150) Fix race condition in Puppet::Util::Lockfile.Glenn Pratt1-5/+47
Before this commit, Puppet::Util::Lockfile.lock called the locked? method before opening the @lockfile for write. Checking that the file doesn't exist and creating the file were not an atomic operation, which allowed two processes to detect that the file didn't exist and open it for write simultaneously. This commit adds and used Puppet::FileSystem::exclusive_create wrapper that sets the following options: * File:CREAT - Creates the file if it doesn't exist. * File:EXCL - Fails if the file does exist. * File:WRONLY - Opens the file for write only. File:EXCL is the important option, callers will recieve an Exception if the file exists, meaning another process has acquired the lock. If the file doesn't exist it will be created atomically, so other another caller cannot create the file in the gap.
2014-01-14Merge branch 'pr/2261' into stableJosh Cooper1-0/+70
* pr/2261: (PUP-1389) Simplify logic for appending extra NULL (PUP-1389) ReplaceFile to FFI / move wide_string (PUP-1389) Ensure wide strings have double null terminators
2014-01-14(PUP-266) Puppet manages group and owner on configEthan J. Brown1-0/+6
- Previously, Puppet would ignore the configuration in defaults.rb for setting a group / owner on a given file or directory -- even when the Windows machine was running with administrative permissions - Since Windows now has the capability of properly setting a group and owner, allow Windows to manage these permissions when appropriate - The existing Puppet::Settings::FileSettings::Service class depends on looking up the appropriate default service accounts for use in a number of locations. To fall in line with this usage pattern, "Administrators" is set as the default owner and the "Service" group S-1-5-6 is set as the default group. This special OS managed group includes all accounts with the logon as a service token privilege.
2014-01-14(PUP-266) Ensure ADSI Group SIDs may be looked upEthan J. Brown1-1/+30
- Previously, calling Puppet::Util::ADSI::Group.exists? for a well-known group SID would return false, because the WinNT:// style URI used to find the group would not examine / lookup the SID, but would instead create a broken Uri that the underlying OS could not understand - Now, the given group name is checked to see if it's a SID before the Uri is constructed, and a SID style Uri is created where appropriate
2014-01-14(PUP-1389) ReplaceFile to FFI / move wide_stringRob Reynolds1-0/+70
Puppet::Util::Windows::File.replace_file now calls FFI to replace files in place on Windows. Puppet::Util::Windows::File.wide_string has now been moved to Puppet::Util::Windows::String.wide_string. This moves wide_string to lib/puppet/ubilt/windows/string.rb, adds specs concerning different encodings. In addition, we've removed Windows::API::WideString usages from everywhere it was found as it is known to cause issues with Windows 2012. Puppet::Util::Windows::Process.lookup_privilege_value in particular was changed to use LookupPrivilegeValueA (ANSI) as we control the privilege name being passed to it. Paired with Josh Cooper <josh@puppetlabs.com>
2014-01-14(PUP-1151) Consolidate JSON schema validationAndrew Parker3-0/+5
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-13(maint) Fix typo in spec test descriptionKylo Ginsberg1-1/+1
2014-01-13Merge remote-tracking branch 'upstream/stable'Kylo Ginsberg1-0/+54
2014-01-07(PUP-1211) Force registry value encoding to match code pageJosh Cooper1-0/+54
Ruby uses ANSI versions of Win32 APIs to read values from the registry. The encoding of these strings depends on the active code page. However, ruby incorrectly sets the string encoding to US-ASCII.[1] As a result, if you try to perform a regex match on the string, and the string contains the registered trademark symbol, 0xAE, then ruby will raise an error saying 'Invalid byte sequence in US-ASCII' This commit forces the encoding of REG_SZ, REG_EXPAND_SZ, and REG_MULTI_SZ to the encoding for the active code page. So if the active code page is 1252, the ruby encoding will be `Encoding::CP1252`. See https://bugs.ruby-lang.org/issues/8943
2014-01-06(PUP-761) Make most FileSystem API change related test passHenrik Lindberg1-1/+1