(PUP-3244) ENC ignores missing directory environments

When using an ENC, if an environment that didn't exist was defined for a
node puppet would place the node into the production environment instead
of raising an error to alert the user that the environment that had been
requested did not exist.

This commit changes the behaviour when an environment is defined in an
ENC but does not actually exist. Instead of placing the node into the
production environment a Puppet::Environments::EnvironmentNotFound error
is raised.
(PUP-3244) Acceptance Tests for Nonexistent Environments

Added acceptance tests to test if an error is raised if an ENC specifies
a nonexistent environment for a node.
(PUP-3244) Validate Environment Before Setting

Before this commit the environment validation was happening for the Exec
terminus instead of on the node object itself. This fix should help all
node objects from having invalid environments when its environment is
set using `Puppet::Node#environment=`.
(PUP-3244) Add Puppet::Environment::Directories#get! method

This new function will return the directory environment or raise an
error if a directory environment does not exist. This gets rid of the
need to check if environments exist across the codebase before
continuing for the areas where we need.
(maint) Modify other uses of get() to get!()

There were several uses of get() that either immediately checked for nil
and raised the UnknownEnvironmentError or assumed non-nil and continued.
This changes all of those cases to use the new get!() method and so be
explicit that they require an environment. There are a couple uses that
still don't require the environment to exist.
Merge branch 'pr/3146' into stable

* pr/3146:
  (maint) Modify other uses of get() to get!()
  (PUP-3244) Add Puppet::Environment::Directories#get! method
  (PUP-3244) Validate Environment Before Setting
  (PUP-3244) Acceptance Tests for Nonexistent Environments
  (PUP-3244) ENC ignores missing directory environments

Closes GH-3146
(PUP-3244) Remove unnecessary Cached.get!

This removes a function that was provided by the super class.
(PUP-3244) Remove redundant methods and refactor.

Before this commit the Puppet::Environments::Cached#get! was not needed
as it was defined in a parent class. Puppet::Environments::Combined#get!
now calls get! in environment objects instead of assuming how get!
should work.

This commit also refactors areas in the code where
Puppet::Environments::EnvironmentNotFound was raised after calling get
in favor of the new get! method.
(PUP-3244) Remove unnecessary Cached.get!

This removes a function that was provided by the super class.
Merge pull request #3179 from ferventcoder/ticket/stable/PUP-3244-enc-cached-get

(PUP-3244) ENC directory environments - Remove unnecessary Cached.get!
Merge pull request #3182 from demophoon/fix/stable/pup-3244

(PUP-3244) ENC ignores missing directory environments
(PUP-3244) Allow autoload to handle missing environment

When a previous commit changed from get() to get!() the agent stopped
being able to use an environment that is available on the master, but
not available locally. I had misread the code and missed a trailing
`&&`. This caused me to think that the environment lookup in this case
was required, where in fact it is still optional.

This changes the structure of the code to make it much clearer that the
environment is optional, changes from get!() to get(), and adds some
tests around these code paths.
(maint) Separate test for missing module directory

The test of behavior when a module directory is specified as part of an
environment but is missing on disk was hidden inside another test. This
splits it out and calls out that the behavior is that the directory is
simply ignored.
Merge pull request #3187 from zaphod42/issue/stable/pup-3244-error-when-agent-uses-missing-env

(PUP-3244) Allow autoload to handle missing environment
Merge branch 'stable'

* stable:
  (maint) Separate test for missing module directory
  (PUP-3244) Allow autoload to handle missing environment
  (PUP-3244) Remove unnecessary Cached.get!
  (PUP-3244) Remove redundant methods and refactor.
  (PUP-3244) Remove unnecessary Cached.get!
  (maint) Modify other uses of get() to get!()
  (PUP-3244) Add Puppet::Environment::Directories#get! method
  (PUP-3244) Validate Environment Before Setting
  (PUP-3244) Acceptance Tests for Nonexistent Environments
  (PUP-3244) ENC ignores missing directory environments