(#22878) Scope call to CloseHandle

Previously, the win32-process gem used to extend Windows::Handle from the
windows-pr gem, so that the Process.CloseHandle method was available.
However, newer versions of the win32-process gem that are based on ffi, do
not extend Windows::Handle, so the Process.CloseHandle method is not defined.

This commit modifies puppet to call a version of CloseHandle which we
control, and therefore is guaranteed to exist.
Merge branch 'ticket/stable/22878-close-handle' into stable

* ticket/stable/22878-close-handle:
  (#22878) Scope call to CloseHandle
(#22925) Fall back to cached catalog if we can't connect to the master

Prior to commit 093a0745b4, puppet would attempt to download a catalog, and if
that failed, it would apply a previously cached catalog. Note this
behavior is controlled by the `usecacheonfailure` setting, which is
disabled when using `--test`.

In commit 093a0745b4, the ENC was made authoritative for specifying node
environment. In doing so, the agent makes a REST call to the master for
its Node object, and then reads the environment from it.

However, the call is made in a begin/rescue block that only catches
Puppet::Error and Net::HTTPErrors, but not errors like
Errno::ECONNREFUSED, etc.

This commit ensures that any standard error will be caught when
retrieving the node's environment, as is done when retrieving the
catalog. If we fail to obtain the node's environment, we warn, and
continue trying to apply the catalog.

This commit does not try to fix consistency issues between the node and
catalog requests. For example, the node request could fail, resulting in
the agent requesting a catalog using its agent-configured environment.
The catalog request could succeed, resulting in the agent applying a
catalog from an environment that doesn't match what the ENC thinks it
should be.
(maint) Fix acceptance harness and tests for windows vcloud templates

Changes the git/pre-suite environment setup step to rely on the
puppet-win32-ruby repo for a windows specific build of ruby with the
gems we require.  Currently we are copying this directly into /bin and
/lib and resetting /lib/ruby for full permissions.  This is ugly, but
Josh and I were having trouble setting PATH in a global way through
Beaker.

This patch also fixes a win2008 bug in tests/ticket_15560_managehome.rb,
which I believe we never hit before because we have only been testing
aginst win2003, clears up a problem in the
resource/scheduled_task/should_query.rb being unable to run against
multiple agents, and patches the sslv2_downgrade_agent test to absorb
exit code 28 (timeouts) from the curl test, which are probably cropping
up occasionally on slow vms.  Kylo applied a similar fix for the 2.7.x
branch fa1e8e0
Merge pull request #2029 from jpartlow/maint/stable/acceptance-fixes-for-windows-vcloud

(maint) Fix acceptance harness and tests for windows vcloud templates
Merge remote-tracking branch 'upstream/stable'

* upstream/stable:
  (maint) Fix acceptance harness and tests for windows vcloud templates
  (#22878) Scope call to CloseHandle
Merge pull request #2031 from joshcooper/ticket/master/22925-cached-catalogs

(#22925) Fall back to cached catalog if we can't connect to the master
(#23081) Ensure that errors from insync? create proper events
(Maint) Reorder and reduce scope of harness

This makes non-public methods explicitly private. It also reorders the
methods to read in a manner where the top is the public and highest
level, and it becomes more low level as we move down the file.
(#23801) Add unit tests for insync? raising StandardError or Exception
(maint) Remove large spec test block whose benefits were unclear.

This changes removes a large block of unit tests, comprising
1296 individual tests built up via 8 nested 'each' loops. Why
remove so many tests?

First, in the course of refactoring for #23081 we triggered
test failures in this block only when we also triggered a test
failure elsewhere, and conversely, it didn't trigger failures
where other individual tests did register a useful failure.

Second, several people have stared at this unit test block
and not been able to figure out what it is uniquely testing.

So in short the value of this test block is not clear, so we're
removing it.  Of course, if we hit future gaps in unit test coverage,
we'll add tests back in to cover gaps.
(maint) Remove an unimplemented test and fix up some comments.
Merge pull request #2036 from kylog/issue/23081/report-property-event-for-insync-exceptions

Issue/23081/report property event for insync exceptions
(Maint) Small cleanups

Just a simple typo fix and re-expanding some blocks to make adding in
debugging easier at a later date.(Maint) Small cleanups
Merge branch 'hlindberg-feature/master/allow-rebuild-of-inventory'

* hlindberg-feature/master/allow-rebuild-of-inventory:
  (Maint) Small cleanups
  (#23074) Remove overly stubbed tests
  (#23074) Refactor cert application's use of cert authority's interface
  (#23074) Make cert inventory not rebuild inventory.txt when adding
  (#23074) Remove header in inventory.txt when regenerating
  (#23074) Cleanup logic
  (#23074) Add text to warn that master should be inactive for reinventory.
  (#23074) Add reinventory command to puppet cert

Closes GH-2032
(maint) Document Puppet::SSL::CertificateRequest#generate
Merge branch 'maint-document-csr-generate'
(#21874) Make name[x] different from name [x]

The parser cannot differentiate between a call of function 'name' with
array as argument from deprecated resource reference (e.g. file['foo'])
since whitespace is not significant.

This is fixed by letting the lexer generate a separate token for a
LBRACK when it is preceded by a NAME and WS.