summaryrefslogtreecommitdiff
path: root/spec/unit/util
AgeCommit message (Collapse)AuthorFilesLines
2014-10-20(PUP-3467) Reject SSLv3 when initiating SSL connectionsJosh Cooper1-0/+12
Previously, when puppet initiated SSL connections, e.g. puppet agent, puppet module, etc, it could downgrade to SSLv3. This commit ensures puppet will not downgrade to SSLv3 by setting the `OpenSSL::SSL::OP_NO_SSLv3` bit. However, unlike SSLv2, we cannot remove SSLv3 ciphersuites, since they are the same ones used in TLSv1. From the openssl ciphers man page, "The TLSv1.0 ciphers are flagged with SSLv3". [1] https://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html
2014-10-13(maint) Separate test for missing module directoryAndrew Parker1-2/+7
The test of behavior when a module directory is specified as part of an environment but is missing on disk was hidden inside another test. This splits it out and calls out that the behavior is that the directory is simply ignored.
2014-10-13(PUP-3244) Allow autoload to handle missing environmentAndrew Parker1-13/+27
When a previous commit changed from get() to get!() the agent stopped being able to use an environment that is available on the master, but not available locally. I had misread the code and missed a trailing `&&`. This caused me to think that the environment lookup in this case was required, where in fact it is still optional. This changes the structure of the code to make it much clearer that the environment is optional, changes from get!() to get(), and adds some tests around these code paths.
2014-09-02(maint) Expect test to fail on windows ruby 2.0 x86Josh Cooper1-1/+5
Ruby 2.0 x86 on windows does not observe the 'TZ' environment variable, so the test would generate a Time object whose `#zone` was 'Eur', but had timezone offset based on the current timezone. C:\work\puppet>ruby --version ruby 2.0.0p481 (2014-05-08) [i386-mingw32] C:\work\puppet>irb irb(main):001:0> ENV['TZ'] = 'Europe/London' => "Europe/London" irb(main):002:0> tm = Time.local(2012, "dec", 11, 15, 59, 2) => 2012-12-11 15:59:02 -0800 irb(main):003:0> tm.zone => "Eur" irb(main):004:0> tm.gmt_offset => -28800 Ironically, ruby 1.9 and 2.0 x64 do the correct thing: C:\Windows\system32>ruby --version ruby 2.0.0p481 (2014-05-08) [x64-mingw32] C:\Windows\system32>irb irb(main):001:0> ENV['TZ'] = 'Europe/London' => "Europe/London" irb(main):002:0> tm = Time.local(2012, "dec", 11, 15, 59, 2) => 2012-12-11 15:59:02 +0000 irb(main):003:0> tm.gmt_offset => 0 irb(main):004:0> tm.zone => "Eur" This commit modifies the test so that we expect failure on windows 1.8 and 2.0 x86, otherwise, we expect the test to pass on other ruby platforms. Reviewed-by: Josh Partlow <joshua.partlow@puppetlabs.com>
2014-08-28PUP-3155 Improve spec tests around the PE puppet versionAnderson Mills1-2/+2
Before this commit, when checking the puppet version on a PE build, several characters; '(', ')' and '.'; caused problems with the regex. This commit Regexp.escape-s them.
2014-08-19Merge pull request #2985 from ↵Josh Partlow1-0/+12
cprice404/feature/master/PUP-3032-setting-to-cache-feature-load-failures (PUP-3032) Add setting to always cache `feature` load attempts
2014-08-19Merge pull request #2984 from ↵Josh Partlow1-24/+25
cprice404/bug/master/PUP-3030-server-side-tempfiles (PUP-3030) More explicit handling of tempfiles on the server
2014-08-19(PUP-2889) Eventlog specs pending Windows 2003Ethan J. Brown1-1/+7
- win32-eventlog gem upgraded from 0.5.3 to 0.6.1 as part of https://github.com/puppetlabs/puppet/commit/ac8d4e257f69beaf87489b2e2a57f8aaab512edc - win32-eventlog gem 0.6.1 doesn't yet include the patch necessary to properly load it on 2003 from: https://github.com/djberg96/win32-eventlog/commit/4692e2a67ae8dc794981928d6e6488b775a6689a - Therefore, mark these eventlog tests as pending on 2003 until the 0.6.2 gem ships and the Gemfile can be updated - These guards will be removed as part of PUP-3061
2014-08-18(PUP-3030) Rename P::F::Tempfile to UniquefileChris Price1-25/+25
Since the new implementation of Puppet::FileSystem::Tempfile is not trying to manage the deletion of files created through it, the name was misleading. This commit simply changes the name to Uniquefile to try to make it a bit more obvious that it is not responsible for deleting the files.
2014-08-18(PUP-3030) Port P::U::Execution to use our TempfileChris Price1-24/+25
This commit ports Puppet::Util::Execution over to use our alternate implementation of Tempfile. This will allow us to have more explicit control over the life cycle of these files on the server.
2014-08-16(PUP-3032) Add setting to always cache `feature` load attemptsChris Price1-0/+12
This commit adds a new setting, :always_cache_features, which affects how we cache attempts to load Puppet 'features'. If false, then calls to `Puppet.features.<feature>?` will always attempt to load the feature (which can be an expensive operation) unless it has already been loaded successfully. This makes it possible for a single agent run to, e.g., install a package that provides the underlying capabilities for a feature, and then later load that feature during the same run (even if the feature had been tested earlier and had not been available). If this setting is set to true, then features will only be checked once, and if they are not available, the negative result is cached and returned for all subsequent attempts to load the feature. This behavior is almost always appropriate for the server, and can result in a significant performance improvement for features that are checked frequently.
2014-07-17Merge pull request #2874 from adrienthebo/maint/master/update-rspecAndrew Parker2-2/+1
Maint/master/update rspec
2014-07-15(PUP-2919) Enable win32-eventlog Ruby2 specsEthan J. Brown1-1/+0
- Previously removed in 9449105658cf9789b94cdae096fd904b92828fb8 as part of https://github.com/puppetlabs/puppet/pull/2846 - Win32-eventlog is Windows x64 / Ruby 2 compatible, and therefore these tests can be re-enabled
2014-07-15(maint) Remove deprecated `.to_not raise_error(args)` callsAdrien Thebo1-1/+1
From RSpec: DEPRECATION: `expect { }.not_to raise_error(SpecificErrorClass, message)` is deprecated. Use `expect { }.not_to raise_error` (with no args) instead. This commit removes all args from `.to_not raise_error` expectations.
2014-07-15(maint) Never require rspec/mocksAdrien Thebo1-1/+0
We use mocha for stubbing and mocking; requiring the rspec mocks as well will break things in RSpec 2.14.
2014-07-15(maint) Require rspec/mocks over deprecated spec/mocksAdrien Thebo1-1/+1
2014-07-08Merge branch 'ticket/master/PUP2889-eventlog'Rob Reynolds1-0/+38
* ticket/master/PUP2889-eventlog: (PUP-2889) Remove dependency on win32-eventlog constants
2014-07-07(maint) Don't try to set expectations on $CHILD_STATUSJosh Cooper1-14/+6
Previously, executing bundle exec rspec spec/unit/util/execution_spec.rb would fail on windows with an rspec error: unexpected invocation: nil.==(/error message/) The issue first appears in commit f41800a. I believe because before f41800a, facter would evaluate the certname fact, executing `hostname.exe` prior to executing the rspec example. As a result $CHILD_STATUS was never nil when the test executed. But starting in f41800a, $CHILD_STATUS may be nil as can be seen by the rspec output: expected exactly once, invoked once: nil.==(0) Since the object we are trying to set an expectation on is global and sometimes doesn't exist, this commit creates a private method for stubbing and setting expectations on the $CHILD_STATUS.exitstatus
2014-07-07(maint) Mark eventlog tests as conditionally pending on ruby 2Josh Cooper1-0/+1
Previously, the tests would fail on ruby2, because under ruby 2 we are using a newer win32-eventlog gem, whose constants are in a different namespace than the version of the gem we are using for ruby 1.9. This commit marks the tests as conditionally pending when running under Windows and ruby2. The tests will be re-enabled when PUP-2889 is implemented.
2014-07-07(PUP-2889) Remove dependency on win32-eventlog constantsJosh Cooper1-0/+38
Previously, we were referencing win32-eventlog constants. However, version 0.6.0 introduced a backwards incompatible change by renaming the event type constants[1]. As result, we can't simply upgrade to the latest ffi gem. This commit defines the constants in puppet, and removes our dependence on the gem. It also adds eventlog specs, in particular to ensure that Puppet.features.eventlog? is always true on windows. [1] https://github.com/djberg96/win32-eventlog/commit/99aeb4d854306a6db699550884f189cbd3c8928a
2014-07-03(PUP-1281) Simplify test for wide console behaviorJosh Cooper1-16/+8
Previously, we were verifying that stdout and stderr were wrapped in WideIO objects in ruby 1.9. However, this doesn't work in CI, because jenkins redirects stdout and stderr. This commit simplifies the test to not be as environmentally sensitive. It just verifies that the WideConsole and WideIO classes have been defined in ruby 1.x, and not defined in 2.x.
2014-07-03(PUP-1281) Ensure don't override stdout/stderr (windows/ruby2)Rob Reynolds1-3/+19
This provides a more deterministic set of specs that determine whether we have wrapped $stderr/$stdout or not based on ruby version.
2014-07-02Merge pull request #2797 from beergeek/fix_auth_proxy_issueAdrien Thebo1-1/+43
(PUP-2869) Puppet should support HTTP proxy authentication
2014-07-01(PUP-1281) Don't use win32console if ruby v2Rob Reynolds1-0/+12
Some of this work was done with PUP-2777 (support bundler workflow). That limits win32console down to being installed/depended upon only for ruby 1.x. This builds on top of that to only setup functions for colorizing output when using Ruby 1.x on Windows.
2014-07-02(PUP-2869) Puppet should support HTTP proxy authenticationbeergeek1-1/+43
Without this patch it is not possible to use the Puppet Module Tool (PMT) with an authenticated proxy. Many enterprises utilise the services of authenticated proxies for Internet access. Current code is able to utilise a proxy, but does not consider credentials for authenticated proxies. This patch uses the credentials from either the environment settings for HTTP_PROXY or http_proxy, or the corresponding values in the puppet.conf file. The patch allows for http_proxy_user and http_proxy_password to supplement the current http_proxy_host and http_proxy_port variables within the puppet.conf.
2014-06-26(PUP-2521) Don't use windows-pr constantsEthan J. Brown2-2/+2
- Somehow there were still some remaining constants referencing Windows:: which is part of windows-pr gem. Most are already defined locally as of the code being ported to FFI. Ensure that we use our internal constant definitions rather than those from gem: Puppet::Util::Windows::AccessControlEntry::CONTAINER_INHERIT_ACE Puppet::Util::Windows::AccessControlEntry::OBJECT_INHERIT_ACE Puppet::Util::Windows::AccessControlEntry::INHERIT_ONLY_ACE Puppet::Util::Windows::File::STANDARD_RIGHTS_ALL Puppet::Util::Windows::File::SPECIFIC_RIGHTS_ALL Puppet::Util::Windows::File::FILE_ALL_ACCESS Puppet::Util::Windows::File::FILE_GENERIC_READ Puppet::Util::Windows::File::FILE_GENERIC_EXECUTE - Add new constants to Puppet::Util::Windows::Error ERROR_FILE_NOT_FOUND ERROR_ACCESS_DENIED
2014-06-23(PUP-1283) win32-security gem raises a different exceptionJosh Cooper1-1/+1
Previously, puppet relied on win32-security version 0.1.4, which raised Win32::Security::SID::Error when it failed to resolve a name into a SID. Newer FFI versions of win32-security raise SystemCallError instead, which is a StandardError subclass. When trying to run the puppet agent against newer versions of the library, puppet reports: Uninitialized constant Win32::Security::SID::Error This commit changes the rescue to capture SystemCallError instead. This exception is defined in ruby 1.8.7 and up.
2014-06-23(PUP-2750) Fix aggregate profiler spec tests on windowsChris Price1-3/+3
It appears that on Windows, the precision of the Time object is not fine enough to guarantee that we'd get a non-zero value for the empty code blocks that we were timing in our tests. This commit simply adds a 10ms sleep to the tests to ensure that that enough time will have passed for us to be able to make an assertion that the elapsed time was greater than zero.
2014-06-23Merge pull request #2768 from ↵Henrik Lindberg5-28/+101
cprice404/feature/master/PUP-2750-support-hierarchical-profile-data (PUP-2750) Add hierarchical metric ids to profiler
2014-06-23(PUP-2750) Add hierarchical metric ids to profilerChris Price5-28/+101
This commit modifies the signature of the `Puppet::Util::Profiler.profile` method to accept a new argument, which is basically a "metric id". The argument takes the form of an array of strings/symbols, allowing us to group specific sets of profiling data into hierarchies and report aggregate profiling statistics at any level of the hierarchy. It also adds a new profiler, `Aggregate`, which extends the existing `WallClock` profiler. The new profiler tracks the aggregate timing data based on the metric id hierarchy, and logs a message containing the aggregate data at the end of the run.
2014-06-19(PUP-839) Remove SID mixin from SecurityEthan J. Brown2-16/+13
- SID methods can really standalone on their own, and should for the sake of sanity / code maintenance. Adjust all callsites (including specs) accordingly. - Make SID methods into static module_functions since they're already stateless
2014-06-18Merge branch 'ticket/master/PUP-2738-FFI-Memory-Issues'Rob Reynolds2-8/+12
* ticket/master/PUP-2738-FFI-Memory-Issues: (PUP-2738) Windows::File use FFI::Pointer helper (PUP-2738) Move CloseHandle -> FFI::WIN32 (PUP-2738) Windows utils appropriate return values (PUP-2738) Use block form of FFI::MemoryPointer (PUP-2738) Puppet::Util::Windows::Process FFI clean (PUP-2738) Puppet::Util::Windows::File FFI cleanup (PUP-2738) open_symlink should wide_string once (PUP-2738) Puppet::Util::Windows::User refactor (PUP-2738) FFI from_string_to_wide_string block (PUP-2738) FFI::Pointer#read_win32_local_pointer
2014-06-18(PUP-2738) Move CloseHandle -> FFI::WIN32Ethan J. Brown1-4/+4
- CloseHandle is an API used frequently, so move it to a shared definition inside FFI::WIN32. Remove extraneous definitions and update call sites.
2014-06-18(PUP-2738) FFI from_string_to_wide_string blockEthan J. Brown1-4/+8
- MemoryPointer from_string_to_wide_string previously allocated a new MemoryPointer instance but didn't force callers to scope / free it. This allowed the Ruby runtime to clean it up on GC, but we prefer to force callers to use a block form, to clean up the unmanaged memory when the variable is no longer needed. Refactor the method to yield the ptr. - Since the ptr is no longer valid after the block yields, return nil from the method
2014-06-16(PUP-2557) Issue deprecation warning for AST::Node inheritanceJosh Partlow1-0/+38
Puppet.deprecation_warning constructs an internal stack trace and is mostly useful for internal deprecation notices as opposed to notices of deprecation in Puppet manifests. Because of this, a regular warning was being used in its place for the node inheritance deprecation. But this would bypass limits on deprecation warnings and the ability to suppress deprecation warnings added in PUP-2650. This commit adds a puppet_deprecation_warning() which shares code now with deprecation_warning, and which traces to the file and line of the node's context. The AST::Node inheritance warning uses this method now.
2014-06-12Merge branch 'pr/2758'Andrew Parker5-34/+113
* pr/2758: (maint) Stop using ambiguous Manager name (PUP-2747) Add support for multiple profilers
2014-06-12(maint) Stop using ambiguous Manager nameAndrew Parker2-20/+16
Manager is not a very good name for a class. What does it manage? What does it mean to manage that? How does it manage? Who manages the manager? This renames the Profiler::Manager class to just Profiler::AroundProfiler because it modifies profilers to work so that they automatically go around a block. This is then the interface exposed by the Puppet::Util::Profiler singleton.
2014-06-11(PUP-2747) Add support for multiple profilersChris Price5-34/+117
This commit makes a slight modification to the profiling system, such that we can register multiple profilers at the same time. This allows callers to register their own profiler without worrying about collisions with profilers that might have been registered by other parts of the code.
2014-06-11Merge pull request #2721 from peterhuene/pup/2622Josh Partlow1-6/+10
(PUP-2622) Use non-zero exit codes for unknown subcommands.
2014-06-06(PUP-2656) FFI Puppet::Util::Windows::RegistryRob Reynolds1-6/+7
- FFI GetACP - Remove requirement on gem windows-pr by removing 'windows/national' - Moved require for windows/registry into windows platform specific - Added module definition to satisfy MSI/Windows Package
2014-06-04Merge branch 'stable'Adrien Thebo1-0/+6
Conflicts: lib/puppet/defaults.rb
2014-06-04(PUP-2650) Add disable_warnings settingAdrien Thebo1-0/+6
This commit adds a new setting that allows users to disable different classes of warnings. Right now the only supported type of warning that can be disabled is 'deprecations'.
2014-06-03Merge remote-tracking branch 'upstream/stable'Andrew Parker1-0/+31
* upstream/stable: (maint) Remove failure for empty generated tags (maint) Update test to use resource matcher (maint) Add sitemoduledir to env env tests (PUP-2689) Make AST Resource check tags against "inherited" tags (maint) Remove unused Puppet::Parser::AST::Tag class
2014-06-03(maint) Remove failure for empty generated tagsAndrew Parker1-2/+28
Commit 0436eb1e0997a6f19ea734923a1b82625a4034f8 added an extra failure condition for any generated tags that end up being empty strings. This was to get it to handle that the same way that it handles a simple empty string tag. However, this could break any installations that generate "::" separated tags that could create 4 ":" in a row ("a::::b"), and it also doesn't address enough of the odd tagging behavior to make it worth it. This commit reverts that change and adds some more tests to cover some more of the ways in which setting tags behaves.
2014-06-03(PUP-2622) Use non-zero exit codes for unknown subcommands.Peter Huene1-6/+10
Previously, if users execute 'puppet foo', an error message is displayed about unknown subcommand 'foo', but puppet still exits with a zero exit code indicating success. Additionally, if users execute 'puppet --option <valid_subcommand>', puppet silently ignores the option, prints a message, and exits with a zero exit code. As a result, a user accidentally transposed a valid option for a subcommand with the subcommand itself in an automated context and puppet did not report a failure. This commit fixes both conditions by exiting with 1 from the nil and unknown subcommands where appropriate. It also prints error messages using the same colorized output we use for usual puppet errors.
2014-05-30(PUP-2689) Make AST Resource check tags against "inherited" tagsHenrik Lindberg1-0/+5
This overrides the tagged? method in AST Resource to also search for tags in its containing resource. These tags will be set when the resource is finalized (just before serialization on transformation to external format). If this is not done, resources will have a different tag set when a search is made for the node itself (exported or virtual) vs. searching external resources. This also correct minor problems with passing an array (which could result in an array being set as a tag). It was also possible for empty tags to be set if a string tag contained multiple :: in sequence, or if ending with ::. Now an error is raised for these conditions (just like for empty segments generated by using a sequence of commas (which was on a different code path).
2014-05-28Merge branch 'ticket/master/PUP-1070-cleanup-invalid-lockfiles'Iristyle1-1/+37
* ticket/master/PUP-1070-cleanup-invalid-lockfiles: (PUP-1070) cleanup empty/invalid lockfiles
2014-05-28(PUP-1070) cleanup empty/invalid lockfilesJohan Haals1-1/+37
Currently lockfiles won't be cleaned up automatically if they're empty or contain non numeric characters. This commit solves this by verifying that the content of the lockfile contains a number or otherwise return nil which will result in deleting the pidfile.
2014-05-23(PUP-840) FFI Puppet::Util::ColorsEthan J. Brown1-14/+0
- Replace WriteConsole / WriteConsoleOutputCharacter calls with FFI equivalents - Remove string_encode function as it's no longer necessary and the test that was using it
2014-05-22(PUP-2554) FFI Puppet::Util::ADSIEthan J. Brown1-0/+7
- Convert ADSI GetComputerName to FFI - Add missing error handling for GetComputerName Win32 function - Add test that verifies GetComputerName returns a non-empty string - Add FFI MemoryPointer aliases for dwords Conflicts: spec/unit/util/windows/adsi_spec.rb