Merge "Enable F and H flake8 rules"
This commit is contained in:
commit
876d0c854a
|
@ -125,8 +125,7 @@ class _PerOperationACL(ACLFormatter):
|
|||
self._users = value
|
||||
|
||||
def remove(self):
|
||||
"""
|
||||
Remove operation specific setting defined for a secret or container
|
||||
"""Remove operation specific setting defined for a secret or container
|
||||
|
||||
:raises barbicanclient.exceptions.HTTPAuthError: 401 Responses
|
||||
:raises barbicanclient.exceptions.HTTPClientError: 4xx Responses
|
||||
|
@ -307,8 +306,7 @@ class ACL(object):
|
|||
return response.json().get('acl_ref')
|
||||
|
||||
def remove(self):
|
||||
"""
|
||||
Remove Barbican ACLs setting defined for a secret or container
|
||||
"""Remove Barbican ACLs setting defined for a secret or container
|
||||
|
||||
:raises barbicanclient.exceptions.HTTPAuthError: 401 Responses
|
||||
:raises barbicanclient.exceptions.HTTPClientError: 4xx Responses
|
||||
|
@ -418,8 +416,7 @@ class ACLManager(base.BaseEntityManager):
|
|||
|
||||
def create(self, entity_ref=None, users=None, project_access=None,
|
||||
operation_type=DEFAULT_OPERATION_TYPE):
|
||||
"""
|
||||
Factory method for creating `ACL` entity.
|
||||
"""Factory method for creating `ACL` entity.
|
||||
|
||||
`ACL` object returned by this method have not yet been
|
||||
stored in Barbican.
|
||||
|
@ -447,8 +444,7 @@ class ACLManager(base.BaseEntityManager):
|
|||
operation_type=operation_type)
|
||||
|
||||
def get(self, entity_ref):
|
||||
"""
|
||||
Retrieve existing ACLs for a secret or container defined in Barbican
|
||||
"""Retrieve existing ACLs for a secret or container found in Barbican
|
||||
|
||||
:param str entity_ref: Full HATEOAS reference to a secret or container.
|
||||
:returns: ACL entity object instance
|
||||
|
|
|
@ -32,8 +32,8 @@ from keystoneauth1 import loading
|
|||
from keystoneauth1 import session
|
||||
|
||||
import barbicanclient
|
||||
from barbicanclient import client
|
||||
from barbicanclient._i18n import _LW
|
||||
from barbicanclient import client
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -222,6 +222,7 @@ class Barbican(app.App):
|
|||
|
||||
def build_option_parser(self, description, version, argparse_kwargs=None):
|
||||
"""Introduces global arguments for the application.
|
||||
|
||||
This is inherited from the framework.
|
||||
"""
|
||||
parser = super(Barbican, self).build_option_parser(
|
||||
|
@ -323,6 +324,7 @@ class Barbican(app.App):
|
|||
|
||||
def prepare_to_run_command(self, cmd):
|
||||
"""Prepares to run the command
|
||||
|
||||
Checks if the minimal parameters are provided and creates the
|
||||
client interface.
|
||||
This is inherited from the framework.
|
||||
|
|
|
@ -17,8 +17,6 @@ from cliff import command
|
|||
from cliff import lister
|
||||
from cliff import show
|
||||
|
||||
from barbicanclient import orders
|
||||
|
||||
|
||||
class CreateOrder(show.ShowOne):
|
||||
"""Create a new order."""
|
||||
|
|
|
@ -57,9 +57,7 @@ class BaseEntityManager(object):
|
|||
self._entity = entity
|
||||
|
||||
def total(self):
|
||||
"""
|
||||
Returns the total number of entities stored in Barbican.
|
||||
"""
|
||||
"""Returns the total number of entities stored in Barbican."""
|
||||
params = {'limit': 0, 'offset': 0}
|
||||
resp = self._api.get(self._entity, params=params)
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# limitations under the License.
|
||||
import functools
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from oslo_utils.timeutils import parse_isotime
|
||||
|
||||
|
@ -64,7 +63,8 @@ class CAFormatter(formatter.EntityFormatter):
|
|||
|
||||
|
||||
class CA(CAFormatter):
|
||||
"""
|
||||
"""Certificate authority
|
||||
|
||||
CAs represent certificate authorities or subCAs with which the Barbican
|
||||
service is configured to interact.
|
||||
"""
|
||||
|
@ -74,7 +74,8 @@ class CA(CAFormatter):
|
|||
plugin_name=None, plugin_ca_id=None,
|
||||
ca_ref=None, created=None, updated=None,
|
||||
status=None, creator_id=None):
|
||||
"""
|
||||
"""Certificate authority
|
||||
|
||||
CA objects should not be instantiated directly. You should use
|
||||
the `create` or `get` methods of the
|
||||
:class:`barbicanclient.cas.CAManager` instead.
|
||||
|
@ -194,8 +195,7 @@ class CAManager(base.BaseEntityManager):
|
|||
super(CAManager, self).__init__(api, 'cas')
|
||||
|
||||
def get(self, ca_ref):
|
||||
"""
|
||||
Retrieve an existing CA from Barbican
|
||||
"""Retrieve an existing CA from Barbican
|
||||
|
||||
:param str ca_ref: Full HATEOAS reference to a CA
|
||||
:returns: CA object retrieved from Barbican
|
||||
|
@ -212,8 +212,7 @@ class CAManager(base.BaseEntityManager):
|
|||
)
|
||||
|
||||
def list(self, limit=10, offset=0, name=None):
|
||||
"""
|
||||
List CAs for the project
|
||||
"""List CAs for the project
|
||||
|
||||
This method uses the limit and offset parameters for paging,
|
||||
and also supports filtering.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import json
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
@ -23,7 +23,6 @@ from barbicanclient import acls
|
|||
from barbicanclient import cas
|
||||
from barbicanclient import containers
|
||||
from barbicanclient import exceptions
|
||||
from barbicanclient._i18n import _
|
||||
from barbicanclient import orders
|
||||
from barbicanclient import secrets
|
||||
|
||||
|
@ -123,8 +122,7 @@ class _HTTPClient(adapter.Adapter):
|
|||
class Client(object):
|
||||
|
||||
def __init__(self, session=None, *args, **kwargs):
|
||||
"""
|
||||
Barbican client object used to interact with barbican service.
|
||||
"""Barbican client object used to interact with barbican service.
|
||||
|
||||
:param session: An instance of keystoneclient.session.Session that
|
||||
can be either authenticated, or not authenticated. When using
|
||||
|
|
|
@ -513,8 +513,7 @@ class CertificateContainer(CertificateContainerFormatter, Container):
|
|||
|
||||
|
||||
class ContainerManager(base.BaseEntityManager):
|
||||
"""
|
||||
EntityManager for Container entities
|
||||
"""EntityManager for Container entities
|
||||
|
||||
You should use the ContainerManager exposed by the Client and should not
|
||||
need to instantiate your own.
|
||||
|
@ -530,8 +529,7 @@ class ContainerManager(base.BaseEntityManager):
|
|||
super(ContainerManager, self).__init__(api, 'containers')
|
||||
|
||||
def get(self, container_ref):
|
||||
"""
|
||||
Retrieve an existing Container from Barbican
|
||||
"""Retrieve an existing Container from Barbican
|
||||
|
||||
:param str container_ref: Full HATEOAS reference to a Container
|
||||
:returns: Container object or a subclass of the appropriate type
|
||||
|
@ -616,8 +614,7 @@ class ContainerManager(base.BaseEntityManager):
|
|||
)
|
||||
|
||||
def create(self, name=None, secrets=None):
|
||||
"""
|
||||
Factory method for `Container` objects
|
||||
"""Factory method for `Container` objects
|
||||
|
||||
`Container` objects returned by this method have not yet been
|
||||
stored in Barbican.
|
||||
|
@ -638,8 +635,7 @@ class ContainerManager(base.BaseEntityManager):
|
|||
|
||||
def create_rsa(self, name=None, public_key=None, private_key=None,
|
||||
private_key_passphrase=None):
|
||||
"""
|
||||
Factory method for `RSAContainer` objects
|
||||
"""Factory method for `RSAContainer` objects
|
||||
|
||||
`RSAContainer` objects returned by this method have not yet been
|
||||
stored in Barbican.
|
||||
|
@ -665,8 +661,7 @@ class ContainerManager(base.BaseEntityManager):
|
|||
def create_certificate(self, name=None, certificate=None,
|
||||
intermediates=None, private_key=None,
|
||||
private_key_passphrase=None):
|
||||
"""
|
||||
Factory method for `CertificateContainer` objects
|
||||
"""Factory method for `CertificateContainer` objects
|
||||
|
||||
`CertificateContainer` objects returned by this method have not yet
|
||||
been stored in Barbican.
|
||||
|
@ -692,8 +687,7 @@ class ContainerManager(base.BaseEntityManager):
|
|||
)
|
||||
|
||||
def delete(self, container_ref):
|
||||
"""
|
||||
Delete a Container from Barbican
|
||||
"""Delete a Container from Barbican
|
||||
|
||||
:param container_ref: Full HATEOAS reference to a Container
|
||||
:raises barbicanclient.exceptions.HTTPAuthError: 401 Responses
|
||||
|
@ -705,8 +699,9 @@ class ContainerManager(base.BaseEntityManager):
|
|||
self._api.delete(container_ref)
|
||||
|
||||
def list(self, limit=10, offset=0, name=None, type=None):
|
||||
"""
|
||||
List containers for the project. This method uses the limit and offset
|
||||
"""List containers for the project.
|
||||
|
||||
This method uses the limit and offset
|
||||
parameters for paging.
|
||||
|
||||
:param limit: Max number of containers returned
|
||||
|
@ -732,8 +727,7 @@ class ContainerManager(base.BaseEntityManager):
|
|||
for container in response.get('containers', [])]
|
||||
|
||||
def register_consumer(self, container_ref, name, url):
|
||||
"""
|
||||
Add a consumer to the container
|
||||
"""Add a consumer to the container
|
||||
|
||||
:param container_ref: Full HATEOAS reference to a Container
|
||||
:param name: Name of the consuming service
|
||||
|
@ -755,8 +749,7 @@ class ContainerManager(base.BaseEntityManager):
|
|||
return self._generate_typed_container(response)
|
||||
|
||||
def remove_consumer(self, container_ref, name, url):
|
||||
"""
|
||||
Remove a consumer from the container
|
||||
"""Remove a consumer from the container
|
||||
|
||||
:param container_ref: Full HATEOAS reference to a Container
|
||||
:param name: Name of the previously consuming service
|
||||
|
|
|
@ -115,8 +115,7 @@ class CertificateOrderFormatter(formatter.EntityFormatter):
|
|||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Order(object):
|
||||
"""
|
||||
Base order object to hold common functionality
|
||||
"""Base order object to hold common functionality
|
||||
|
||||
This should be considered an abstract class that should not be
|
||||
instantiated directly.
|
||||
|
@ -227,9 +226,10 @@ class Order(object):
|
|||
|
||||
@immutable_after_save
|
||||
def submit(self):
|
||||
"""
|
||||
Submit the Order to Barbican. New Order objects are not persisted
|
||||
in Barbican until this method is called.
|
||||
"""Submit the Order to Barbican.
|
||||
|
||||
New Order objects are not persisted in Barbican until this method
|
||||
is called.
|
||||
"""
|
||||
order_dict = {'type': self._type, 'meta': self._meta}
|
||||
LOG.debug("Request body: {0}".format(order_dict))
|
||||
|
@ -239,9 +239,7 @@ class Order(object):
|
|||
return self._order_ref
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
Deletes the Order from Barbican
|
||||
"""
|
||||
"""Deletes the Order from Barbican"""
|
||||
if self._order_ref:
|
||||
self._api.delete(self._order_ref)
|
||||
self._order_ref = None
|
||||
|
@ -250,9 +248,7 @@ class Order(object):
|
|||
|
||||
|
||||
class KeyOrder(Order, KeyOrderFormatter):
|
||||
"""
|
||||
KeyOrders can be used to request random key material from Barbican
|
||||
"""
|
||||
"""KeyOrders can be used to request random key material from Barbican"""
|
||||
_type = 'key'
|
||||
_validMeta = (u'name', u'algorithm', u'mode', u'bit_length', u'expiration',
|
||||
u'payload_content_type')
|
||||
|
@ -329,8 +325,7 @@ class AsymmetricOrder(Order, AsymmetricOrderFormatter):
|
|||
|
||||
@property
|
||||
def pass_phrase(self):
|
||||
"""Passphrase to be used for passphrase protected asymmetric keys
|
||||
"""
|
||||
"""Passphrase to be used for passphrase protected asymmetric keys"""
|
||||
return self._meta.get('pass_phrase')
|
||||
|
||||
@pass_phrase.setter
|
||||
|
@ -379,9 +374,7 @@ class CertificateOrder(Order, CertificateOrderFormatter):
|
|||
|
||||
|
||||
class OrderManager(base.BaseEntityManager):
|
||||
"""
|
||||
Entity Manager for Order entitites
|
||||
"""
|
||||
"""Entity Manager for Order entitites"""
|
||||
|
||||
_order_type_to_class_map = {
|
||||
'key': KeyOrder,
|
||||
|
@ -393,8 +386,7 @@ class OrderManager(base.BaseEntityManager):
|
|||
super(OrderManager, self).__init__(api, 'orders')
|
||||
|
||||
def get(self, order_ref):
|
||||
"""
|
||||
Retrieve an existing Order from Barbican
|
||||
"""Retrieve an existing Order from Barbican
|
||||
|
||||
:param order_ref: Full HATEOAS reference to an Order
|
||||
:returns: An instance of the appropriate subtype of Order
|
||||
|
@ -449,8 +441,7 @@ class OrderManager(base.BaseEntityManager):
|
|||
|
||||
def create_key(self, name=None, algorithm=None, bit_length=None, mode=None,
|
||||
payload_content_type=None, expiration=None):
|
||||
"""
|
||||
Factory method for `KeyOrder` objects
|
||||
"""Factory method for `KeyOrder` objects
|
||||
|
||||
`KeyOrder` objects returned by this method have not yet been submitted
|
||||
to the Barbican service.
|
||||
|
@ -475,8 +466,7 @@ class OrderManager(base.BaseEntityManager):
|
|||
def create_asymmetric(self, name=None, algorithm=None, bit_length=None,
|
||||
pass_phrase=None, payload_content_type=None,
|
||||
expiration=None):
|
||||
"""
|
||||
Factory method for `AsymmetricOrder` objects
|
||||
"""Factory method for `AsymmetricOrder` objects
|
||||
|
||||
`AsymmetricOrder` objects returned by this method have not yet been
|
||||
submitted to the Barbican service.
|
||||
|
@ -501,8 +491,7 @@ class OrderManager(base.BaseEntityManager):
|
|||
def create_certificate(self, name=None, request_type=None, subject_dn=None,
|
||||
source_container_ref=None, ca_id=None,
|
||||
profile=None, request_data=None):
|
||||
"""
|
||||
Factory method for `CertificateOrder` objects
|
||||
"""Factory method for `CertificateOrder` objects
|
||||
|
||||
`CertificateOrder` objects returned by this method have not yet been
|
||||
submitted to the Barbican service.
|
||||
|
@ -527,8 +516,7 @@ class OrderManager(base.BaseEntityManager):
|
|||
request_data=request_data)
|
||||
|
||||
def delete(self, order_ref):
|
||||
"""
|
||||
Delete an Order from Barbican
|
||||
"""Delete an Order from Barbican
|
||||
|
||||
:param order_ref: The href for the order
|
||||
"""
|
||||
|
@ -537,8 +525,7 @@ class OrderManager(base.BaseEntityManager):
|
|||
self._api.delete(order_ref)
|
||||
|
||||
def list(self, limit=10, offset=0):
|
||||
"""
|
||||
List Orders for the project
|
||||
"""List Orders for the project
|
||||
|
||||
This method uses the limit and offset parameters for paging.
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ import logging
|
|||
from oslo_utils.timeutils import parse_isotime
|
||||
import six
|
||||
|
||||
from barbicanclient._i18n import _LW
|
||||
from barbicanclient import acls as acl_manager
|
||||
from barbicanclient import base
|
||||
from barbicanclient import exceptions
|
||||
from barbicanclient import formatter
|
||||
from barbicanclient._i18n import _LW
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -78,7 +78,8 @@ class SecretFormatter(formatter.EntityFormatter):
|
|||
|
||||
|
||||
class Secret(SecretFormatter):
|
||||
"""
|
||||
"""Secrets managed by Barbican
|
||||
|
||||
Secrets represent keys, credentials, and other sensitive data that is
|
||||
stored by the Barbican service.
|
||||
"""
|
||||
|
@ -90,9 +91,9 @@ class Secret(SecretFormatter):
|
|||
secret_ref=None, created=None, updated=None,
|
||||
content_types=None, status=None, secret_type=None,
|
||||
creator_id=None):
|
||||
"""
|
||||
Secret objects should not be instantiated directly. You should use
|
||||
the `create` or `get` methods of the
|
||||
"""Secret objects should not be instantiated directly.
|
||||
|
||||
You should use the `create` or `get` methods of the
|
||||
:class:`barbicanclient.secrets.SecretManager` instead.
|
||||
"""
|
||||
self._api = api
|
||||
|
@ -187,9 +188,7 @@ class Secret(SecretFormatter):
|
|||
|
||||
@property
|
||||
def payload(self):
|
||||
"""
|
||||
Lazy-loaded property that holds the unencrypted data
|
||||
"""
|
||||
"""Lazy-loaded property that holds the unencrypted data"""
|
||||
if self._payload is None and self.secret_ref is not None:
|
||||
try:
|
||||
self._fetch_payload()
|
||||
|
@ -282,9 +281,10 @@ class Secret(SecretFormatter):
|
|||
|
||||
@immutable_after_save
|
||||
def store(self):
|
||||
"""
|
||||
Stores the Secret in Barbican. New Secret objects are not persisted
|
||||
in Barbican until this method is called.
|
||||
"""Stores the Secret in Barbican.
|
||||
|
||||
New Secret objects are not persisted in Barbican until this method
|
||||
is called.
|
||||
|
||||
:raises: PayloadException
|
||||
"""
|
||||
|
@ -307,31 +307,31 @@ class Secret(SecretFormatter):
|
|||
raise exceptions.PayloadException("Invalid Payload Type")
|
||||
|
||||
if self.payload_content_type or self.payload_content_encoding:
|
||||
"""
|
||||
'''
|
||||
Setting the payload_content_type and payload_content_encoding
|
||||
manually is deprecated. This clause of the if statement is here
|
||||
for backwards compatibility and should be removed in a future
|
||||
release.
|
||||
"""
|
||||
'''
|
||||
secret_dict['payload'] = self.payload
|
||||
secret_dict['payload_content_type'] = self.payload_content_type
|
||||
secret_dict['payload_content_encoding'] = (
|
||||
self.payload_content_encoding
|
||||
)
|
||||
elif type(self.payload) is six.binary_type:
|
||||
"""
|
||||
'''
|
||||
six.binary_type is stored as application/octet-stream
|
||||
and it is base64 encoded for a one-step POST
|
||||
"""
|
||||
'''
|
||||
secret_dict['payload'] = (
|
||||
base64.b64encode(self.payload)
|
||||
).decode('UTF-8')
|
||||
secret_dict['payload_content_type'] = u'application/octet-stream'
|
||||
secret_dict['payload_content_encoding'] = u'base64'
|
||||
elif type(self.payload) is six.text_type:
|
||||
"""
|
||||
'''
|
||||
six.text_type is stored as text/plain
|
||||
"""
|
||||
'''
|
||||
secret_dict['payload'] = self.payload
|
||||
secret_dict['payload_content_type'] = u'text/plain'
|
||||
|
||||
|
@ -346,9 +346,7 @@ class Secret(SecretFormatter):
|
|||
return self.secret_ref
|
||||
|
||||
def update(self):
|
||||
"""
|
||||
Updates the secret in Barbican.
|
||||
"""
|
||||
"""Updates the secret in Barbican."""
|
||||
|
||||
if not self.payload:
|
||||
raise exceptions.PayloadException("Invalid or Missing Payload")
|
||||
|
@ -367,9 +365,7 @@ class Secret(SecretFormatter):
|
|||
data=self.payload)
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
Deletes the Secret from Barbican
|
||||
"""
|
||||
"""Deletes the Secret from Barbican"""
|
||||
if self._secret_ref:
|
||||
self._api.delete(self._secret_ref)
|
||||
self._secret_ref = None
|
||||
|
@ -449,8 +445,7 @@ class SecretManager(base.BaseEntityManager):
|
|||
super(SecretManager, self).__init__(api, 'secrets')
|
||||
|
||||
def get(self, secret_ref, payload_content_type=None):
|
||||
"""
|
||||
Retrieve an existing Secret from Barbican
|
||||
"""Retrieve an existing Secret from Barbican
|
||||
|
||||
:param str secret_ref: Full HATEOAS reference to a Secret
|
||||
:param str payload_content_type: DEPRECATED: Content type to use for
|
||||
|
@ -471,8 +466,7 @@ class SecretManager(base.BaseEntityManager):
|
|||
)
|
||||
|
||||
def update(self, secret_ref, payload=None):
|
||||
"""
|
||||
Update an existing Secret from Barbican
|
||||
"""Update an existing Secret from Barbican
|
||||
|
||||
:param str secret_ref: Full HATEOAS reference to a Secret
|
||||
:param str payload: New payload to add to secret
|
||||
|
@ -500,8 +494,7 @@ class SecretManager(base.BaseEntityManager):
|
|||
payload_content_type=None, payload_content_encoding=None,
|
||||
algorithm=None, bit_length=None, secret_type=None,
|
||||
mode=None, expiration=None):
|
||||
"""
|
||||
Factory method for creating new `Secret` objects
|
||||
"""Factory method for creating new `Secret` objects
|
||||
|
||||
Secrets returned by this method have not yet been stored in the
|
||||
Barbican service.
|
||||
|
@ -532,8 +525,7 @@ class SecretManager(base.BaseEntityManager):
|
|||
secret_type=secret_type, expiration=expiration)
|
||||
|
||||
def delete(self, secret_ref):
|
||||
"""
|
||||
Delete a Secret from Barbican
|
||||
"""Delete a Secret from Barbican
|
||||
|
||||
:param secret_ref: The href for the secret to be deleted
|
||||
:raises barbicanclient.exceptions.HTTPAuthError: 401 Responses
|
||||
|
@ -547,8 +539,7 @@ class SecretManager(base.BaseEntityManager):
|
|||
|
||||
def list(self, limit=10, offset=0, name=None, algorithm=None,
|
||||
mode=None, bits=0):
|
||||
"""
|
||||
List Secrets for the project
|
||||
"""List Secrets for the project
|
||||
|
||||
This method uses the limit and offset parameters for paging,
|
||||
and also supports filtering.
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
# limitations under the License.
|
||||
import six
|
||||
|
||||
from barbicanclient import client
|
||||
from barbicanclient import barbican as barb
|
||||
from barbicanclient.barbican import Barbican
|
||||
from barbicanclient import client
|
||||
from barbicanclient.tests import keystone_client_fixtures
|
||||
from barbicanclient.tests import test_client
|
||||
from barbicanclient.barbican import Barbican
|
||||
|
||||
|
||||
class WhenTestingBarbicanCLI(test_client.BaseEntityResource):
|
||||
|
@ -171,7 +171,6 @@ class WhenTestingBarbicanCLI(test_client.BaseEntityResource):
|
|||
self.assertIsNone(httpclient.service_name)
|
||||
|
||||
def test_endpoint_filter_kwargs_set_correctly(self):
|
||||
from testtools.content import text_content
|
||||
auth_args = ('--no-auth --endpoint http://barbican_endpoint:9311/v1 '
|
||||
'--os-project-id project1')
|
||||
endpoint_filter_args = ('--interface private '
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
# Copyright (c) 2017
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import testtools
|
||||
|
||||
import barbicanclient
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
# limitations under the License.
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from barbicanclient.tests import test_client
|
||||
from barbicanclient import cas
|
||||
from barbicanclient.tests import test_client
|
||||
|
||||
|
||||
class CAData(object):
|
||||
|
|
|
@ -20,8 +20,10 @@ from oslo_utils import timeutils
|
|||
import six
|
||||
|
||||
from barbicanclient import acls
|
||||
from barbicanclient import base
|
||||
from barbicanclient import containers
|
||||
from barbicanclient import secrets
|
||||
from barbicanclient.tests import test_client
|
||||
from barbicanclient import base, containers, secrets
|
||||
|
||||
|
||||
class ContainerData(object):
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
# Copyright (c) 2017
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import testtools
|
||||
|
||||
from barbicanclient import formatter
|
||||
|
|
|
@ -14,14 +14,12 @@
|
|||
# limitations under the License.
|
||||
import json
|
||||
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
import testtools
|
||||
import uuid
|
||||
|
||||
from barbicanclient import orders, base
|
||||
from barbicanclient import base
|
||||
from barbicanclient import orders
|
||||
from barbicanclient.tests import test_client
|
||||
from barbicanclient.tests import test_secrets
|
||||
|
||||
|
||||
class OrdersTestCase(test_client.BaseEntityResource):
|
||||
|
@ -280,12 +278,10 @@ class WhenTestingOrderManager(OrdersTestCase):
|
|||
def test_should_get_invalid_meta(self):
|
||||
self.responses.get(self.entity_href, text=self.key_order_invalid_data)
|
||||
|
||||
try:
|
||||
# Verify checking for invalid meta fields.
|
||||
order = self.manager.get(order_ref=self.entity_href)
|
||||
self.fail("Didn't raise an TypeError exception")
|
||||
except TypeError:
|
||||
pass
|
||||
# Verify checking for invalid meta fields.
|
||||
self.assertRaises(TypeError,
|
||||
self.manager.get,
|
||||
self.entity_href)
|
||||
|
||||
def test_should_get_list(self):
|
||||
data = {"orders": [json.loads(self.key_order_data) for _ in range(3)]}
|
||||
|
@ -318,6 +314,7 @@ class WhenTestingOrderManager(OrdersTestCase):
|
|||
def test_should_get_total(self):
|
||||
self.responses.get(self.entity_base, json={'total': 1})
|
||||
total = self.manager.total()
|
||||
self.assertEqual(1, total)
|
||||
|
||||
def test_get_formatted_data(self):
|
||||
self.responses.get(self.entity_href, text=self.key_order_data)
|
||||
|
|
|
@ -17,9 +17,11 @@ import json
|
|||
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from barbicanclient.tests import test_client
|
||||
from barbicanclient import acls
|
||||
from barbicanclient import secrets, base, exceptions
|
||||
from barbicanclient import base
|
||||
from barbicanclient import exceptions
|
||||
from barbicanclient import secrets
|
||||
from barbicanclient.tests import test_client
|
||||
|
||||
|
||||
class SecretData(object):
|
||||
|
@ -90,8 +92,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
|
|||
self.assertEqual(self.secret.payload, secret_req['payload'])
|
||||
|
||||
def test_should_store_binary_type_as_octet_stream(self):
|
||||
"""
|
||||
We use six.binary_type as the canonical binary type.
|
||||
"""We use six.binary_type as the canonical binary type.
|
||||
|
||||
The client should base64 encode the payload before sending the
|
||||
request.
|
||||
"""
|
||||
|
@ -116,9 +118,7 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
|
|||
self.assertNotEqual(binary_payload, secret_req['payload'])
|
||||
|
||||
def test_should_store_text_type_as_text_plain(self):
|
||||
"""
|
||||
We use six.text_type as the canonical text type.
|
||||
"""
|
||||
"""We use six.text_type as the canonical text type."""
|
||||
data = {'secret_ref': self.entity_href}
|
||||
self.responses.post(self.entity_base + '/', json=data)
|
||||
|
||||
|
@ -135,8 +135,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
|
|||
self.assertEqual(u'text/plain', secret_req['payload_content_type'])
|
||||
|
||||
def test_should_store_with_deprecated_content_type(self):
|
||||
"""
|
||||
DEPRECATION WARNING:
|
||||
"""DEPRECATION WARNING
|
||||
|
||||
Manually setting the payload_content_type is deprecated and will be
|
||||
removed in a future release.
|
||||
"""
|
||||
|
@ -157,8 +157,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
|
|||
secret_req['payload_content_type'])
|
||||
|
||||
def test_should_store_with_deprecated_content_encoding(self):
|
||||
"""
|
||||
DEPRECATION WARNING:
|
||||
"""DEPRECATION WARNING
|
||||
|
||||
Manually setting the payload_content_encoding is deprecated and will be
|
||||
removed in a future release.
|
||||
"""
|
||||
|
@ -261,8 +261,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
|
|||
self.assertEqual(acl_ref, n.last_request.url)
|
||||
|
||||
def test_should_get_payload_only_when_content_type_is_set(self):
|
||||
"""
|
||||
DEPRECATION WARNING:
|
||||
"""DEPRECATION WARNING
|
||||
|
||||
Manually setting the payload_content_type is deprecated and will be
|
||||
removed in a future release.
|
||||
"""
|
||||
|
@ -339,8 +339,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
|
|||
decryption_response.last_request.url)
|
||||
|
||||
def test_should_decrypt_when_content_type_is_set(self):
|
||||
"""
|
||||
DEPRECATION WARNING:
|
||||
"""DEPRECATION WARNING
|
||||
|
||||
Manually setting the payload_content_type is deprecated and will be
|
||||
removed in a future release.
|
||||
"""
|
||||
|
@ -491,9 +491,10 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
|
|||
|
||||
def test_get_formatted_data(self):
|
||||
data = self.secret.get_dict(self.entity_href)
|
||||
m = self.responses.get(self.entity_href, json=data)
|
||||
self.responses.get(self.entity_href, json=data)
|
||||
|
||||
secret = self.manager.get(secret_ref=self.entity_href)
|
||||
f_data = secret._get_formatted_data()
|
||||
self.assertEqual(timeutils.parse_isotime(data['created']).isoformat(),
|
||||
f_data[2])
|
||||
self.assertEqual(
|
||||
timeutils.parse_isotime(data['created']).isoformat(),
|
||||
f_data[2])
|
||||
|
|
Loading…
Reference in New Issue