diff options
Diffstat (limited to 'barbicanclient')
-rw-r--r-- | barbicanclient/acls.py | 12 | ||||
-rw-r--r-- | barbicanclient/barbican.py | 4 | ||||
-rw-r--r-- | barbicanclient/barbican_cli/orders.py | 2 | ||||
-rw-r--r-- | barbicanclient/base.py | 4 | ||||
-rw-r--r-- | barbicanclient/cas.py | 13 | ||||
-rw-r--r-- | barbicanclient/client.py | 6 | ||||
-rw-r--r-- | barbicanclient/containers.py | 29 | ||||
-rw-r--r-- | barbicanclient/orders.py | 43 | ||||
-rw-r--r-- | barbicanclient/secrets.py | 57 | ||||
-rw-r--r-- | barbicanclient/tests/test_barbican.py | 5 | ||||
-rw-r--r-- | barbicanclient/tests/test_base.py | 15 | ||||
-rw-r--r-- | barbicanclient/tests/test_cas.py | 2 | ||||
-rw-r--r-- | barbicanclient/tests/test_containers.py | 4 | ||||
-rw-r--r-- | barbicanclient/tests/test_formatter.py | 15 | ||||
-rw-r--r-- | barbicanclient/tests/test_orders.py | 17 | ||||
-rw-r--r-- | barbicanclient/tests/test_secrets.py | 37 |
16 files changed, 128 insertions, 137 deletions
diff --git a/barbicanclient/acls.py b/barbicanclient/acls.py index a7393e0..9292d12 100644 --- a/barbicanclient/acls.py +++ b/barbicanclient/acls.py @@ -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 diff --git a/barbicanclient/barbican.py b/barbicanclient/barbican.py index d52c199..edc13f5 100644 --- a/barbicanclient/barbican.py +++ b/barbicanclient/barbican.py @@ -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. diff --git a/barbicanclient/barbican_cli/orders.py b/barbicanclient/barbican_cli/orders.py index d3c4b5c..713f907 100644 --- a/barbicanclient/barbican_cli/orders.py +++ b/barbicanclient/barbican_cli/orders.py @@ -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.""" diff --git a/barbicanclient/base.py b/barbicanclient/base.py index 738526b..9bfcc98 100644 --- a/barbicanclient/base.py +++ b/barbicanclient/base.py @@ -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) diff --git a/barbicanclient/cas.py b/barbicanclient/cas.py index 71d6478..8c46346 100644 --- a/barbicanclient/cas.py +++ b/barbicanclient/cas.py @@ -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. diff --git a/barbicanclient/client.py b/barbicanclient/client.py index d47b764..c42386b 100644 --- a/barbicanclient/client.py +++ b/barbicanclient/client.py @@ -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 diff --git a/barbicanclient/containers.py b/barbicanclient/containers.py index 6ccc2a4..d5df64c 100644 --- a/barbicanclient/containers.py +++ b/barbicanclient/containers.py @@ -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 diff --git a/barbicanclient/orders.py b/barbicanclient/orders.py index be48ba0..056d742 100644 --- a/barbicanclient/orders.py +++ b/barbicanclient/orders.py @@ -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. diff --git a/barbicanclient/secrets.py b/barbicanclient/secrets.py index 5d53720..f373007 100644 --- a/barbicanclient/secrets.py +++ b/barbicanclient/secrets.py @@ -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. diff --git a/barbicanclient/tests/test_barbican.py b/barbicanclient/tests/test_barbican.py index 0e5bd30..6f4e966 100644 --- a/barbicanclient/tests/test_barbican.py +++ b/barbicanclient/tests/test_barbican.py @@ -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 ' diff --git a/barbicanclient/tests/test_base.py b/barbicanclient/tests/test_base.py index cb75c2d..6f0fa8c 100644 --- a/barbicanclient/tests/test_base.py +++ b/barbicanclient/tests/test_base.py @@ -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 diff --git a/barbicanclient/tests/test_cas.py b/barbicanclient/tests/test_cas.py index 86ac118..c28f38f 100644 --- a/barbicanclient/tests/test_cas.py +++ b/barbicanclient/tests/test_cas.py @@ -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): diff --git a/barbicanclient/tests/test_containers.py b/barbicanclient/tests/test_containers.py index 6441c23..6d967c7 100644 --- a/barbicanclient/tests/test_containers.py +++ b/barbicanclient/tests/test_containers.py @@ -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): diff --git a/barbicanclient/tests/test_formatter.py b/barbicanclient/tests/test_formatter.py index 94f3752..a09b1b6 100644 --- a/barbicanclient/tests/test_formatter.py +++ b/barbicanclient/tests/test_formatter.py @@ -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 diff --git a/barbicanclient/tests/test_orders.py b/barbicanclient/tests/test_orders.py index 21eee98..2ae4913 100644 --- a/barbicanclient/tests/test_orders.py +++ b/barbicanclient/tests/test_orders.py @@ -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) diff --git a/barbicanclient/tests/test_secrets.py b/barbicanclient/tests/test_secrets.py index 61efdb0..0cd981c 100644 --- a/barbicanclient/tests/test_secrets.py +++ b/barbicanclient/tests/test_secrets.py @@ -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]) |