maint: relax spec test of resources

The resource_spec performs some comparisons by using the equal_attributes_of
matcher. This is mostly correct, but considers some instance variables that are
of no consequence to the resource, e.g. @rstype. As a result, internal changes
to Puppet::Resource that may lead to this attribute not being set in a resource
that is generated from YAML would break this expectation:

expected
Foo::Bar[xyzzy]{:name=>"xyzzy", :one=>"test", :two=>"other"}
to equal attributes of
Foo::Bar[xyzzy]{:name=>"xyzzy", :one=>"test", :two=>"other"}

This is not only difficult to debug, it first and foremost misses the intention
of the example, which is only concerned with RAL attributes, not "internal"
instance variables.
(PUP-1381) issue warnings to current users of cron purging

A behavioral fix is planned for the 4.0 release. The final
3.x point releases should issue early warnings to users who employ
the functionality that is about to change.
(PUP-1381) make file_setting spec test more robust

A new call to self.resource_type in Puppet::Resource#initialize can cause
the loading of type code as a side effect. This interfered with the mocking
for the test

Puppet::Settings::FileSetting when being converted to a resource
should manage existent files even if 'create_files' is not enabled

Add a stubs call to one of the uncritical expectations so that
additional calls are not considered as spurious.
(PUP-1843) Restore hiera indirector terminus

This was collapsed into the DataBindings code in 9a5b81b412. That broke
community plugins using this code. This commit just restores the code
but doesn't revert the other changes from that commit.
(PUP-2298) add resource lifecycle method Puppet::Type#pre_run_check

In order to deprecate the builtin defined function (which is often abused
to work around resource duplication among modules) it is desirable to
add resource constraints to the language. An easy approach to allowing such
constraints to work is to add them as a special resource type that does not
take effect during the transaction, but fails the whole catalog in case of
validation failure.

To make this possible, add a new method #pre_run_check to the Type base class
for overriding in appropriate resource types (such as constraint).

The semantics is simply
- raise nothing if the pre-run check is succesful
- raise a Puppet::Error otherwise

The check is performed during evaluation of the transaction, just before
the catalog is applied. The generating of additional resources should be
complete when this is done (because the hook is meant to be able to
check the whole catalog for consistency).
(PUP-2298) protect transaction spec test against new exceptions

The new perform_pre_run_checks method in the transaction loops over
all resources in the catalog. This is prone to failures if any nil references
end up in the catalog. This can happen during the addition of resources
to the catalog under test conditions, because the mock resources are not
sufficiently contained.

To work around this effect, stub the very #container_of method in the mock
catalog so that all resources will have an apparent container.
(PUP-867) Remove support for dynamic defaults for future parser

WHen future parser is in effect, the lookup of default values
will now not look in "parent scopes" (i.e. scopes that *contain*
the resource). Instead it now only looks in inherited and enclosing
scopes + itself.

This removes the confusion that occurs when a class may be included
from different locations, and the location that wins manages to impose
the defaults from its scope. 

This removal goes hand in hand with dynamic scoping being removed
everywhere else.
(PUP-2632) Make Type be subtype of Object

Without this change, a reference to "any" must be written
Optional[Variant[Type, Object]] which is quite horrible.
There is no harm in making Type an Object since that is the most
abstract type as seen from the Puppet Programming Language.
(PUP-2314) Make assert_type handle lambda and user handling

This adds the ability to handle a Callable as the value, as well
as supporting a lambda that takes over the built in raising of
an error. This means that assert_type can be customized to fail
with special message, or to issue a warning and use a default.

assert_type(String, 1) |$expected, $actual| {
  warning("a $actual is not a $expected")
  "Free Beer, is the default"
}
(packaging) Update PUPPETVERSION to 3.6.1
Merge branch 'stable'

* stable:
  (packaging) Update PUPPETVERSION to 3.6.1
(PUP-2642) Make default in selector be out of band, raise error nomatch

This makes the selector expression in the future evaluator have
the same semantics as the 3.6.1 current evaluator. The future evauator
did not process default out of band, and did not raise an error when
there was no match.

This fixes both problems.
(PUP-836) FFI Puppet::Util::Windows::User

 - LogonUserW, LoadUserProfile, UnloadUserProfile and PROFILEINFO
   have been converted from manually packing params with Win32API.new to
   automatically managed with FFI definitions.
 - Use MemoryPointer where appropriate.
 - Note that wide character LogonUserW is used rather than platform
   varying LogonUser as FFI is unable to use that.  The pointer
   widths of PROFILEINFO vary depending on platform, which is handled
   by using :pointer.  With LogonUserW the string pointed to is always
   wide character, which is properly handled by using wide_string.
 - Add FFI::MemoryPointer helper read_handle
 - Add FFI::MemoryPointer.from_wide_string and corresponding tests that
   ensure that a properly terminated UTF-16LE string is passed in
 - Add FFI::MemoryPointer#read_wide_string that reads a wide string buffer
   into a Ruby string with Encoding.default_external and corresponding tests
 - Add additional tests around User methods that make native Win32 API calls
   that will intentionally fail
 - Fix wide_string helper to return nil when given nil so that can be passed
   directly to Win32 as a null pointer
(PUP-836) FFI Puppet::Util::Windows::User

 - Remove dependence on Win32 API calls defined in the win32-security
   gem, including CreateWellKnownSid, IsValidSid, CheckTokenMembership
 - These calls have all been FFI'd accordingly
 - Add FFI::MemoryPointer helper read_bool
(PUP-836) Remove Win32::Security.elevated_security

 - Refactor Puppet::Util::Windows::Process to implement new method
   elevated_security? that was in win32-security gem
 - Refactor get_token_information to return an FFI::MemoryPointer buffer
   instead of a parsed structure, since GetTokenInformation is a generic
   call that can return many structure types, including TOKEN_ELEVATION.
 - Remove any reliance on win32-security gem from user.rb
 - Adjust tests accordingly
Merge pull request #2675 from Iristyle/ticket/master/PUP-836-FFI-Windows-User

(PUP-836) FFI Puppet::Util::Windows::User
(PUP-2544) Util::ADSI -> Util::Windows::ADSI

 - Move Windows ADSI code out of puppet/util and into
   puppet/util/windows
 - Update namespace from Puppet::Util::ADSI to
   Puppet::Util::Windows::ADSI
 - Add module / class definitions for ADSI to util/windows.rb
   to prevent tests from blowing up on non-Windows
 - Moving Puppet.features.microsoft_windows? checks to top of
   user and group provider tests for ADSI
 - Update all dependent code, remove unnecessary references
(PUP-2554) FFI Puppet::Util::ADSI

 - 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
Merge branch 'pr/2677'

* pr/2677:
  (PUP-2554) FFI Puppet::Util::ADSI
  (PUP-2544) Util::ADSI -> Util::Windows::ADSI

Closes GH-2677
Merge pull request #2687 from hlindberg/PUP-2642_selector-default-out-of-band

(PUP-2642) Make default in selector be out of band, raise error nomatch