Merge "Fixing D202 and D203 PEP257 violation."
This commit is contained in:
@@ -75,7 +75,6 @@ def get_version_data(session, url, authenticated=None):
|
|||||||
|
|
||||||
def normalize_version_number(version):
|
def normalize_version_number(version):
|
||||||
"""Turn a version representation into a tuple."""
|
"""Turn a version representation into a tuple."""
|
||||||
|
|
||||||
# trim the v from a 'v2.0' or similar
|
# trim the v from a 'v2.0' or similar
|
||||||
try:
|
try:
|
||||||
version = version.lstrip('v')
|
version = version.lstrip('v')
|
||||||
|
@@ -49,7 +49,6 @@ class AccessInfo(dict):
|
|||||||
release and may be removed in the 2.0.0 release.
|
release and may be removed in the 2.0.0 release.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if region_name:
|
if region_name:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'Use of the region_name argument is deprecated as of the '
|
'Use of the region_name argument is deprecated as of the '
|
||||||
|
@@ -276,7 +276,6 @@ class BaseAuthPlugin(object):
|
|||||||
:param parser: the parser to attach argparse options.
|
:param parser: the parser to attach argparse options.
|
||||||
:type parser: argparse.ArgumentParser
|
:type parser: argparse.ArgumentParser
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# NOTE(jamielennox): ideally oslo_config would be smart enough to
|
# NOTE(jamielennox): ideally oslo_config would be smart enough to
|
||||||
# handle all the Opt manipulation that goes on in this file. However it
|
# handle all the Opt manipulation that goes on in this file. However it
|
||||||
# is currently not. Options are handled in as similar a way as
|
# is currently not. Options are handled in as similar a way as
|
||||||
@@ -313,7 +312,6 @@ class BaseAuthPlugin(object):
|
|||||||
:returns: An auth plugin, or None if a name is not provided.
|
:returns: An auth plugin, or None if a name is not provided.
|
||||||
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _getter(opt):
|
def _getter(opt):
|
||||||
return getattr(namespace, 'os_%s' % opt.dest)
|
return getattr(namespace, 'os_%s' % opt.dest)
|
||||||
|
|
||||||
@@ -343,7 +341,6 @@ class BaseAuthPlugin(object):
|
|||||||
:returns: An authentication Plugin.
|
:returns: An authentication Plugin.
|
||||||
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _getter(opt):
|
def _getter(opt):
|
||||||
return conf[group][opt.dest]
|
return conf[group][opt.dest]
|
||||||
|
|
||||||
@@ -366,7 +363,6 @@ class BaseAuthPlugin(object):
|
|||||||
:returns: An authentication Plugin.
|
:returns: An authentication Plugin.
|
||||||
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
plugin_opts = cls.get_options()
|
plugin_opts = cls.get_options()
|
||||||
|
|
||||||
for opt in plugin_opts:
|
for opt in plugin_opts:
|
||||||
|
@@ -73,7 +73,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'username is deprecated as of the 1.7.0 release and may be '
|
'username is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
@@ -86,7 +85,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'username is deprecated as of the 1.7.0 release and may be '
|
'username is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
@@ -99,7 +97,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'password is deprecated as of the 1.7.0 release and may be '
|
'password is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
@@ -112,7 +109,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'password is deprecated as of the 1.7.0 release and may be '
|
'password is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
@@ -125,7 +121,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'token is deprecated as of the 1.7.0 release and may be '
|
'token is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
@@ -138,7 +133,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'token is deprecated as of the 1.7.0 release and may be '
|
'token is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
@@ -151,7 +145,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'trust_id is deprecated as of the 1.7.0 release and may be '
|
'trust_id is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
@@ -164,7 +157,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
It may be removed in the 2.0.0 release.
|
It may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'trust_id is deprecated as of the 1.7.0 release and may be '
|
'trust_id is deprecated as of the 1.7.0 release and may be '
|
||||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||||
|
@@ -101,7 +101,6 @@ def _check_files_accessible(files):
|
|||||||
|
|
||||||
def _process_communicate_handle_oserror(process, data, files):
|
def _process_communicate_handle_oserror(process, data, files):
|
||||||
"""Wrapper around process.communicate that checks for OSError."""
|
"""Wrapper around process.communicate that checks for OSError."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output, err = process.communicate(data)
|
output, err = process.communicate(data)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
@@ -138,7 +138,6 @@ class OidcPassword(federated.FederatedBaseAuth):
|
|||||||
:returns: a token data representation
|
:returns: a token data representation
|
||||||
:rtype: :py:class:`keystoneclient.access.AccessInfo`
|
:rtype: :py:class:`keystoneclient.access.AccessInfo`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# get an access token
|
# get an access token
|
||||||
client_auth = (self.client_id, self.client_secret)
|
client_auth = (self.client_id, self.client_secret)
|
||||||
payload = {'grant_type': self.grant_type, 'username': self.username,
|
payload = {'grant_type': self.grant_type, 'username': self.username,
|
||||||
|
@@ -293,7 +293,6 @@ class Saml2UnscopedToken(_BaseSAMLPlugin):
|
|||||||
|
|
||||||
def _send_idp_saml2_authn_request(self, session):
|
def _send_idp_saml2_authn_request(self, session):
|
||||||
"""Present modified SAML2 authn assertion from the Service Provider."""
|
"""Present modified SAML2 authn assertion from the Service Provider."""
|
||||||
|
|
||||||
self._prepare_idp_saml2_request(self.saml2_authn_request)
|
self._prepare_idp_saml2_request(self.saml2_authn_request)
|
||||||
idp_saml2_authn_request = self.saml2_authn_request
|
idp_saml2_authn_request = self.saml2_authn_request
|
||||||
|
|
||||||
@@ -581,7 +580,6 @@ class ADFSUnscopedToken(_BaseSAMLPlugin):
|
|||||||
:type fmt: string
|
:type fmt: string
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
date_created = datetime.datetime.utcnow()
|
date_created = datetime.datetime.utcnow()
|
||||||
date_expires = date_created + datetime.timedelta(
|
date_expires = date_created + datetime.timedelta(
|
||||||
seconds=self.DEFAULT_ADFS_TOKEN_EXPIRATION)
|
seconds=self.DEFAULT_ADFS_TOKEN_EXPIRATION)
|
||||||
@@ -593,7 +591,6 @@ class ADFSUnscopedToken(_BaseSAMLPlugin):
|
|||||||
Some values like username or password are inserted in the request.
|
Some values like username or password are inserted in the request.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WSS_SECURITY_NAMESPACE = {
|
WSS_SECURITY_NAMESPACE = {
|
||||||
'o': ('http://docs.oasis-open.org/wss/2004/01/oasis-200401-'
|
'o': ('http://docs.oasis-open.org/wss/2004/01/oasis-200401-'
|
||||||
'wss-wssecurity-secext-1.0.xsd')
|
'wss-wssecurity-secext-1.0.xsd')
|
||||||
@@ -905,7 +902,6 @@ class Saml2ScopedTokenMethod(v3.TokenMethod):
|
|||||||
|
|
||||||
def get_auth_data(self, session, auth, headers, **kwargs):
|
def get_auth_data(self, session, auth, headers, **kwargs):
|
||||||
"""Build and return request body for token scoping step."""
|
"""Build and return request body for token scoping step."""
|
||||||
|
|
||||||
t = super(Saml2ScopedTokenMethod, self).get_auth_data(
|
t = super(Saml2ScopedTokenMethod, self).get_auth_data(
|
||||||
session, auth, headers, **kwargs)
|
session, auth, headers, **kwargs)
|
||||||
_token_method, token = t
|
_token_method, token = t
|
||||||
|
@@ -162,7 +162,6 @@ class Ec2Signer(object):
|
|||||||
def _calc_signature_4(self, params, verb, server_string, path, headers,
|
def _calc_signature_4(self, params, verb, server_string, path, headers,
|
||||||
body_hash):
|
body_hash):
|
||||||
"""Generate AWS signature version 4 string."""
|
"""Generate AWS signature version 4 string."""
|
||||||
|
|
||||||
def sign(key, msg):
|
def sign(key, msg):
|
||||||
return hmac.new(key, self._get_utf8_value(msg),
|
return hmac.new(key, self._get_utf8_value(msg),
|
||||||
hashlib.sha256).digest()
|
hashlib.sha256).digest()
|
||||||
|
@@ -459,7 +459,6 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
|||||||
This is deprecated as of the 1.7.0 release in favor of project_id
|
This is deprecated as of the 1.7.0 release in favor of project_id
|
||||||
and may be removed in the 2.0.0 release.
|
and may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'tenant_id is deprecated as of the 1.7.0 release in favor of '
|
'tenant_id is deprecated as of the 1.7.0 release in favor of '
|
||||||
'project_id and may be removed in the 2.0.0 release.',
|
'project_id and may be removed in the 2.0.0 release.',
|
||||||
@@ -476,7 +475,6 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
|||||||
This is deprecated as of the 1.7.0 release in favor of project_name
|
This is deprecated as of the 1.7.0 release in favor of project_name
|
||||||
and may be removed in the 2.0.0 release.
|
and may be removed in the 2.0.0 release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'tenant_name is deprecated as of the 1.7.0 release in favor of '
|
'tenant_name is deprecated as of the 1.7.0 release in favor of '
|
||||||
'project_name and may be removed in the 2.0.0 release.',
|
'project_name and may be removed in the 2.0.0 release.',
|
||||||
|
@@ -310,7 +310,6 @@ class Session(object):
|
|||||||
|
|
||||||
:returns: The response to the request.
|
:returns: The response to the request.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers = kwargs.setdefault('headers', dict())
|
headers = kwargs.setdefault('headers', dict())
|
||||||
|
|
||||||
if authenticated is None:
|
if authenticated is None:
|
||||||
@@ -563,12 +562,10 @@ class Session(object):
|
|||||||
functions without session arguments.
|
functions without session arguments.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'Session.construct() is deprecated as of the 1.7.0 release in '
|
'Session.construct() is deprecated as of the 1.7.0 release in '
|
||||||
'favor of using session constructor and may be removed in the '
|
'favor of using session constructor and may be removed in the '
|
||||||
'2.0.0 release.', DeprecationWarning)
|
'2.0.0 release.', DeprecationWarning)
|
||||||
|
|
||||||
return cls._construct(kwargs)
|
return cls._construct(kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@@ -180,7 +180,6 @@ class SessionTests(utils.TestCase):
|
|||||||
|
|
||||||
def test_logs_failed_output(self):
|
def test_logs_failed_output(self):
|
||||||
"""Test that output is logged even for failed requests."""
|
"""Test that output is logged even for failed requests."""
|
||||||
|
|
||||||
session = client_session.Session()
|
session = client_session.Session()
|
||||||
body = uuid.uuid4().hex
|
body = uuid.uuid4().hex
|
||||||
|
|
||||||
@@ -192,7 +191,6 @@ class SessionTests(utils.TestCase):
|
|||||||
|
|
||||||
def test_unicode_data_in_debug_output(self):
|
def test_unicode_data_in_debug_output(self):
|
||||||
"""Verify that ascii-encodable data is logged without modification."""
|
"""Verify that ascii-encodable data is logged without modification."""
|
||||||
|
|
||||||
session = client_session.Session(verify=False)
|
session = client_session.Session(verify=False)
|
||||||
|
|
||||||
body = 'RESP'
|
body = 'RESP'
|
||||||
@@ -204,7 +202,6 @@ class SessionTests(utils.TestCase):
|
|||||||
|
|
||||||
def test_binary_data_not_in_debug_output(self):
|
def test_binary_data_not_in_debug_output(self):
|
||||||
"""Verify that non-ascii-encodable data causes replacement."""
|
"""Verify that non-ascii-encodable data causes replacement."""
|
||||||
|
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
data = "my data" + chr(255)
|
data = "my data" + chr(255)
|
||||||
else:
|
else:
|
||||||
|
@@ -158,7 +158,6 @@ class DisableModuleFixture(fixtures.Fixture):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Ensure ImportError for the specified module."""
|
"""Ensure ImportError for the specified module."""
|
||||||
|
|
||||||
super(DisableModuleFixture, self).setUp()
|
super(DisableModuleFixture, self).setUp()
|
||||||
|
|
||||||
# Clear 'module' references in sys.modules
|
# Clear 'module' references in sys.modules
|
||||||
|
@@ -93,7 +93,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||||||
" argument 'project_name'")
|
" argument 'project_name'")
|
||||||
def test_conf_params(self):
|
def test_conf_params(self):
|
||||||
"""Ensure OpenID Connect config options work."""
|
"""Ensure OpenID Connect config options work."""
|
||||||
|
|
||||||
section = uuid.uuid4().hex
|
section = uuid.uuid4().hex
|
||||||
identity_provider = uuid.uuid4().hex
|
identity_provider = uuid.uuid4().hex
|
||||||
protocol = uuid.uuid4().hex
|
protocol = uuid.uuid4().hex
|
||||||
@@ -129,7 +128,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||||||
|
|
||||||
def test_initial_call_to_get_access_token(self):
|
def test_initial_call_to_get_access_token(self):
|
||||||
"""Test initial call, expect JSON access token."""
|
"""Test initial call, expect JSON access token."""
|
||||||
|
|
||||||
# Mock the output that creates the access token
|
# Mock the output that creates the access token
|
||||||
self.requests_mock.post(
|
self.requests_mock.post(
|
||||||
self.ACCESS_TOKEN_ENDPOINT,
|
self.ACCESS_TOKEN_ENDPOINT,
|
||||||
@@ -154,7 +152,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||||||
|
|
||||||
def test_second_call_to_protected_url(self):
|
def test_second_call_to_protected_url(self):
|
||||||
"""Test subsequent call, expect Keystone token."""
|
"""Test subsequent call, expect Keystone token."""
|
||||||
|
|
||||||
# Mock the output that creates the keystone token
|
# Mock the output that creates the keystone token
|
||||||
self.requests_mock.post(
|
self.requests_mock.post(
|
||||||
self.FEDERATION_AUTH_URL,
|
self.FEDERATION_AUTH_URL,
|
||||||
@@ -176,7 +173,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||||||
|
|
||||||
def test_end_to_end_workflow(self):
|
def test_end_to_end_workflow(self):
|
||||||
"""Test full OpenID Connect workflow."""
|
"""Test full OpenID Connect workflow."""
|
||||||
|
|
||||||
# Mock the output that creates the access token
|
# Mock the output that creates the access token
|
||||||
self.requests_mock.post(
|
self.requests_mock.post(
|
||||||
self.ACCESS_TOKEN_ENDPOINT,
|
self.ACCESS_TOKEN_ENDPOINT,
|
||||||
|
@@ -493,7 +493,6 @@ class AuthenticateviaADFSTests(utils.TestCase):
|
|||||||
|
|
||||||
def test_get_adfs_security_token(self):
|
def test_get_adfs_security_token(self):
|
||||||
"""Test ADFSUnscopedToken._get_adfs_security_token()."""
|
"""Test ADFSUnscopedToken._get_adfs_security_token()."""
|
||||||
|
|
||||||
self.requests_mock.post(
|
self.requests_mock.post(
|
||||||
self.IDENTITY_PROVIDER_URL,
|
self.IDENTITY_PROVIDER_URL,
|
||||||
content=make_oneline(self.ADFS_SECURITY_TOKEN_RESPONSE),
|
content=make_oneline(self.ADFS_SECURITY_TOKEN_RESPONSE),
|
||||||
@@ -672,7 +671,6 @@ class SAMLGenerationTests(utils.ClientTestCase):
|
|||||||
|
|
||||||
def test_saml_create(self):
|
def test_saml_create(self):
|
||||||
"""Test that a token can be exchanged for a SAML assertion."""
|
"""Test that a token can be exchanged for a SAML assertion."""
|
||||||
|
|
||||||
token_id = uuid.uuid4().hex
|
token_id = uuid.uuid4().hex
|
||||||
service_provider_id = uuid.uuid4().hex
|
service_provider_id = uuid.uuid4().hex
|
||||||
|
|
||||||
@@ -695,7 +693,6 @@ class SAMLGenerationTests(utils.ClientTestCase):
|
|||||||
|
|
||||||
def test_ecp_create(self):
|
def test_ecp_create(self):
|
||||||
"""Test that a token can be exchanged for an ECP wrapped assertion."""
|
"""Test that a token can be exchanged for an ECP wrapped assertion."""
|
||||||
|
|
||||||
token_id = uuid.uuid4().hex
|
token_id = uuid.uuid4().hex
|
||||||
service_provider_id = uuid.uuid4().hex
|
service_provider_id = uuid.uuid4().hex
|
||||||
|
|
||||||
|
@@ -98,7 +98,6 @@ class TokenTests(object):
|
|||||||
Assert that the data in the headers matches the data
|
Assert that the data in the headers matches the data
|
||||||
that is produced from oauthlib.
|
that is produced from oauthlib.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.assertThat(auth_header, matchers.StartsWith('OAuth '))
|
self.assertThat(auth_header, matchers.StartsWith('OAuth '))
|
||||||
parameters = dict(
|
parameters = dict(
|
||||||
oauth1.rfc5849.utils.parse_authorization_header(auth_header))
|
oauth1.rfc5849.utils.parse_authorization_header(auth_header))
|
||||||
|
@@ -131,7 +131,6 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
|
|||||||
:returns: a list of the projects in the created hierarchy.
|
:returns: a list of the projects in the created hierarchy.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ref = self.new_ref()
|
ref = self.new_ref()
|
||||||
project_id = ref['id']
|
project_id = ref['id']
|
||||||
projects = [ref]
|
projects = [ref]
|
||||||
|
@@ -29,7 +29,6 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def find_resource(manager, name_or_id):
|
def find_resource(manager, name_or_id):
|
||||||
"""Helper for the _find_* methods."""
|
"""Helper for the _find_* methods."""
|
||||||
|
|
||||||
# first try the entity as a string
|
# first try the entity as a string
|
||||||
try:
|
try:
|
||||||
return manager.get(name_or_id)
|
return manager.get(name_or_id)
|
||||||
@@ -128,7 +127,6 @@ _ISO8601_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
|
|||||||
|
|
||||||
def isotime(at=None, subsecond=False):
|
def isotime(at=None, subsecond=False):
|
||||||
"""Stringify time in ISO 8601 format."""
|
"""Stringify time in ISO 8601 format."""
|
||||||
|
|
||||||
# Python provides a similar instance method for datetime.datetime objects
|
# Python provides a similar instance method for datetime.datetime objects
|
||||||
# called isoformat(). The format of the strings generated by isoformat()
|
# called isoformat(). The format of the strings generated by isoformat()
|
||||||
# have a couple of problems:
|
# have a couple of problems:
|
||||||
@@ -140,7 +138,6 @@ def isotime(at=None, subsecond=False):
|
|||||||
# the value happens to be 0. This will likely show up as random failures
|
# the value happens to be 0. This will likely show up as random failures
|
||||||
# as parsers may be written to always expect microseconds, and it will
|
# as parsers may be written to always expect microseconds, and it will
|
||||||
# parse correctly most of the time.
|
# parse correctly most of the time.
|
||||||
|
|
||||||
if not at:
|
if not at:
|
||||||
at = timeutils.utcnow()
|
at = timeutils.utcnow()
|
||||||
st = at.strftime(_ISO8601_TIME_FORMAT
|
st = at.strftime(_ISO8601_TIME_FORMAT
|
||||||
|
@@ -25,7 +25,6 @@ class CertificatesManager(object):
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
resp, body = self._client.get('/certificates/ca', authenticated=False)
|
resp, body = self._client.get('/certificates/ca', authenticated=False)
|
||||||
return resp.text
|
return resp.text
|
||||||
|
|
||||||
@@ -36,7 +35,6 @@ class CertificatesManager(object):
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
resp, body = self._client.get('/certificates/signing',
|
resp, body = self._client.get('/certificates/signing',
|
||||||
authenticated=False)
|
authenticated=False)
|
||||||
return resp.text
|
return resp.text
|
||||||
|
@@ -147,7 +147,6 @@ class Client(httpclient.HTTPClient):
|
|||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Initialize a new client for the Keystone v2.0 API."""
|
"""Initialize a new client for the Keystone v2.0 API."""
|
||||||
|
|
||||||
if not kwargs.get('session'):
|
if not kwargs.get('session'):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'Constructing an instance of the '
|
'Constructing an instance of the '
|
||||||
|
@@ -32,7 +32,6 @@ class CredentialsManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
:rtype: object of type :class:`EC2`
|
:rtype: object of type :class:`EC2`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
params = {'tenant_id': tenant_id}
|
params = {'tenant_id': tenant_id}
|
||||||
|
|
||||||
return self._post('/users/%s/credentials/OS-EC2' % user_id,
|
return self._post('/users/%s/credentials/OS-EC2' % user_id,
|
||||||
|
@@ -107,7 +107,6 @@ class TenantManager(base.ManagerWithFind):
|
|||||||
:rtype: list of :class:`Tenant`
|
:rtype: list of :class:`Tenant`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
if limit:
|
if limit:
|
||||||
params['limit'] = limit
|
params['limit'] = limit
|
||||||
|
@@ -106,7 +106,6 @@ class TokenManager(base.Manager):
|
|||||||
:rtype: :py:class:`keystoneclient.access.AccessInfoV2`
|
:rtype: :py:class:`keystoneclient.access.AccessInfoV2`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def calc_id(token):
|
def calc_id(token):
|
||||||
if isinstance(token, access.AccessInfo):
|
if isinstance(token, access.AccessInfo):
|
||||||
return token.auth_token
|
return token.auth_token
|
||||||
|
@@ -113,7 +113,6 @@ class UserManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
:rtype: list of :class:`User`
|
:rtype: list of :class:`User`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
if limit:
|
if limit:
|
||||||
params['limit'] = int(limit)
|
params['limit'] = int(limit)
|
||||||
|
@@ -37,7 +37,6 @@ class ProtocolManager(base.CrudManager):
|
|||||||
|
|
||||||
def build_url(self, dict_args_in_out=None):
|
def build_url(self, dict_args_in_out=None):
|
||||||
"""Build URL for federation protocols."""
|
"""Build URL for federation protocols."""
|
||||||
|
|
||||||
if dict_args_in_out is None:
|
if dict_args_in_out is None:
|
||||||
dict_args_in_out = {}
|
dict_args_in_out = {}
|
||||||
|
|
||||||
|
@@ -34,7 +34,6 @@ class SamlManager(base.Manager):
|
|||||||
:returns: SAML representation of token_id
|
:returns: SAML representation of token_id
|
||||||
:rtype: string
|
:rtype: string
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers, body = self._create_common_request(service_provider, token_id)
|
headers, body = self._create_common_request(service_provider, token_id)
|
||||||
resp, body = self.client.post(SAML2_ENDPOINT, json=body,
|
resp, body = self.client.post(SAML2_ENDPOINT, json=body,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
@@ -54,7 +53,6 @@ class SamlManager(base.Manager):
|
|||||||
:returns: SAML representation of token_id, wrapped in ECP envelope
|
:returns: SAML representation of token_id, wrapped in ECP envelope
|
||||||
:rtype: string
|
:rtype: string
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers, body = self._create_common_request(service_provider, token_id)
|
headers, body = self._create_common_request(service_provider, token_id)
|
||||||
resp, body = self.client.post(ECP_ENDPOINT, json=body,
|
resp, body = self.client.post(ECP_ENDPOINT, json=body,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
@@ -51,7 +51,6 @@ class RequestTokenManager(base.CrudManager):
|
|||||||
can be exchanged for an access token.
|
can be exchanged for an access token.
|
||||||
:param roles: a list of roles, that will be delegated to the user.
|
:param roles: a list of roles, that will be delegated to the user.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
request_id = urlparse.quote(base.getid(request_token))
|
request_id = urlparse.quote(base.getid(request_token))
|
||||||
endpoint = utils.OAUTH_PATH + '/authorize/%s' % (request_id)
|
endpoint = utils.OAUTH_PATH + '/authorize/%s' % (request_id)
|
||||||
body = {'roles': [{'id': base.getid(r_id)} for r_id in roles]}
|
body = {'roles': [{'id': base.getid(r_id)} for r_id in roles]}
|
||||||
|
@@ -25,7 +25,6 @@ def get_oauth_token_from_body(body):
|
|||||||
'oauth_token=12345&oauth_token_secret=67890' with
|
'oauth_token=12345&oauth_token_secret=67890' with
|
||||||
'oauth_expires_at=2013-03-30T05:27:19.463201' possibly there, too.
|
'oauth_expires_at=2013-03-30T05:27:19.463201' possibly there, too.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
body = body.decode('utf-8')
|
body = body.decode('utf-8')
|
||||||
|
|
||||||
|
@@ -25,7 +25,6 @@ class SimpleCertManager(object):
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
resp, body = self._client.get('/OS-SIMPLE-CERT/ca',
|
resp, body = self._client.get('/OS-SIMPLE-CERT/ca',
|
||||||
authenticated=False)
|
authenticated=False)
|
||||||
return resp.text
|
return resp.text
|
||||||
@@ -37,7 +36,6 @@ class SimpleCertManager(object):
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
resp, body = self._client.get('/OS-SIMPLE-CERT/certificates',
|
resp, body = self._client.get('/OS-SIMPLE-CERT/certificates',
|
||||||
authenticated=False)
|
authenticated=False)
|
||||||
return resp.text
|
return resp.text
|
||||||
|
@@ -136,6 +136,5 @@ class CredentialManager(base.CrudManager):
|
|||||||
:type credential: :class:`Credential` or str
|
:type credential: :class:`Credential` or str
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return super(CredentialManager, self).delete(
|
return super(CredentialManager, self).delete(
|
||||||
credential_id=base.getid(credential))
|
credential_id=base.getid(credential))
|
||||||
|
@@ -28,7 +28,6 @@ class EC2Manager(base.ManagerWithFind):
|
|||||||
|
|
||||||
:rtype: object of type :class:`EC2`
|
:rtype: object of type :class:`EC2`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# NOTE(jamielennox): Yes, this uses tenant_id as a key even though we
|
# NOTE(jamielennox): Yes, this uses tenant_id as a key even though we
|
||||||
# are in the v3 API.
|
# are in the v3 API.
|
||||||
return self._post('/users/%s/credentials/OS-EC2' % user_id,
|
return self._post('/users/%s/credentials/OS-EC2' % user_id,
|
||||||
|
@@ -76,7 +76,6 @@ class ProjectManager(base.CrudManager):
|
|||||||
:param parent: the project's parent in the hierarchy. (optional)
|
:param parent: the project's parent in the hierarchy. (optional)
|
||||||
:type parent: :py:class:`keystoneclient.v3.projects.Project` or str
|
:type parent: :py:class:`keystoneclient.v3.projects.Project` or str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# NOTE(rodrigods): the API must be backwards compatible, so if an
|
# NOTE(rodrigods): the API must be backwards compatible, so if an
|
||||||
# application was passing a 'parent_id' before as kwargs, the call
|
# application was passing a 'parent_id' before as kwargs, the call
|
||||||
# should not fail. If both 'parent' and 'parent_id' are provided,
|
# should not fail. If both 'parent' and 'parent_id' are provided,
|
||||||
|
@@ -74,7 +74,6 @@ class RoleAssignmentManager(base.CrudManager):
|
|||||||
:param boolean include_names: Display names instead
|
:param boolean include_names: Display names instead
|
||||||
of IDs. (optional)
|
of IDs. (optional)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._check_not_user_and_group(user, group)
|
self._check_not_user_and_group(user, group)
|
||||||
self._check_not_domain_and_project(domain, project)
|
self._check_not_domain_and_project(domain, project)
|
||||||
|
|
||||||
|
@@ -154,7 +154,6 @@ class RoleManager(base.CrudManager):
|
|||||||
used. It provides the ability for projects to inherit role assignments
|
used. It provides the ability for projects to inherit role assignments
|
||||||
from their domains or from projects in the hierarchy.
|
from their domains or from projects in the hierarchy.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if os_inherit_extension_inherited:
|
if os_inherit_extension_inherited:
|
||||||
kwargs['tail'] = '/inherited_to_projects'
|
kwargs['tail'] = '/inherited_to_projects'
|
||||||
if user or group:
|
if user or group:
|
||||||
|
@@ -36,7 +36,6 @@ class TokenManager(object):
|
|||||||
:py:class:`keystoneclient.access.AccessInfo` or a string
|
:py:class:`keystoneclient.access.AccessInfo` or a string
|
||||||
token_id.
|
token_id.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
token_id = _calc_id(token)
|
token_id = _calc_id(token)
|
||||||
headers = {'X-Subject-Token': token_id}
|
headers = {'X-Subject-Token': token_id}
|
||||||
return self._client.delete('/auth/tokens', headers=headers)
|
return self._client.delete('/auth/tokens', headers=headers)
|
||||||
@@ -92,7 +91,6 @@ class TokenManager(object):
|
|||||||
:rtype: :py:class:`keystoneclient.access.AccessInfoV3`
|
:rtype: :py:class:`keystoneclient.access.AccessInfoV3`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
token_id = _calc_id(token)
|
token_id = _calc_id(token)
|
||||||
body = self.get_token_data(token_id, include_catalog=include_catalog)
|
body = self.get_token_data(token_id, include_catalog=include_catalog)
|
||||||
return access.AccessInfo.factory(auth_token=token_id, body=body)
|
return access.AccessInfo.factory(auth_token=token_id, body=body)
|
||||||
|
4
tox.ini
4
tox.ini
@@ -47,9 +47,7 @@ passenv = OS_*
|
|||||||
# D104: Missing docstring in public package
|
# D104: Missing docstring in public package
|
||||||
# D105: Missing docstring in magic method
|
# D105: Missing docstring in magic method
|
||||||
# D200: One-line docstring should fit on one line with quotes
|
# D200: One-line docstring should fit on one line with quotes
|
||||||
# D202: No blank lines allowed after function docstring
|
ignore = D100,D101,D102,D103,D104,D105,D200
|
||||||
# D203: 1 blank required before class docstring.
|
|
||||||
ignore = D100,D101,D102,D103,D104,D105,D200,D202,D203
|
|
||||||
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