Update keystoneclient code to account for hacking 0.9.2
Fixed most of the errors reported back from hacking 0.9.2. Specifically: - E128 continuation line under-indented for visual indent - E251 unexpected spaces around keyword / parameter equals - E265 block comment should start with '# ' - H305 imports not grouped correctly - H307 like imports should be grouped together - H402 one line docstring needs punctuation - H904 Wrap long lines in parentheses instead of a backslash But opted to ignore the following for now: - E122: continuation line missing indentation or outdented - H405: multi line docstring summary not separated with an empty line Change-Id: Ib8e698d85fd598fa91435538657361a1f695ce89
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from keystoneclient.auth import base
|
from keystoneclient.auth import base
|
||||||
|
@@ -24,8 +24,9 @@ import logging
|
|||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import keyring
|
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
import keyring
|
||||||
except ImportError:
|
except ImportError:
|
||||||
keyring = None
|
keyring = None
|
||||||
pickle = None
|
pickle = None
|
||||||
|
@@ -149,13 +149,13 @@ import contextlib
|
|||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import requests
|
|
||||||
import stat
|
import stat
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
import requests
|
||||||
import six
|
import six
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
|
|
||||||
|
@@ -33,9 +33,10 @@ import hashlib
|
|||||||
import hmac
|
import hmac
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
# make sure pycrypto is available
|
# make sure pycrypto is available
|
||||||
try:
|
try:
|
||||||
from Crypto.Cipher import AES
|
from Crypto.Cipher import AES
|
||||||
|
@@ -32,11 +32,11 @@ This WSGI component:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import webob
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import six
|
import six
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
|
import webob
|
||||||
|
|
||||||
from keystoneclient.openstack.common import jsonutils
|
from keystoneclient.openstack.common import jsonutils
|
||||||
|
|
||||||
|
@@ -637,7 +637,7 @@ class CommonAuthTokenMiddlewareTest(object):
|
|||||||
for _ in range(2): # Do it twice because first result was cached.
|
for _ in range(2): # Do it twice because first result was cached.
|
||||||
self.assert_valid_request_200(
|
self.assert_valid_request_200(
|
||||||
self.token_dict['signed_token_scoped'])
|
self.token_dict['signed_token_scoped'])
|
||||||
#ensure that signed requests do not generate HTTP traffic
|
# ensure that signed requests do not generate HTTP traffic
|
||||||
self.assertLastPath(None)
|
self.assertLastPath(None)
|
||||||
|
|
||||||
def test_valid_signed_compressed_request(self):
|
def test_valid_signed_compressed_request(self):
|
||||||
@@ -722,7 +722,7 @@ class CommonAuthTokenMiddlewareTest(object):
|
|||||||
return jsonutils.dumps(revocation_list)
|
return jsonutils.dumps(revocation_list)
|
||||||
|
|
||||||
def test_is_signed_token_revoked_returns_false(self):
|
def test_is_signed_token_revoked_returns_false(self):
|
||||||
#explicitly setting an empty revocation list here to document intent
|
# explicitly setting an empty revocation list here to document intent
|
||||||
self.middleware.token_revocation_list = jsonutils.dumps(
|
self.middleware.token_revocation_list = jsonutils.dumps(
|
||||||
{"revoked": [], "extra": "success"})
|
{"revoked": [], "extra": "success"})
|
||||||
result = self.middleware.is_signed_token_revoked(
|
result = self.middleware.is_signed_token_revoked(
|
||||||
@@ -1443,10 +1443,10 @@ class v2AuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
|
|||||||
self.examples.UUID_TOKEN_UNKNOWN_BIND,
|
self.examples.UUID_TOKEN_UNKNOWN_BIND,
|
||||||
self.examples.UUID_TOKEN_NO_SERVICE_CATALOG,
|
self.examples.UUID_TOKEN_NO_SERVICE_CATALOG,
|
||||||
self.examples.SIGNED_TOKEN_SCOPED_KEY,):
|
self.examples.SIGNED_TOKEN_SCOPED_KEY,):
|
||||||
|
response_body = self.examples.JSON_TOKEN_RESPONSES[token]
|
||||||
httpretty.register_uri(httpretty.GET,
|
httpretty.register_uri(httpretty.GET,
|
||||||
"%s/v2.0/tokens/%s" % (BASE_URI, token),
|
"%s/v2.0/tokens/%s" % (BASE_URI, token),
|
||||||
body=
|
body=response_body)
|
||||||
self.examples.JSON_TOKEN_RESPONSES[token])
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
httpretty.register_uri(httpretty.GET,
|
||||||
'%s/v2.0/tokens/%s' % (BASE_URI, ERROR_TOKEN),
|
'%s/v2.0/tokens/%s' % (BASE_URI, ERROR_TOKEN),
|
||||||
@@ -1537,10 +1537,10 @@ class CrossVersionAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
|
|||||||
body=FAKE_ADMIN_TOKEN)
|
body=FAKE_ADMIN_TOKEN)
|
||||||
|
|
||||||
token = self.examples.UUID_TOKEN_DEFAULT
|
token = self.examples.UUID_TOKEN_DEFAULT
|
||||||
|
response_body = self.examples.JSON_TOKEN_RESPONSES[token]
|
||||||
httpretty.register_uri(httpretty.GET,
|
httpretty.register_uri(httpretty.GET,
|
||||||
"%s/v2.0/tokens/%s" % (BASE_URI, token),
|
"%s/v2.0/tokens/%s" % (BASE_URI, token),
|
||||||
body=
|
body=response_body)
|
||||||
self.examples.JSON_TOKEN_RESPONSES[token])
|
|
||||||
|
|
||||||
self.set_middleware(conf=conf)
|
self.set_middleware(conf=conf)
|
||||||
|
|
||||||
|
@@ -90,8 +90,8 @@ class KeyringTest(utils.TestCase):
|
|||||||
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
||||||
|
|
||||||
# stub and check that a new token is received
|
# stub and check that a new token is received
|
||||||
with mock.patch.object(cl, 'get_raw_token_from_identity_service') \
|
method = 'get_raw_token_from_identity_service'
|
||||||
as meth:
|
with mock.patch.object(cl, method) as meth:
|
||||||
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
|
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
|
||||||
|
|
||||||
self.assertTrue(cl.authenticate())
|
self.assertTrue(cl.authenticate())
|
||||||
@@ -128,8 +128,8 @@ class KeyringTest(utils.TestCase):
|
|||||||
self.memory_keyring.password = pickle.dumps(auth_ref)
|
self.memory_keyring.password = pickle.dumps(auth_ref)
|
||||||
|
|
||||||
# stub and check that a new token is received, so not using expired
|
# stub and check that a new token is received, so not using expired
|
||||||
with mock.patch.object(cl, 'get_raw_token_from_identity_service') \
|
method = 'get_raw_token_from_identity_service'
|
||||||
as meth:
|
with mock.patch.object(cl, method) as meth:
|
||||||
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
|
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
|
||||||
|
|
||||||
self.assertTrue(cl.authenticate())
|
self.assertTrue(cl.authenticate())
|
||||||
@@ -166,8 +166,8 @@ class KeyringTest(utils.TestCase):
|
|||||||
use_keyring=True)
|
use_keyring=True)
|
||||||
|
|
||||||
# stub and check that a new token is received
|
# stub and check that a new token is received
|
||||||
with mock.patch.object(cl, 'get_raw_token_from_identity_service') \
|
method = 'get_raw_token_from_identity_service'
|
||||||
as meth:
|
with mock.patch.object(cl, method) as meth:
|
||||||
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
|
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
|
||||||
|
|
||||||
self.assertTrue(cl.authenticate())
|
self.assertTrue(cl.authenticate())
|
||||||
|
@@ -313,9 +313,9 @@ class ShellTest(utils.TestCase):
|
|||||||
shell('tenant-create')
|
shell('tenant-create')
|
||||||
assert do_tenant_mock.called
|
assert do_tenant_mock.called
|
||||||
# FIXME(dtroyer): how do you test the decorators?
|
# FIXME(dtroyer): how do you test the decorators?
|
||||||
#shell('tenant-create --tenant-name wilma '
|
# shell('tenant-create --tenant-name wilma '
|
||||||
# '--description "fred\'s wife"')
|
# '--description "fred\'s wife"')
|
||||||
#assert do_tenant_mock.called
|
# assert do_tenant_mock.called
|
||||||
|
|
||||||
def test_do_tenant_list(self):
|
def test_do_tenant_list(self):
|
||||||
do_tenant_mock = mock.MagicMock()
|
do_tenant_mock = mock.MagicMock()
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import uuid
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import httpretty
|
import httpretty
|
||||||
@@ -22,7 +23,6 @@ import requests
|
|||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
import testtools
|
import testtools
|
||||||
import uuid
|
|
||||||
|
|
||||||
from keystoneclient.openstack.common import jsonutils
|
from keystoneclient.openstack.common import jsonutils
|
||||||
|
|
||||||
|
@@ -176,7 +176,7 @@ class TenantTests(utils.TestCase):
|
|||||||
"description": "I changed you!",
|
"description": "I changed you!",
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
"extravalue01": "metadataChanged",
|
"extravalue01": "metadataChanged",
|
||||||
#"extraname": "dontoverwrite!",
|
# "extraname": "dontoverwrite!",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
resp_body = {
|
resp_body = {
|
||||||
|
@@ -87,7 +87,7 @@ def do_user_get(kc, args):
|
|||||||
@utils.arg('--enabled', metavar='<true|false>', default=True,
|
@utils.arg('--enabled', metavar='<true|false>', default=True,
|
||||||
help='Initial user enabled status. Default is true.')
|
help='Initial user enabled status. Default is true.')
|
||||||
def do_user_create(kc, args):
|
def do_user_create(kc, args):
|
||||||
"""Create new user"""
|
"""Create new user."""
|
||||||
if args.tenant:
|
if args.tenant:
|
||||||
tenant_id = utils.find_resource(kc.tenants, args.tenant).id
|
tenant_id = utils.find_resource(kc.tenants, args.tenant).id
|
||||||
elif args.tenant_id:
|
elif args.tenant_id:
|
||||||
|
@@ -81,7 +81,7 @@ class TenantManager(base.ManagerWithFind):
|
|||||||
"description": description,
|
"description": description,
|
||||||
"enabled": enabled}}
|
"enabled": enabled}}
|
||||||
|
|
||||||
#Allow Extras Passthru and ensure we don't clobber primary arguments.
|
# Allow Extras Passthru and ensure we don't clobber primary arguments.
|
||||||
for k, v in six.iteritems(kwargs):
|
for k, v in six.iteritems(kwargs):
|
||||||
if k not in params['tenant']:
|
if k not in params['tenant']:
|
||||||
params['tenant'][k] = v
|
params['tenant'][k] = v
|
||||||
@@ -131,7 +131,7 @@ class TenantManager(base.ManagerWithFind):
|
|||||||
if description is not None:
|
if description is not None:
|
||||||
body['tenant']['description'] = description
|
body['tenant']['description'] = description
|
||||||
|
|
||||||
#Allow Extras Passthru and ensure we don't clobber primary arguments.
|
# Allow Extras Passthru and ensure we don't clobber primary arguments.
|
||||||
for k, v in six.iteritems(kwargs):
|
for k, v in six.iteritems(kwargs):
|
||||||
if k not in body['tenant']:
|
if k not in body['tenant']:
|
||||||
body['tenant'][k] = v
|
body['tenant'][k] = v
|
||||||
|
@@ -20,7 +20,7 @@ from keystoneclient import base
|
|||||||
|
|
||||||
|
|
||||||
class User(base.Resource):
|
class User(base.Resource):
|
||||||
"""Represents a Keystone user"""
|
"""Represents a Keystone user."""
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<User %s>" % self._info
|
return "<User %s>" % self._info
|
||||||
|
|
||||||
|
4
tox.ini
4
tox.ini
@@ -36,7 +36,9 @@ commands =
|
|||||||
# F821: undefined name
|
# F821: undefined name
|
||||||
# H304: no relative imports
|
# H304: no relative imports
|
||||||
# H803 Commit message should not end with a period (do not remove per list discussion)
|
# H803 Commit message should not end with a period (do not remove per list discussion)
|
||||||
ignore = F821,H304,H803
|
# H405: multi line docstring summary not separated with an empty line
|
||||||
|
# E122: continuation line missing indentation or outdented
|
||||||
|
ignore = F821,H304,H803,H405,E122
|
||||||
show-source = True
|
show-source = True
|
||||||
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*
|
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user