diff options
-rw-r--r-- | .zuul.yaml | 2 | ||||
-rw-r--r-- | README.rst | 20 | ||||
-rw-r--r-- | barbicanclient/tests/test_barbican.py | 11 | ||||
-rw-r--r-- | barbicanclient/tests/v1/test_cas.py | 8 | ||||
-rw-r--r-- | barbicanclient/tests/v1/test_containers.py | 3 | ||||
-rw-r--r-- | barbicanclient/tests/v1/test_secrets.py | 40 | ||||
-rw-r--r-- | barbicanclient/v1/orders.py | 8 | ||||
-rw-r--r-- | barbicanclient/v1/secrets.py | 31 | ||||
-rw-r--r-- | doc/source/cli/cli_usage.rst | 82 | ||||
-rw-r--r-- | doc/source/cli/usage.rst | 18 | ||||
-rwxr-xr-x | doc/source/conf.py | 6 | ||||
-rw-r--r-- | doc/source/contributor/testing.rst | 24 | ||||
-rw-r--r-- | functionaltests/base.py | 2 | ||||
-rw-r--r-- | functionaltests/cli/v1/behaviors/base_behaviors.py | 6 | ||||
-rw-r--r-- | functionaltests/client/v1/functional/test_secrets.py | 2 | ||||
-rw-r--r-- | functionaltests/utils.py | 9 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | test-requirements.txt | 1 | ||||
-rw-r--r-- | tox.ini | 2 |
19 files changed, 127 insertions, 149 deletions
@@ -13,7 +13,7 @@ - project: templates: - check-requirements - - openstack-python3-zed-jobs + - openstack-python3-jobs - openstackclient-plugin-jobs - publish-openstack-docs-pti check: @@ -38,12 +38,12 @@ with keystone authentication: >>> from barbicanclient import client >>> # We'll use Keystone API v3 for authentication - >>> auth = identity.v3.Password(auth_url=u'http://localhost:5000/v3', - ... username=u'admin_user', - ... user_domain_name=u'Default', - ... password=u'password', - ... project_name=u'demo', - ... project_domain_name=u'Default') + >>> auth = identity.v3.Password(auth_url='http://localhost:5000/v3', + ... username='admin_user', + ... user_domain_name='Default', + ... password='password', + ... project_name='demo', + ... project_domain_name='Default') >>> # Next we'll create a Keystone session using the auth plugin we just created >>> sess = session.Session(auth=auth) @@ -52,13 +52,13 @@ with keystone authentication: >>> barbican = client.Client(session=sess) >>> # Let's create a Secret to store some sensitive data - >>> secret = barbican.secrets.create(name=u'Self destruction sequence', - ... payload=u'the magic words are squeamish ossifrage') + >>> secret = barbican.secrets.create(name='Self destruction sequence', + ... payload='the magic words are squeamish ossifrage') >>> # Now let's store the secret by using its store() method. This will send the secret data >>> # to Barbican, where it will be encrypted and stored securely in the cloud. >>> secret.store() - u'http://localhost:9311/v1/secrets/85b220fd-f414-483f-94e4-2f422480f655' + 'http://localhost:9311/v1/secrets/85b220fd-f414-483f-94e4-2f422480f655' >>> # The URI returned by store() uniquely identifies your secret in the Barbican service. >>> # After a secret is stored, the URI is also available by accessing @@ -67,7 +67,7 @@ with keystone authentication: http://localhost:9311/v1/secrets/091adb32-4050-4980-8558-90833c531413 >>> # When we need to retrieve our secret at a later time, we can use the secret_ref - >>> retrieved_secret = barbican.secrets.get(u'http://localhost:9311/v1/secrets/091adb32-4050-4980-8558-90833c531413') + >>> retrieved_secret = barbican.secrets.get('http://localhost:9311/v1/secrets/091adb32-4050-4980-8558-90833c531413') >>> # We can access the secret payload by using the payload attribute. >>> # Barbican decrypts the secret and sends it back. >>> print(retrieved_secret.payload) diff --git a/barbicanclient/tests/test_barbican.py b/barbicanclient/tests/test_barbican.py index 22dfca4..71ce182 100644 --- a/barbicanclient/tests/test_barbican.py +++ b/barbicanclient/tests/test_barbican.py @@ -12,8 +12,7 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -import six -from testtools import testcase +import io from barbicanclient import barbican as barb from barbicanclient.barbican import Barbican @@ -27,8 +26,8 @@ class WhenTestingBarbicanCLI(test_client.BaseEntityResource): def setUp(self): self._setUp('barbican') - self.captured_stdout = six.StringIO() - self.captured_stderr = six.StringIO() + self.captured_stdout = io.StringIO() + self.captured_stderr = io.StringIO() self.barbican = Barbican( stdout=self.captured_stdout, stderr=self.captured_stderr @@ -49,10 +48,8 @@ class WhenTestingBarbicanCLI(test_client.BaseEntityResource): self.assertIsNotNone(client) return client - @testcase.skip("https://storyboard.openstack.org/#!/story/2010022") def test_should_show_usage_with_help_flag(self): - e = self.assertRaises(SystemExit, self.barbican.run, ['-h']) - self.assertEqual(0, e.code) + self.assertRaises(SystemExit, self.barbican.run, ['-h']) self.assertIn('usage', self.captured_stdout.getvalue()) def test_should_show_usage_with_no_args(self): diff --git a/barbicanclient/tests/v1/test_cas.py b/barbicanclient/tests/v1/test_cas.py index 118cfdb..a352661 100644 --- a/barbicanclient/tests/v1/test_cas.py +++ b/barbicanclient/tests/v1/test_cas.py @@ -19,10 +19,10 @@ from barbicanclient.v1 import cas class CAData(object): - def __init__(self, description=u'Test CA description'): - self.name = u'Test CA' + def __init__(self, description='Test CA description'): + self.name = 'Test CA' self.description = description - self.plugin_name = u'Test CA Plugin' + self.plugin_name = 'Test CA Plugin' self.plugin_ca_id = 'plugin_uuid' now = timeutils.utcnow() @@ -35,7 +35,7 @@ class CAData(object): self.meta.append({'description': self.description}) self.ca_dict = {'meta': self.meta, - 'status': u'ACTIVE', + 'status': 'ACTIVE', 'plugin_name': self.plugin_name, 'plugin_ca_id': self.plugin_ca_id, 'created': self.created} diff --git a/barbicanclient/tests/v1/test_containers.py b/barbicanclient/tests/v1/test_containers.py index 3cbdd92..291a07e 100644 --- a/barbicanclient/tests/v1/test_containers.py +++ b/barbicanclient/tests/v1/test_containers.py @@ -17,7 +17,6 @@ from unittest import mock from oslo_serialization import jsonutils from oslo_utils import timeutils -import six from barbicanclient import base from barbicanclient.tests import test_client @@ -524,7 +523,7 @@ class WhenTestingContainers(test_client.BaseEntityResource): # Verify that the names of the secret_refs in the containers are None for container in containers_list: - for name in six.iterkeys(container._secret_refs): + for name in container._secret_refs.keys(): self.assertIsNone(name) def test_should_fail_get_invalid_container(self): diff --git a/barbicanclient/tests/v1/test_secrets.py b/barbicanclient/tests/v1/test_secrets.py index dcc2fdf..bf5624e 100644 --- a/barbicanclient/tests/v1/test_secrets.py +++ b/barbicanclient/tests/v1/test_secrets.py @@ -27,14 +27,14 @@ from barbicanclient.v1 import secrets class SecretData(object): def __init__(self): - self.name = u'Self destruction sequence' - self.payload = u'the magic words are squeamish ossifrage' - self.payload_content_type = u'text/plain' - self.algorithm = u'AES' + self.name = 'Self destruction sequence' + self.payload = 'the magic words are squeamish ossifrage' + self.payload_content_type = 'text/plain' + self.algorithm = 'AES' self.created = str(timeutils.utcnow()) self.secret_dict = {'name': self.name, - 'status': u'ACTIVE', + 'status': 'ACTIVE', 'algorithm': self.algorithm, 'created': self.created} @@ -93,7 +93,7 @@ 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 bytes as the canonical binary type. The client should base64 encode the payload before sending the request. @@ -101,8 +101,6 @@ class WhenTestingSecrets(test_client.BaseEntityResource): data = {'secret_ref': self.entity_href} self.responses.post(self.entity_base + '/', json=data) - # This literal will have type(str) in Python 2, but will have - # type(bytes) in Python 3. It is six.binary_type in both cases. binary_payload = b'F\x130\x89f\x8e\xd9\xa1\x0e\x1f\r\xf67uu\x8b' secret = self.manager.create() @@ -112,20 +110,18 @@ class WhenTestingSecrets(test_client.BaseEntityResource): secret_req = jsonutils.loads(self.responses.last_request.text) self.assertEqual(self.secret.name, secret_req['name']) - self.assertEqual(u'application/octet-stream', + self.assertEqual('application/octet-stream', secret_req['payload_content_type']) - self.assertEqual(u'base64', + self.assertEqual('base64', secret_req['payload_content_encoding']) 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 unicode string as the canonical text type.""" data = {'secret_ref': self.entity_href} self.responses.post(self.entity_base + '/', json=data) - # This literal will have type(unicode) in Python 2, but will have - # type(str) in Python 3. It is six.text_type in both cases. - text_payload = u'time for an ice cold \U0001f37a' + text_payload = 'time for an ice cold \U0001f37a' secret = self.manager.create() secret.payload = text_payload @@ -133,7 +129,7 @@ class WhenTestingSecrets(test_client.BaseEntityResource): secret_req = jsonutils.loads(self.responses.last_request.text) self.assertEqual(text_payload, secret_req['payload']) - self.assertEqual(u'text/plain', secret_req['payload_content_type']) + self.assertEqual('text/plain', secret_req['payload_content_type']) def test_should_store_with_deprecated_content_type(self): """DEPRECATION WARNING @@ -145,7 +141,7 @@ class WhenTestingSecrets(test_client.BaseEntityResource): self.responses.post(self.entity_base + '/', json=data) payload = 'I should be octet-stream' - payload_content_type = u'text/plain' + payload_content_type = 'text/plain' secret = self.manager.create() secret.payload = payload @@ -169,8 +165,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource): encoded_payload = base64.b64encode( b'F\x130\x89f\x8e\xd9\xa1\x0e\x1f\r\xf67uu\x8b' ).decode('UTF-8') - payload_content_type = u'application/octet-stream' - payload_content_encoding = u'base64' + payload_content_type = 'application/octet-stream' + payload_content_encoding = 'base64' secret = self.manager.create() secret.payload = encoded_payload @@ -448,9 +444,7 @@ class WhenTestingSecrets(test_client.BaseEntityResource): self.test_should_delete_from_object(self.entity_id) def test_should_update_from_manager(self, secret_ref=None): - # This literal will have type(unicode) in Python 2, but will have - # type(str) in Python 3. It is six.text_type in both cases. - text_payload = u'time for an ice cold \U0001f37a' + text_payload = 'time for an ice cold \U0001f37a' secret_ref = secret_ref or self.entity_href self.responses.put(self.entity_href, status_code=204) @@ -479,9 +473,7 @@ class WhenTestingSecrets(test_client.BaseEntityResource): # Verify the secret has the correct ref for testing updates self.assertEqual(secref_ref, secret.secret_ref) - # This literal will have type(unicode) in Python 2, but will have - # type(str) in Python 3. It is six.text_type in both cases. - text_payload = u'time for an ice cold \U0001f37a' + text_payload = 'time for an ice cold \U0001f37a' self.responses.put(self.entity_href, status_code=204) diff --git a/barbicanclient/v1/orders.py b/barbicanclient/v1/orders.py index aee762a..b9c11be 100644 --- a/barbicanclient/v1/orders.py +++ b/barbicanclient/v1/orders.py @@ -17,7 +17,6 @@ import functools import logging from oslo_utils.timeutils import parse_isotime -import six from barbicanclient import base from barbicanclient import formatter @@ -113,8 +112,7 @@ class CertificateOrderFormatter(formatter.EntityFormatter): return data -@six.add_metaclass(abc.ABCMeta) -class Order(object): +class Order(object, metaclass=abc.ABCMeta): """Base order object to hold common functionality This should be considered an abstract class that should not be @@ -251,8 +249,8 @@ class Order(object): class KeyOrder(Order, KeyOrderFormatter): """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') + _validMeta = ('name', 'algorithm', 'mode', 'bit_length', 'expiration', + 'payload_content_type') def __init__(self, api, name=None, algorithm=None, bit_length=None, mode=None, expiration=None, payload_content_type=None, diff --git a/barbicanclient/v1/secrets.py b/barbicanclient/v1/secrets.py index f4bc7ad..8cd883e 100644 --- a/barbicanclient/v1/secrets.py +++ b/barbicanclient/v1/secrets.py @@ -17,7 +17,6 @@ import functools import logging from oslo_utils.timeutils import parse_isotime -import six from barbicanclient import base from barbicanclient import exceptions @@ -171,7 +170,7 @@ class Secret(SecretFormatter): if self._content_types: return self._content_types elif self._payload_content_type: - return {u'default': self.payload_content_type} + return {'default': self.payload_content_type} return None @property @@ -269,7 +268,7 @@ class Secret(SecretFormatter): uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) payload_url = uuid_ref + '/payload' payload = self._api._get_raw(payload_url, headers=headers) - if self.payload_content_type == u'text/plain': + if self.payload_content_type == 'text/plain': self._payload = payload.decode('UTF-8') else: self._payload = payload @@ -293,7 +292,7 @@ class Secret(SecretFormatter): } if self.payload is not None: - if not isinstance(self.payload, (six.text_type, six.binary_type)): + if not isinstance(self.payload, (str, bytes)): raise exceptions.PayloadException("Invalid Payload Type") if not len(self.payload): @@ -307,7 +306,7 @@ class Secret(SecretFormatter): for backwards compatibility and should be removed in a future release. ''' - if type(self.payload) is six.binary_type: + if type(self.payload) is bytes: secret_dict['payload'] = self.payload.decode('utf-8') else: secret_dict['payload'] = self.payload @@ -315,22 +314,22 @@ class Secret(SecretFormatter): secret_dict['payload_content_encoding'] = ( self.payload_content_encoding ) - elif type(self.payload) is six.binary_type: + elif type(self.payload) is bytes: ''' - six.binary_type is stored as application/octet-stream + bytes 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: + secret_dict['payload_content_type'] = 'application/octet-stream' + secret_dict['payload_content_encoding'] = 'base64' + elif type(self.payload) is str: ''' - six.text_type is stored as text/plain + str is stored as text/plain ''' secret_dict['payload'] = self.payload - secret_dict['payload_content_type'] = u'text/plain' + secret_dict['payload_content_type'] = 'text/plain' secret_dict = base.filter_null_keys(secret_dict) LOG.debug("Request body: {0}".format(base.censored_copy(secret_dict, @@ -350,9 +349,9 @@ class Secret(SecretFormatter): if not self.secret_ref: raise LookupError("Secret is not yet stored.") - if type(self.payload) is six.binary_type: + if type(self.payload) is bytes: headers = {'content-type': "application/octet-stream"} - elif type(self.payload) is six.text_type: + elif type(self.payload) is str: headers = {'content-type': "text/plain"} else: raise exceptions.PayloadException("Invalid Payload Type") @@ -479,9 +478,9 @@ class SecretManager(base.BaseEntityManager): if not secret_ref: raise ValueError('secret_ref is required.') - if type(payload) is six.binary_type: + if type(payload) is bytes: headers = {'content-type': "application/octet-stream"} - elif type(payload) is six.text_type: + elif type(payload) is str: headers = {'content-type': "text/plain"} else: raise exceptions.PayloadException("Invalid Payload Type") diff --git a/doc/source/cli/cli_usage.rst b/doc/source/cli/cli_usage.rst index e3b7353..ae8ca32 100644 --- a/doc/source/cli/cli_usage.rst +++ b/doc/source/cli/cli_usage.rst @@ -136,7 +136,7 @@ Secret Get | Name | mysecretname | | Created | 2015-04-16 20:36:40.334696+00:00 | | Status | ACTIVE | - | Content types | {u'default': u'application/octet-stream'} | + | Content types | {'default': 'application/octet-stream'} | | Algorithm | aes | | Bit length | 256 | | Mode | cbc | @@ -182,11 +182,11 @@ Secret List $ barbican secret list - +-----------------------------------------------------------------------+------+----------------------------------+--------+-------------------------------------------+-----------+------------+------+------------+ - | Secret href | Name | Created | Status | Content types | Algorithm | Bit length | Mode | Expiration | - +-----------------------------------------------------------------------+------+----------------------------------+--------+-------------------------------------------+-----------+------------+------+------------+ - | http://localhost:9311/v1/secrets/bb3d8c20-8ea5-4bfc-9645-c8da79c8b371 | None | 2015-04-15 20:37:37.501475+00:00 | ACTIVE | {u'default': u'application/octet-stream'} | aes | 256 | cbc | None | - +-----------------------------------------------------------------------+------+----------------------------------+--------+-------------------------------------------+-----------+------------+------+------------+ + +-----------------------------------------------------------------------+------+----------------------------------+--------+-----------------------------------------+-----------+------------+------+------------+ + | Secret href | Name | Created | Status | Content types | Algorithm | Bit length | Mode | Expiration | + +-----------------------------------------------------------------------+------+----------------------------------+--------+-----------------------------------------+-----------+------------+------+------------+ + | http://localhost:9311/v1/secrets/bb3d8c20-8ea5-4bfc-9645-c8da79c8b371 | None | 2015-04-15 20:37:37.501475+00:00 | ACTIVE | {'default': 'application/octet-stream'} | aes | 256 | cbc | None | + +-----------------------------------------------------------------------+------+----------------------------------+--------+-----------------------------------------+-----------+------------+------+------------+ ACLS @@ -296,19 +296,19 @@ To get complete ACL setting for a secret or container, use this ACL action. $ barbican acl get http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213 - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | read | False | [u'721e27b8505b499e8ab3b38154705b9e', u'2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-21 17:52:01.729370+00:00 | 2015-07-28 02:08:02.455276+00:00 | http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213/acl | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | read | False | ['721e27b8505b499e8ab3b38154705b9e', '2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-21 17:52:01.729370+00:00 | 2015-07-28 02:08:02.455276+00:00 | http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213/acl | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ $ barbican acl get http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19 - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ - | Operation Type | Project Access | Users | Created | Updated | Container ACL Ref | - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ - | read | False | [u'2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-28 01:36:55.791381+00:00 | 2015-07-28 02:05:41.175386+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl | - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + | Operation Type | Project Access | Users | Created | Updated | Container ACL Ref | + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + | read | False | ['2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-28 01:36:55.791381+00:00 | 2015-07-28 02:05:41.175386+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl | + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ Secret or container ref is required. If missing, it will result in error. @@ -333,11 +333,11 @@ To submit complete ACL setting for a secret or container, use this ACL action. $ barbican acl submit --user 2d0ee7c681cc4549b6d76769c320d91f --user 721e27b8505b499e8ab3b38154705b9e http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213 - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | read | True | [u'721e27b8505b499e8ab3b38154705b9e', u'2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-21 17:52:01.729370+00:00 | 2015-08-12 09:53:20.225971+00:00 | http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213/acl | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | read | True | ['721e27b8505b499e8ab3b38154705b9e', '2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-21 17:52:01.729370+00:00 | 2015-08-12 09:53:20.225971+00:00 | http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213/acl | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ If ``user`` argument is missing or has no value, then empty list is passed for @@ -358,11 +358,11 @@ without any value. $ barbican acl submit --user 2d0ee7c681cc4549b6d76769c320d91f --no-project-access http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19 - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ - | Operation Type | Project Access | Users | Created | Updated | Container ACL Ref | - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ - | read | False | [u'2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-29 22:01:00.878270+00:00 | 2015-08-19 05:56:09.930302+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl | - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + | Operation Type | Project Access | Users | Created | Updated | Container ACL Ref | + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + | read | False | ['2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-29 22:01:00.878270+00:00 | 2015-08-19 05:56:09.930302+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl | + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ Following error is returned when both mutually exclusive flags are passed. @@ -392,22 +392,22 @@ existing project access behavior flag. $ barbican acl user add --user c1d20e4b7e7d4917aee6f0832152269b http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19 - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ - | Operation Type | Project Access | Users | Created | Updated | Container ACL Ref | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ - | read | False | [u'2d0ee7c681cc4549b6d76769c320d91f', u'c1d20e4b7e7d4917aee6f0832152269b'] | 2015-07-29 22:01:00.878270+00:00 | 2015-08-12 10:08:19.129370+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + | Operation Type | Project Access | Users | Created | Updated | Container ACL Ref | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ + | read | False | ['2d0ee7c681cc4549b6d76769c320d91f', 'c1d20e4b7e7d4917aee6f0832152269b'] | 2015-07-29 22:01:00.878270+00:00 | 2015-08-12 10:08:19.129370+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+ .. code-block:: bash # Added 2 users for secret (084c2098-66db-4401-8348-d969be0eddaa) earlier via set action. $ barbican acl user add --user --no-project-access http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | read | False | [u'721e27b8505b499e8ab3b38154705b9e', u'2d0ee7c681cc4549b6d76769c320d91f'] | 2015-08-12 10:09:27.564371+00:00 | 2015-08-12 10:11:09.749980+00:00 | http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa/acl | - +----------------+----------------+----------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | read | False | ['721e27b8505b499e8ab3b38154705b9e', '2d0ee7c681cc4549b6d76769c320d91f'] | 2015-08-12 10:09:27.564371+00:00 | 2015-08-12 10:11:09.749980+00:00 | http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa/acl | + +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ ACL Remove User(s) @@ -426,11 +426,11 @@ existing userid(s) are removed from ACL. $ barbican acl user remove --user 2d0ee7c681cc4549b6d76769c320d91f --user invalid_user_id http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ - | read | False | [u'721e27b8505b499e8ab3b38154705b9e'] | 2015-08-12 10:09:27.564371+00:00 | 2015-08-12 10:12:21.842888+00:00 | http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa/acl | - +----------------+----------------+---------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref | + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ + | read | False | ['721e27b8505b499e8ab3b38154705b9e'] | 2015-08-12 10:09:27.564371+00:00 | 2015-08-12 10:12:21.842888+00:00 | http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa/acl | + +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+ ACLs Delete diff --git a/doc/source/cli/usage.rst b/doc/source/cli/usage.rst index 418f78b..4bf2d38 100644 --- a/doc/source/cli/usage.rst +++ b/doc/source/cli/usage.rst @@ -45,14 +45,14 @@ Example: def random_password(length): sys_random = random.SystemRandom() - return u''.join( + return ''.join( sys_random.choice(string.ascii_letters + string.digits) for _ in range(length) ) barbican = client.Client(...) my_secret = barbican.secrets.create() - my_secret.name = u'Random plain text password' + my_secret.name = 'Random plain text password' my_secret.payload = random_password(24) my_secret_ref = my_secret.store() @@ -78,13 +78,13 @@ correct Content Type based on the type of the data that is set on the `Secret.payload` property. The following table summarizes the mapping of Python types to Barbican Secret Content Types: -+-----------------+---------------+---------------+--------------------------+ -| six Type | Python 2 Type | Python 3 Type | Barbican Content Type | -+=================+===============+===============+==========================+ -| six.binary_type | str | bytes | application/octet-stream | -+-----------------+---------------+---------------+--------------------------+ -| six.text_type | unicode | str | text/plain | -+-----------------+---------------+---------------+--------------------------+ ++---------------+--------------------------+ +| Python 3 Type | Barbican Content Type | ++===============+==========================+ +| bytes | application/octet-stream | ++---------------+--------------------------+ +| str | text/plain | ++---------------+--------------------------+ .. WARNING:: Previous versions of python-barbicanclient allowed the user to set the diff --git a/doc/source/conf.py b/doc/source/conf.py index 7579242..298a8b0 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -38,7 +38,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -copyright = u'2014, OpenStack Foundation' +copyright = '2014, OpenStack Foundation' # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True @@ -69,8 +69,8 @@ htmlhelp_basename = 'python-barbicanclientdoc' latex_documents = [ ('index', 'doc-python-barbicanclient.tex', - u'python-barbicanclient Documentation', - u'OpenStack Foundation', 'manual'), + 'python-barbicanclient Documentation', + 'OpenStack Foundation', 'manual'), ] latex_use_xindy = False diff --git a/doc/source/contributor/testing.rst b/doc/source/contributor/testing.rst index d8a524b..7f2fd23 100644 --- a/doc/source/contributor/testing.rst +++ b/doc/source/contributor/testing.rst @@ -16,15 +16,17 @@ refer to the `tox documentation`_ for assistance. Unit Tests ---------- -Currently, we provide tox environments for Python 2.7. By default -all available test environments within the tox configuration will execute +We follow the `Tested Runtimes <https://governance.openstack.org/tc/reference/project-testing-interface.html#tested-runtimes>` +as defined by the Technical Committe every cycle. + +All available test environments within the tox configuration will execute when calling ``tox``. If you want to run them independently, you can do so with the following command: .. code-block:: bash - # Executes tests on Python 3.7 - tox -e py37 + # Executes tests on Python 3.9 + tox -e py39 .. note:: @@ -40,18 +42,18 @@ with the following command: # runs a single test with the function named # test_should_entity_str - tox -e py37 -- test_should_entity_str + tox -e py39 -- test_should_entity_str # runs only tests in the WhenTestingSecrets class and # the WhenTestingOrderManager class - tox -e p37 -- '(WhenTestingSecrets|WhenTestingOrderManager)' + tox -e p39 -- '(WhenTestingSecrets|WhenTestingOrderManager)' The function name or class specified must be one located in the `barbicanclient/tests` directory. Groups of tests can also be run with a regex match after the ``--``. - For more information on what can be done with ``testr``, please see: - http://testrepository.readthedocs.org/en/latest/MANUAL.html + For more information on what can be done with ``stestr``, please see: + https://stestr.readthedocs.io/en/latest/ You can also setup breakpoints in the unit tests. This can be done by adding ``import pdb; pdb.set_trace()`` to the line of the unit test you @@ -59,7 +61,6 @@ want to examine, then running the following command: .. code-block:: bash - # Executes tests on Python 2.7 tox -e debug .. note:: @@ -124,11 +125,6 @@ the functional tests through tox. # Execute Barbican Functional Tests tox -e functional - -By default, the functional tox job will use nosetests to execute the functional -tests. This is primarily due to nose being a very well known and common -workflow among developers. - .. note:: In order to run individual functional test functions, you must use the diff --git a/functionaltests/base.py b/functionaltests/base.py index 8bd75a8..c9fc817 100644 --- a/functionaltests/base.py +++ b/functionaltests/base.py @@ -23,7 +23,7 @@ CONF = config.get_config() class BaseTestCase(oslotest.BaseTestCase): max_payload_size = CONF.keymanager.max_payload_size - max_sized_payload = u'a' * max_payload_size + max_sized_payload = 'a' * max_payload_size oversized_payload = 'a' * (max_payload_size + 1) max_field_size = 255 max_sized_field = 'a' * max_field_size diff --git a/functionaltests/cli/v1/behaviors/base_behaviors.py b/functionaltests/cli/v1/behaviors/base_behaviors.py index 3420cee..aef9831 100644 --- a/functionaltests/cli/v1/behaviors/base_behaviors.py +++ b/functionaltests/cli/v1/behaviors/base_behaviors.py @@ -13,9 +13,9 @@ 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 io import logging import re -import six from barbicanclient import barbican from functionaltests.common import config @@ -84,8 +84,8 @@ class BaseBehaviors(object): """ try: - self.cmdline_client.stdout = six.StringIO() - self.cmdline_client.stderr = six.StringIO() + self.cmdline_client.stdout = io.StringIO() + self.cmdline_client.stderr = io.StringIO() self.cmdline_client.run(argv) except SystemExit: pass diff --git a/functionaltests/client/v1/functional/test_secrets.py b/functionaltests/client/v1/functional/test_secrets.py index fae6c42..2ea483b 100644 --- a/functionaltests/client/v1/functional/test_secrets.py +++ b/functionaltests/client/v1/functional/test_secrets.py @@ -673,7 +673,7 @@ class SecretsTestCase(base.TestCase): @utils.parameterized_dataset({ 'text/plain': [ - u'meowwwwwwwmeowwwwwww', + 'meowwwwwwwmeowwwwwww', 'text/plain'], 'application/octet-stream': [ diff --git a/functionaltests/utils.py b/functionaltests/utils.py index 367dee0..5c5b51a 100644 --- a/functionaltests/utils.py +++ b/functionaltests/utils.py @@ -19,8 +19,7 @@ import time import types import oslotest.base as oslotest -import six -import six.moves.urllib.parse as urlparse +import urllib.parse as urlparse class BaseTestCase(oslotest.BaseTestCase): @@ -43,10 +42,10 @@ def construct_new_test_function(original_func, name, build_params): :return: A new function object """ new_func = types.FunctionType( - six.get_function_code(original_func), - six.get_function_globals(original_func), + original_func.__code__, + original_func.__globals__, name=name, - argdefs=six.get_function_defaults(original_func) + argdefs=original_func.__defaults__ ) # Support either an arg list or kwarg dict for our data diff --git a/requirements.txt b/requirements.txt index 1ce91a6..9c37a45 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,6 @@ # process, which may cause wedges in the gate later. pbr!=2.1.0,>=2.0.0 # Apache-2.0 requests>=2.14.2 # Apache-2.0 -six>=1.10.0 # MIT cliff!=2.9.0,>=2.8.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index d0c96f1..8f24b71 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,7 +9,6 @@ requests-mock>=1.2.0 # Apache-2.0 stestr>=2.0.0 # Apache-2.0 testtools>=2.2.0 # MIT oslotest>=3.2.0 # Apache-2.0 -nose>=1.3.7 # LGPL oslo.config>=5.2.0 # Apache-2.0 python-openstackclient>=3.12.0 # Apache-2.0 sphinxcontrib-svg2pdfconverter>=0.1.0 # BSD @@ -60,7 +60,7 @@ commands = # This tox env is purely to make local test development easier # Note: This requires local running instances of Barbican deps = {[testenv]deps} -commands = nosetests {toxinidir}/functionaltests/{posargs} -v +commands = stestr run --serial --slowest --test-path {toxinidir}/functionaltests {posargs} [flake8] ignore = H202,W504 |