Add additional commits to CHANGELOG missed in 2.7.19rc1
Use Win32 API atomic replace in `replace_file`

The changes to enable Windows support in `replace_file` were not actually
complete, and it didn't work when the file didn't exist - because of
limitations of the emulation done on our side, rather than anything else.

Windows has a bunch of quirks, and Ruby doesn't actually abstract over the
underlying platform a great deal.  We can use the Windows API ReplaceFile, and
MoveFileEx, to achieve the desired behaviour though.

This adds even more conditional code inside the `replace_file` method to
handle multiple platforms - but it really isn't very clean.  Better to get
this working now, then refactor, though.

Cherry pick of: 73e302bbf5ab4a6c5513a39070e2c907542775ae

Conflicts:

	lib/puppet/util.rb
	spec/unit/util_spec.rb
(#15471) Ensure non-root can read report summary

The security fix for locking down the last_run_report, which contains
sensitive information, also locked down the last_run_summary, which does
not contain sensitive information. Unfortunately this file is often used
by monitoring systems so that they can track puppet runs. Since the
agent runs as root and the monitoring systems do not, this caused the
summary to become unreadable by the monitoring systems.

This commit returns the summary to being world readable which undoes
part of the change done in fd44bf5e6d0d360f6a493d663b653c121fa83c3f
(#15471) Fix setting mode of last_run_summary

The writlock function didn't work with setting the mode on the
last_run_summary file. This backports some of the work in commit
7d8fd144949f21eff924602c2a6b7f130f1c0b69. Specifically, the changes
from using writelock to replace_file for saving the summary file. This
builds on top of the backport of getting replace_file to work on
windows.
Merge remote-tracking branch 'andy/ticket/2.7rc/15471_last_run_report_only_readable_by_root' into 2.7rc

* andy/ticket/2.7rc/15471_last_run_report_only_readable_by_root:
  (#15471) Fix setting mode of last_run_summary
  (#15471) Ensure non-root can read report summary
  Use Win32 API atomic replace in `replace_file`
Merge remote-tracking branch 'upstream/2.7rc' into 2.7.x

* upstream/2.7rc:
  (#15471) Fix setting mode of last_run_summary
  (#15471) Ensure non-root can read report summary
  Use Win32 API atomic replace in `replace_file`
  Add additional commits to CHANGELOG missed in 2.7.19rc1
Update CHANGELOG, conf/redhat/puppet.spec for 2.7.19rc2
Merge branch '2.7rc' into 2.7.x
Don't mask NoMethodErrors

This rescue was masking a bug in a provider (involving calling `[]` on
`nil.NilClass`) with a misleading error message.  The new code asks
permission rather than begging forgiveness, but is more specific to the
problem being detected.
(#10915) Fix tests to work with new parameter checking

The change to how the property checks if the provider can be called
caused several tests to fail because they were not using providers that
were able to properly report `respond_to?`. This fixes those tests. In
the case of the host_spec.rb I was able to convert away from a mock, but
in the mount_spec.rb the mock had to mock `respond_to?` since the
interaction with the provider seems to be more complicated than I can
unravel.
(#10915) Add test for provider throwing NoMethodError
Merge branch 'bug/2.7.x/10915-misleading-error-messages' into 2.7.x

* bug/2.7.x/10915-misleading-error-messages:
  (#10915) Add test for provider throwing NoMethodError
  (#10915) Fix tests to work with new parameter checking
  Don't mask NoMethodErrors
(#14515) Tests fail with mocha 0.11.4

Prior to this commit, these tests only worked with mocha 0.10.5 because
the tests were broken and trying to stub methods on nil, which mocha
0.11.4 no longer allows. After this commit, these tests work with both
mocha 0.10.5 and 0.11.4.
Fix stubbing on nil in some specs
Don't require mocha in spec_helper

Rspec will automatically require mocha, and it knows how to do it properly
depending on the mocha version. This eliminates spurious deprecation warnings
about how mocha is loaded.
Rename specs to end in _spec.rb
Avoid stubbing Thread::new due to issues in newer mocha

In mocha >= 0.11.0, unstubbing a method is done by defining a method that
calls the original method. Somehow this indirection causes issues when
Thread::new is stubbed, and the new thread does not have proper access to
local variables. This patch fixes this from both ends, by not stubbing
Thread::new and not using local variables in the test that was failing.
Check that function loading worked correctly.

In some odd circumstances - typically, just development errors - you can wind
up in a world where a function correctly loads but isn't available.

This ensures that the method is defined as expected and raises a clear, quick
error if not. The alternative is an unclear stack overflow raised because we
recurse forever through method_missing.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>

Conflicts:
	lib/puppet/parser/scope.rb
Clear Environment.current when calling Environment.clear

This makes Puppet::Node::Environment::clear properly clear all the environment
state. This reduces dependencies between tests due to leaked state. It also
moves the call to clear to happen before each test. This avoids issues where
tests set up stubs on settings, as the after block is called before stubs are
removed.
Add Puppet::Parser::Functions::clear for specs

Since functions uses class instance variables to track which functions are
loaded, we need to clear this between tests.