Enhance tests for assignment create_grant when no user or group

There were no tests that show the behavior of create_grant when
the user or group doesn't exist. Turns out the behavior is
different depending on the backend (sql vs kvs vs ldap).

Change-Id: I71c3e2b94aaa44e40c8a891b49cc2a9961cee16f
Related-Bug: #1239476
Fix KVS create_grant to not raise NotFound if no user/group

The KVS assigment backend would fail with NotFound if the user
or group didn't exist when calling create_grant while the SQL
assignment backend did not fail.

It's unreasonable to check if the user or group exists when
creating a grant, so the KVS assignment backend is changed to
not require the user or group to exist.

Closes-Bug: #1239476
Change-Id: I2d3b2fd82e7d4d33ac7158968d72cbfbe37528dc
Dependency cleanup

Clean up dependency usage.

a) If the class uses a dependency directly, make sure it's
included (getting from superclass isn't enough)

b) If the class doesn't use a dependency directly, make
sure it's NOT included (being a superclass isn't excuse)

Change-Id: Ifbd489f349ec019a41093a2814664e6d8c9f0069
don't rebind stdlib's os.chdir function

Change-Id: I07d5e8c58007cf716eecb922afb67abe3b53b981
Utilites for manipulating base64 & PEM

Add two new utility modules

  - keystone.common.base64utils
  - keystone.common.pemutils

Add two new unit tests to exercise the above.

  - keystone.tests.test_base64utils
  - keystone.tests.test_pemutils

Functionality in these utilities will be utilized to fix bug #1233838
in a subsequent commit. It is hoped these modules will moved to Oslo
common code. Each module has a doc string describing their purpose and
functionalty.

Change-Id: I3546674dcd9eddec2c378929dd3f759f667cfd5d
Partial-Bug: #1233838
Try decoding string to UTF-8 on error message fail

Database Errors from SQLAlchemy tend to get mangled into ASCII. If an
error is process that contains UTF-8 data in ASCII form if fails to
build the message and will lead to a 5xx error. Catch the error and try
to decode it to create the message again, if that doesn't work at least
fail gracefully.

Change-Id: Iecb1170387c51064918780dc6de07db7ca8aeeee
Closes-Bug: 1253905
Added documentation to keystone.common.dependency.

All public attributes now have docstrings describing their interface,
and the module has a top level docstring as well. Previously,
documentation was very sparse.

Closes-Bug: #1252428
Change-Id: I9c83883a6d9ae3201c9037c979689cb82c232120
Fix typo in keystone

1. Validate the user and tenant auth into in order to -> Validate the user
   and tenant auth info in order to
2. attmepting -> attempting
3. extnsion -> extension
4. identfier -> identifier
5. establed -> established
6. specifc -> specific
7. intitalized -> initialized
8. explicity -> explicitly
9. uniq -> unique

Change-Id: I8f4420e7c41cfdbc3f4751ed1c0b9a6e151b0940
Closes-Bug: #1254585
Ensure the sample policy file won't diverge

Currently rules should appear in both policy.v3cloudsample.json and
policy.json. In the future there may be a few exceptions that can be
documented by making the exception explicit in the test.

Change-Id: I3e9cdf64998d667941c44dc6edb48c2f7a9d37c4
Closes-Bug: #1255564
Updates .gitignore

To ignore swap files from getting into repository
currently the implemented ignore is *.swp
however vim adds more swap files if these files exists,
so improving this with *.sw?

Change-Id: I5c70908e32fc5316e395c72810fc45f5db8a7a77
Closes-Bug: #1255864
Deprecates V2 controllers

The revocation_list controller method's code was copied from the v2
controller to the v3 controller.  This allows us to cleanly deprecate
the v2 API without impacting the v3 API.

Closes-Bug:#1222696
Change-Id: I0ca7a091a50007c07dfe6942b2653c617ca98e70
Merge "Deprecates V2 controllers"
Updated from global requirements

Closes-Bug: 1239892
Change-Id: I669865879d8c12c5b810553ef9c7f87b9fb26fb1
Merge "don't rebind stdlib's os.chdir function"
Merge "Dependency cleanup"
Merge "Updated from global requirements"
Merge "Enhance tests for assignment create_grant when no user or group"
Sync From OSLO

blueprint: key-distribution-server
Change-Id: I424dbd6e8a535279498589444b976ea332e09c64
Merge "Fix KVS create_grant to not raise NotFound if no user/group"
One transaction per call to sql assignment backend

There are numerous schedules that lead to inconsistent data in the
various grant tables and role table. These races arose from a lack of
synchronization during grant table modification (i.e., during grant
record creation + deletion and role deletion) and deletions of records
that grant records refer to (i.e., user, group, domain, and project
records). The races manifested as 404 errors in response to API
requests. This patch adds the necessary synchronization by way of
transactions.

Also removed pointless session.flush() calls at the ends of transactions.

Closes-Bug: #1246489
Change-Id: I958d48bafc7fcb95f1d9ea71e408b4cefc2469c9