Deprecate sending YAML over the network

I'm not sure if this covers all the corners. I didn't want to do it in the
Format itself because that can be used in other places.
(#21427) Send facts to master as pson

This changes the format of facts being sent to the master from
b64_zlib_yaml (base 64 encoded compressed yaml) to pson, in preparation
for deprecating all YAML sent over the network. This should be backwards
compatible as facts are tagged with the format and the master already
supports pson.
(#21427) Issue deprecation warning for b64_zlib_yaml
(#21427) Improve deprecation warning for yaml params

Previously we were not informed what parameter and value was being
transmitted as YAML, which made debugging and correcting the problem
nearly impossible. This outputs the offending request parameter and
value as a debug message to aid in fixing the issue.
(#20607) support symbolic file mode in Puppet::Util#replace_file

In order to fix #20607 (where incorrect 'settings specified' file
permissions were crashing P::U#replace_file), this patch enhance
P::U#replace_file default_mode behavior.

Now P::U#replace_file supports symbolic file mode, along with
octal numerical string, and pure octal integers. It also now fails
if the given mode is incorrect.

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
(Maint) Cleanup do_save specs

This replaces the excessive mocking in the do_save specs with using
actual implementations and removes mocking on the class under test. By
doing so there are many fewer tests required and the remaining tests are
more directly related to externally observable behavior. This has only
been done for the do_save method.
(maint) Includes missing spec_helper in three specs.

spec/spec_helper was missing from three of the specs. This showed up
because spec/unit/pops/containment_spec.rb just happened to come first
in the order of specs to be executed on our Solaris build, and began
causing failures because puppet/pops was being loaded prior to
spec_helper and puppet.  It was also causing rspec/mocha setup and
teardown failures, presumably because of rspec configuration being
called after this initial spec was loaded.

This commit ensures that each of these specs requires spec_helper first
so that spec and the puppet environment initialize properly regardless
of whether these specs run first or come later in the spec ordering.
(#21427) Respect Accept header for save

The REST save action will now respect the formats that are requested in
the Accept header. In order to retain backwards compatibility for
clients that have never been required to specify an Accept before this
it will also default to :yaml when no Accept is provided. If an Accept
is provided but none of the wanted formats are suitable an error is
raised, just like find and search.

In order to report the status of an unkown Accept header correctly this
also adds the capability of raising web related exceptions that contain
the HTTP response code that needs to be used.
(#21427) Respect Accept header for destroy

The REST destroy action will now respect the formats that are requested in
the Accept header. In order to retain backwards compatibility for
clients that have never been required to specify an Accept before this
it will also default to :yaml when no Accept is provided. If an Accept
is provided but none of the wanted formats are suitable an error is
raised, just like find and search.
(#21427) Remove duplicate handling of accept headers

When the save and destroy actions started respecting the accept header
we duplicated how accept headers were handled for selecting the response
format. This removes that duplication and in putting specific tests in
place, cleans up the tests to work mainly through the public interfaces
as well as putting in place an HTTP error handling mechanism that allows
the request handlers to more specifically control the HTTP responses.
Invalid Accept headers will now cause a 406 response instead of the
previous 400.

Since all of this is tested with the memory terminus, it needed to be
expanded to also handle search and head actions.
(#21427) Deprecate YAML over the network

Issue a deprecation warning whenever YAML is encoded or decoded in the
http handler.
(#21427) Submit reports in PSON format

This changes the agent to submit reports in PSON. An effect of this
change is that reports will not be able to submit to masters that do not
have the changes for CVE-2013-3567 which allow the master to parse
PSON formatted reports.
Merge pull request #1722 from masterzen/tickets/master/20607

(#20607) - do not fail saving lastrunfile when mode is specified
Merge pull request #1727 from jpartlow/maint/added-missing-spec-helper

(maint) Includes missing spec_helper in three specs.
(Maint) Remove stubbing from query_string tests

The tests for the Puppet::Indirector::Request#query_string method were
relying on stubbing methods on the class under test. There is no need
for that since the required data is trivially passed in via the
constructor. This replaces the stubbing with simply constructing the
correct object to test.
(Maint) Test that the query string is parsable

Rather than relying on all sorts of string checks, it is better to check
that a parameter parsing library is able to parse the generated string
back into the expected data. This changes the tests to use CGI::parse to
parse the query_string and then can check that the resulting hash has
the data that is expected.
(#21427) Do not send arrays as YAML in query params

Previously, when the REST requests were constructed and one of the
parameters was an Array, the Array was encoded as YAML and then
identified on the master and parsed as YAML. This was used specifically
to send the list of "ignores" when making file metadata requests.

This changes the system to now use multi-valued query parameters instead
of YAML. Both the agent and master have been updated to support this,
however existing masters will not be able to understand the new requests
correctly since they will either:

  * in webrick only choose the first value as the value of the parameter
  * in rack fail because the decode_params method does not understand
    arrays as values
Merge pull request #1734 from zaphod42/deprecate-yaml

(#21427) Deprecate YAML and stop sending it from the agent