(maint) Fix acceptance test for scheduled_task deletion

This test was accidentally checking that the scheduled task was still in
place in the Windows scheduled task list. Because the
Win32::TaskScheduler#delete call seems to be asynchronous, as long as
the test for scheduled task happened fast enough, it was still seen as
present and the test 'passed'.  In fact, puppet resource was scheduling
the task to be removed, and it does get removed.  This test began to fail
when the vms slowed down enough that the broken verification step began
to fail because it was no longer executing fast enough to see the
transient task prior to its deletion completing.

This change corrects the verification step to verify by asserting that
the schtasks.exe list command failed (did not show the deleted task).
And it wraps it in a timeout to allow it a few seconds for the scheduled
tasks state to finalize.
(maint) Correct documentation of each function

The documentation of the each function used deprecated syntax.
PUP-1322 Do not fail hard on unparseable files
Merge pull request #2256 from jpartlow/maint/stable/fix-scheduled-task-delete-acceptance

(maint) Fix acceptance test for scheduled_task deletion
(PUP-1389) Ensure wide strings have double null terminators

It seems that calling String#encode('UTF-16LE') sometimes adds only a single
NULL terminator in both ruby 1.9 and 2.0 on Windows. However, a wide string
is supposed to have two NULL terminators.

For reasons unknown, versions prior to 2012 seem to accept wide strings with
only a single NULL terminator, but in 2012 and 2012R2 the string is often times
contains a non-zero high byte, which causes Windows to read past the single
terminator, and attempt to access a path that does not exist.
(PUP-1389) ReplaceFile to FFI / move wide_string

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>
(PUP-1389) Simplify logic for appending extra NULL

This commit simplifies the process for appending a NULL terminator to
the wide string.
Merge branch 'pr/2261' into stable

* 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
(PUP-1118) Fetch the environment's manifest & modulepath at init

After trying to get the manifest and modulepath during the
initialization for an environment, it turned out that a lot of other
things depended on a very specific load order. Some of those needed to
change around, others needed to delay executing until later, after
everything had been loaded and initialized (creation of the root
environment was one of these). The reset of the Parser::Functions also
moved so that it doesn't happen until settings have been initialized.
(#23316) Update yum package provider support :holdable

This commit adds support for the `holdable` package feature to the yum
package provider. If the yum versionlock plugin is available packages
can specify an ensure value of 'held' and the yum provider will use the
versionlock plugin to lock the version.

This feature has the caveat that it can only be enabled at provider load
time since provider features cannot be enabled based on a code block.
(PUP-1432) Add V2 API structured errors.

This commit introduces error responses, a JSON object as described
in the api documentation (with associated schema).

It introduces the Puppet::Network::HTTP::Issues module, which collects
the known issue_kind values, in order to ensure consistency and provide
ability to yardoc them.

It adds two HTTPError subclasses for future use: an HTTPBadRequestError
(400 response), and an HTTPServerError class. The HTTPServerError
allows the API to provide more information about an unexpected error
than simply letting the error bubble up to be caught by the generic
HTTP handler.
(PUP-1432) Move JSON error ser8n to error classes

Rather than serializing in the generic HTTP handler.
(PUP-1432) Fix error JSON schema

The type of the items in the stacktrace array was not correctly
specified.
(PUP-1432) Add error spec that tests serialization
(PUP-1282) Express Windows specific gem dependencies

Previously, if a ruby module on windows tried to use puppet as a
library, the calling module had to know about puppet's platform specific
dependencies. This comes up when trying to develop and test puppet
modules on windows.

This commit adds the windows specific gems to project_data.yaml, and
updates the Gemfile to add these dependencies when during
bundle install

The build pipeline will automatically create an x86-mingw32 gem in
addition to the generic one.
(PUP-1118) Introduce "create" to make specific environments

Environments are more than just a name, they are also a modulepath and a
manifest. This commit makes a "create" method for setting up
environments with specific modulepaths and manifests rather than relying
on the Puppet Settings at the time that methods are called. In order to
control environments for module installation they now take advantage of
this in order to control the modulepath that things will be installed
into.
(PUP-1118) Provide context at initialization for environments

When puppet is initialized it now also sets up a environments service so
that other parts of the code and go about their merry way.

This also changes the handling of component to work the same way as
other types so that an extra, and confusing, require isn't needed.
(PUP-1448) Validates the user type shell property

Adds the feature :manages_shell to the user type and asserts that
providers manipulating the shell property must have this feature.  The
useradd provider is then patched to specifically check that the shell
property is valid (file exists and is executable).  Other providers
which use shell (user/aix, user/directory_service, user/ldap, user/pw)
have the :manages_shell feature added to ensure that they continue to
function, but no additional validation is performed.

Rebased to a more recent master from Alejandro Ramirez's PR
https://github.com/puppetlabs/puppet/pull/1942
(Commits squashed)
(Maint) Alias TESTS as TEST

Sometimes we type one, sometimes the other. Just make them aliases.
(PUP-1389) Embed the extra NULL within the string

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.