| Age | Commit message (Collapse) | Author | Files | Lines |
|
- Instead of trying to simulate a POSIX environment on the Windows for
the sake of tests against a provider that never runs on Windows,
exclude the tests when Puppet.features.posix? is not true.
- Given that these tests will no longer execute on Windows, the usage
of expand_path is no longer necessary, nor are any of the
Puppet.features.microsoft_windows? guards
|
|
The return type of Etc.getpwent (and friends) is available as
Etc::Passwd in ruby 1.9.3 and later. However that constant doesn't exist
in ruby 1.8.7. However the docs refer to the type as Struct::Passwd,
which turns out to be available on 1.8.7, 1.9.3, 2.0.0, and 2.1.0.
|
|
When the user parameter is specified, but it is the same as the current
user, there isn't any need to control the user when executing the
command. This adds a test in the posix provider for this shared
behavior. There don't appear to be many tests for how exec works at all.
|
|
The shell provider tests were creating an invalid configuration of
objects in order to test. The resource needs to be an instance of the
:exec type, not a Puppet::Resource.
|
|
This uses the mocha parameter matchers in the tests rather than a custom
with() block. This is a little shorter and should provide better error
messages when it fails.
|
|
The ProcessOutput class was lonely over in the puppet/process directory.
Not only did it have the wrong name, but it had no friends. This moves
it to Puppet::Util::Execution so that it can be with its friends and
also gives it some more documentation and a public tag so that others
can know how great it is.
|
|
This fixes the incorrect exitstatus being returned when a process
is run on Windows. There is an outstanding bug with Ruby
(https://bugs.ruby-lang.org/issues/8083) where it truncates the
exit codes to one byte values. Due to this an exit code of 3010
is currently truncated to 194.
Puppet accurately receives the exit code but was then ignoring
that and only returning the output. $CHILD_STATUS was then being
queried, and due to the aforementioned bug, was returning the
truncated return code. This means that anything above 256 would
be returned incorrectly.
This removes the private method Puppet::Util::SUIDManager.run_and_capture()
in favor of a more simplified call to Puppet::Util::Execution.execute().
This was done as run_and_capture was only being called by
Puppet::Provider::Exec.run(). This also removes the call to $CHILD_STATUS
which may clear up some other race conditions with capturing the proper
$CHILD_STATUS.
Paired with Andrew Parker <andy@puppetlabs.com>
|
|
Conflicts:
lib/puppet/provider/package/windows.rb
|
|
into stable"
Reverting as this should have been targeted at 3.4.0 (on master).
This reverts commit 1f3ea533b06ccf5188f5dd371da722e7c84dc904, reversing
changes made to f4c7e8b7a67ae5ae60b0be12b97f12b6c3673291.
|
|
Conflicts:
lib/puppet/provider/package/windows.rb
|
|
The ProcessOutput class was lonely over in the puppet/process directory.
Not only did it have the wrong name, but it had no friends. This moves
it to Puppet::Util::Execution so that it can be with its friends and
also gives it some more documentation and a public tag so that others
can know how great it is.
|
|
This fixes the incorrect exitstatus being returned when a process
is run on Windows. There is an outstanding bug with Ruby
(https://bugs.ruby-lang.org/issues/8083) where it truncates the
exit codes to one byte values. Due to this an exit code of 3010
is currently truncated to 194.
Puppet accurately receives the exit code but was then ignoring
that and only returning the output. $CHILD_STATUS was then being
queried, and due to the aforementioned bug, was returning the
truncated return code. This means that anything above 256 would
be returned incorrectly.
This removes the private method Puppet::Util::SUIDManager.run_and_capture()
in favor of a more simplified call to Puppet::Util::Execution.execute().
This was done as run_and_capture was only being called by
Puppet::Provider::Exec.run(). This also removes the call to $CHILD_STATUS
which may clear up some other race conditions with capturing the proper
$CHILD_STATUS.
Paired with Andrew Parker <andy@puppetlabs.com>
|
|
Setting a umask value for execs can be useful when the exec creates files or directories. Relying on the sytem umask can produce unexected results as it may be different from system to system or just not what the user intends..
|
|
When running the tests on Windows and Ruby 1.8.7, File.executable?
returns true on regardless of the file extension. On Ruby 1.9, it only
returns true if the extension is .exe or similar.
This commit ensures the "executable" ends with .exe.
|
|
This test was setting path to /bin with the assumption that it didn't
contain cd, and therefore the only cd would be a shell built-in. On
system which *do* contain /bin/cd, this was failing. Now we just use a
bogus path so this will work everywhere.
|
|
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,'
|
|
* 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.
|
|
Conflicts:
lib/puppet/parser/functions/shellquote.rb
lib/puppet/type/package.rb
spec/integration/util/file_locking_spec.rb
spec/unit/parser/functions/shellquote_spec.rb
spec/unit/util/command_line_spec.rb
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
The posix specs were creating executable files in /tmp, which caused a warning
about an insecure directory in the path. This adds an intermediate safe
directory.
|
|
Previous merge from 3.x to master updated the locales incorrectly and
overwrote a change for solaris specs (#15547) : validate locales as
sentinel #43d86d40570140918009f2048f8998fb2200f81f. This update corrects
it.
|
|
The merge from 3.x to master had an incorrect change that caused the
test to fail. I had forgotten to run the tests before pushing and didn't
notice until it got to CI. This commit just undoes the one incorrect
change.
|
|
* upstream/3.x: (27 commits)
Replace "the short version" with outline
(#15547) mock of facter :operatingsystem pending
(#15595) Improve message on SSL errors
(#15595) Clear up tests around ssl errors
use error_message instead of error
updates as requested
(#15595) Offer better errors for certificate validation errors
Update CONTRIBUTING.md
(Maint) Remove some more ambiguity
Use rspec 2.11 compatible block syntax
Revert "Merge branch 'fixpid' of https://github.com/vrthra/puppet into 3.x"
Make 3.x specs compatible with rspec 2.11
(#15676) Fix puppet module face SSL acceptance tests to use masters real hostname
wip
Revert "Merge branch 'non-string-resource-titles' of https://github.com/nicklewis/puppet into 3.x"
Fix buggy resource title tests
Use rspec 2.11 compatible block syntax
(Maint) Be more honest about submission methods
(Maint) Clarify that Redmine tickets are mandatory
(Maint) Clarify which branches changes should be based on
...
Conflicts:
spec/unit/provider/exec/posix_spec.rb
|
|
Using spurious values for LC_ALL and LANG values in solaris causes
some commands to barf. Since we are only checking for overrides, we
can aswell use a valid locale.
|
|
solaris has /bin/cd as a command to ensure posix compatibility. So
we need to avoid using '/bin' in path if we want to ensure that we
are looking at shell builtin cd.
|
|
Fixes #15467
|
|
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.
|
|
This manually fixes up a pile of Puppet Module Tool conflicts by hand, related
to overlapping changes with nothing but textual translation. The rest of the
merge was smooth and simple.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
The `shell` exec provider was supposed to emulate the behaviour of 0.25 exec,
which was to pass the content through the default shell to get it executed.
Unfortunately, it got quoting a bit wrong, and ended up interpolating
variables at the wrong point - it used double quotes where single quotes were
really what was desired.
Thanks to Matthew Byng-Maddick for the report, and a fix to the quoting; in
the end we should not be in this position - we shouldn't be using string
execution where we can pass an array instead. That avoids any chance that
there is more than one round of shell interpolation entirely.
As a bonus, this fixes the base exec type to support specifying the command to
run that very way, and making it good.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
This just whips the content up to the modern standard for tests.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
* 2.7.x:
(maint) Remove unnecessary step from puppet module build help
(#13659) Convert fact values to string when searching database
(#13649) Restrict module name matching
(#13643) Make the use of FileUtils.rm_rf secure
(#13642) Move search notice message
(#13639) Don't send errors directly to stderr
(#13638) Add SemVer#pre function
(#3581) Stop forking around: Add fork helper method
(#13397) fix gem provider ensure=>latest bug
(#12101) Make Puppet::Util::absolute_path? usable in autoloader
(#12101) Add shared context for specs to imitate windows or posix
Conflicts:
lib/puppet/util.rb
spec/unit/util_spec.rb
|
|
Add "windows" and "posix" shared contexts to rspec. If you give :as_platform
=> :posix or :as_platform => :windows as argument to a describe block, it will
automatically stub the relevant facts and path behavior to imitate windows or
posix.
|
|
|
|
There are still deprecated stubs for execpipe, execfail, and execute in Puppet::Util for backwards compatibility. rspecs are all passing, but would still like to go through and check for deprecation warnings that were triggered by this changeset (and fix them, obviously).
get spec tests running against Puppet::Util -> Util::Execution refactor
|
|
|
|
This bug report was related to the fact that you may end up with very different values for environment variables such as "HOME", "USER", "LOGNAME" depending on how you start puppet (at boot time, via "service", via /etc/init.d, etc.). These variations can have an effect on the behavior of programs / services that are launched by puppet, particularly those that are triggered via Exec resources. Change the behavior such that these environment variables are simply unset by puppet prior to executing commands.
|
|
Previously, the daemon and execute_posix spec tests were failing on
Windows, but this functionality is not supported on Windows, and so
the tests are skipped on Windows.
|
|
Puppet::Util.execute_posix contained some code that would override some locale-related environment variables in order to force the command being executed to produce well-known, consistent, predictably formatted output so that it could be parsed. However, there are some cases (such as a user-defined "exec" block) where we need to respect the system/user locale settings. Add a boolean parameter to the Puppet::Util.execute method that allows toggling this locale override behavior.
The "exec" provider now passes "false" for this value, meaning that we no longer override the locale for user-defined "exec" resources. Users may choose to override the locale themselves by specifying the appropriate locale-related vars in the "environment" section of their resource.
All of this is ignored on windows at the moment, but the parameter is passed in to "execute", which is responsible for calling "execute_windows" on windows systems. We could decide to do something with this parameter on windows at some point in the future.
|
|
This reverts commit edc544d73bc8f9f7de07de4b30e344d1f4db3178.
This doesn't work with rspec < 2.6.0 and it's breaking continuous integration.
|
|
Add "windows" and "posix" shared contexts to rspec. If you give :as_platform
=> :posix or :as_platform => :windows as argument to a describe block, it will
automatically stub the relevant facts and path behavior to imitate windows or
posix.
|
|
These specs were trying to stub the microsoft_windows feature to enable
the Windows exec provider for the test. However, the Windows provider
was changed in ad98d47 to use the operatingsystem fact for its confine,
rather than the feature, so these failed. This changes them to also stub
the operatingsystem fact.
Reviewed-by: Josh Cooper <josh@puppetlabs.com>
|
|
Previously, the Windows exec provider had incorrect logic for
resolving an executable using a hard-coded list of extensions,
e.g. '.cmd' wasn't in the list.
Recently, Puppet::Util.which was modified to perform path resolution
taking into account the PATHEXT environment variable on Windows. See
0258096c474d1b2cbf7e403fc990a853ac277231. As a result, the duplicate
logic in the Windows exec provider has been removed.
|
|
The provider/exec/windows_spec.rb spec was creating exec resources
explicitly using the Windows provider as the provider. The Windows
provider was being evaluated as suitable and thus the default provider
for the type. Then in future specs, it could be used since it was the
default, even though it wasn't necessarily suitable, causing failures.
Now, we just clear the defaultprovider on the exec type after all the
specs in the file have finished, ensuring it will be recalculated
appropriately when needed.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
|
|
This provider inherits from the Puppet::Provider::Exec class, and is
very similar to the posix provider in its behavior. This provider
doesn't have the ability to run as a particular user or group and will
fail if that is attempted, but does support setting all other
parameters, as well as autorequires.
|
|
Rather than the shell provider inheriting from the posix provider, they
both now inherit from a common Puppet::Provider::Exec class. This new
base class and inheritance structure will allow the forthcoming windows
provider to also inherit from that class, rather than from the
unsuitable posix provider.
Also, now that Puppet::Util.execute supports commands as strings in
addition to arrays, the command to execute is passed to
Puppet::Util::SUIDManager.run_and_capture as a string, rather than a
string wrapped in an array. This ensures we will never improperly quote
a command with arguments provided as a single string.
|
|
These specs were assuming that paths such as /foo were always absolute, which
is not the case on Windows. Thus, when run on Windows, the provider was
complaining about receiving relative paths when it expected absolute, rather
than succeeding or failing in the intended way. Now we expand all paths we want
to be absolute, to guarantee they will be absolute everywhere.
Also, some specs were failing because they were trying to test the case where a
file isn't executable. That's not something we can reliably check on Windows,
so instead just stub the appropriate executable? methods.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
(cherry picked from commit e9b558dd35eec6e221aef9de3f300a5843347454)
|
|
Because this provider only applies when the posix feature is present (and thus
not the windows feature), it can never be used on Windows. Thus, the
Windows-specific command handling is unnecessary and unused.
Also added more specific error messages for the cases where a command doesn't
exist, isn't a file, and isn't executable. These only apply when the command
path is absolute (otherwise the message is simply command not found).
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
(cherry picked from commit b28bcb031346cfd2026361ec5ffb420c1dcf60d7)
Conflicts:
spec/unit/provider/exec/posix_spec.rb
|
|
The mount, shell, and ssh_authorized_key types are not supported on
Windows, so these spec tests have been disabled when running on
Windows.
One of the compiler spec tests fails on Windows because
Puppet::Util.execute attempts to execute a program named "git rev-parse
HEAD". This has different semantics than Unix, where the command is
splatted, Kernel.exec(*command). Since this truly is a Windows bug, I
removed the fails_on_windows tag and updated ticket #8410.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit d9ce88d10707268fe41c8f3ad1166137fe8e202f)
|
|
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
|
|
These specs were assuming that paths such as /foo were always absolute, which
is not the case on Windows. Thus, when run on Windows, the provider was
complaining about receiving relative paths when it expected absolute, rather
than succeeding or failing in the intended way. Now we expand all paths we want
to be absolute, to guarantee they will be absolute everywhere.
Also, some specs were failing because they were trying to test the case where a
file isn't executable. That's not something we can reliably check on Windows,
so instead just stub the appropriate executable? methods.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
|