Modify keyring tests to test authentication

Currently keyring tests test the calls to the keyring service directly
and not their use in an actual authentication call. Modify them so we
test how the keyring performs under more realistic usage.

Change-Id: I2216dcaaa6464f39807fd79a3bea07d1de71f827
Decode the non-english username str to unicode

convert the non-english username str to unicode,
then the converted username can match the username from db.

Fixes bug #1221576

Change-Id: I9e5f941fe43f081d75750e3f4754e8beea8210db
Log user info in auth_token middleware

Add logging for user information (like user name, tenant_id, roles) in
the auth_token middleware. This would make tracking down issues much
easier.

Change-Id: Ife4ce29d2f8e1a338a025dda4afbd7b563f6b8c1
Implements: blueprint user-info-logging-in-auth-token-middleware
Allow blank to email in user-update

User cannot set blank to email address when use "user-update".

This patch fixes this problem.

Change-Id: I3b9494a1c668358a529031c366c55b303f43c533
Closes-bug: #1226439
Change Babel to a runtime requirement

Fixes bug #1226736

Change-Id: Id0ab5a1b74688601f4f8dd1c2613f4cee93401ab
Merge "Decode the non-english username str to unicode"
Merge "Allow blank to email in user-update"
Merge "Change Babel to a runtime requirement"
Merge "Modify keyring tests to test authentication"
Move tests in keystoneclient

This is the suggested location for tests and is adopted by most
projects. As part of this change relative imports to package imports.

Fix all the test running and coverage code to point to the new location.

Change-Id: I01264aed14f396ab9a7242e3e72b71e1bc332675
Require oslo.config 1.2.0 final

Now that 1.2.0 has been released, require it rather than on of the beta
release tarballs.

Closes-Bug: #1182861
Change-Id: I75ffc4a572d14488d19491a38742d6920951c171
Merge "Move tests in keystoneclient"
Add auth_uri in conf to avoid unnecessary warning

Unittest code for auth_token.py doesn't specify auth_uri in conf,
which will cause lots of warnings, since auth_token.py will use
'%(protocol)s://%(host)s:%(port)s' to generate auth_uri when it is
None, we can specify this value directly to avoid unnecessary warnings.

Closes-Bug: #1219493
Change-Id: I26b636bcddabd91b06479c6a42a6a48d74ac9431
Fix misused assertTrue in unit tests

Refactored unit tests to use assertEqual instead of assertTrue
where needed.

Fixes bug #1226374

Change-Id: I678b2e7fcc522c8776c7fc0a554c1fc229ab781e
Allow v2 client authentication with trust_id

It should be possible to authenticate against the v2 tokens
API with a trust_id, because it suports rescoping an existing
token to a trust, this patch adds client support for this.

Note with the current keystone code it's necessary to pass the
trustor tenant ID when rescoping with a trust where
impersonation==True, e.g:

c = client_v2.Client(username=TRUSTEE_USERNAME,
                     password=TRUSTEE_USERNAME,
                     tenant_name=TRUSTEE_TENANT_NAME,
                     auth_url=OS_AUTH_URL_V2)
c.authenticate(trust_id=trust_i.id, tenant_id=TRUSTOR_TENANT_ID)

Change-Id: I177c41af298b7437e2c6fb437aa9ce9a09773b9d
Closes-Bug: #1231483
Fixes print error for keystone action with non-English characters

When processing keystone tenant-delete action with non-English
characters, printing the exception traceback will result in a
UnicodeEncodeError, so should encode text with safe_encode.

Fixes bug #1231472

Change-Id: Ic2599c51513189c132e31aa87d0d15df81802688
Refactor for testability of an upcoming change

confirm_token_not_expired() in keystoneclient/middleware/auth_token.py has
been moved out of the class to make it a function and be more testable.
Currently, there is no need to keep it within the class. An upcoming
commit makes fixes that rely on this refactor to be tested.

Change-Id: I8460a2ee663dec8be0f339735208779a3b988040
Merge "Log user info in auth_token middleware"
Fix H202 assertRaises Exception

Align the hacking version between test-requirement and global requirement.

The change of H202 detection from 0.6 to 0.7 in hacking is:

-    if logical_line.startswith("self.assertRaises(Exception)"):
+    if logical_line.startswith("self.assertRaises(Exception,"):

then more cases are detected by this change. Fix the exposed H202 error.

There is a special test case:
tests/v3/test_endpoints.py:test_update_invalid_interface

ref = self.new_ref(interface=uuid.uuid4().hex)

this line can not generate proper parameter for self.manager.update,
add a parameter "endpoint" for it, according to the
definition in keystoneclient/v3/endpoints.py:EndpointManager.update.

Otherwise, there will be following error after changing the Exception
to exceptions.ValidationError:
TypeError: update() takes at least 2 arguments (6 given)

Fixes Bug #1220008

Change-Id: I8f7ed7a6eebf8576a6db5fecd86b9d19a15c8d60
Merge "Add auth_uri in conf to avoid unnecessary warning"