From 6b5629a116dda0a4ec9b9fde21dbc164d8a08171 Mon Sep 17 00:00:00 2001 From: Ade Lee Date: Wed, 2 Aug 2017 11:41:26 -0400 Subject: [PATCH] Fix PEP8 issues --- HACKING.rst | 2 +- novajoin_tempest_plugin/README.rst | 4 ++-- novajoin_tempest_plugin/__init__.py | 1 - novajoin_tempest_plugin/config.py | 15 ------------ novajoin_tempest_plugin/plugin.py | 3 --- .../tests/scenario/manager.py | 10 ++++---- .../tests/scenario/novajoin_manager.py | 17 +++++-------- .../scenario/test_novajoin_enrollment.py | 24 +++++++++++++------ .../tests/scenario/test_tripleo_deployment.py | 5 +--- 9 files changed, 32 insertions(+), 49 deletions(-) delete mode 100644 novajoin_tempest_plugin/config.py diff --git a/HACKING.rst b/HACKING.rst index c01bb76..f769444 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -1,4 +1,4 @@ barbican_tempest_plugin Style Commandments -=============================================== +========================================== Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/ diff --git a/novajoin_tempest_plugin/README.rst b/novajoin_tempest_plugin/README.rst index 0d06cf6..1af47e5 100644 --- a/novajoin_tempest_plugin/README.rst +++ b/novajoin_tempest_plugin/README.rst @@ -1,6 +1,6 @@ -=============================================== +=============================== Tempest Integration of Novajoin -=============================================== +=============================== This directory contains Tempest tests to cover the Novajoin project. diff --git a/novajoin_tempest_plugin/__init__.py b/novajoin_tempest_plugin/__init__.py index 9a7e13d..4bce6f3 100644 --- a/novajoin_tempest_plugin/__init__.py +++ b/novajoin_tempest_plugin/__init__.py @@ -15,4 +15,3 @@ import pbr.version __version__ = pbr.version.VersionInfo( 'novajoin_tempest_plugin').version_string() - diff --git a/novajoin_tempest_plugin/config.py b/novajoin_tempest_plugin/config.py deleted file mode 100644 index 4dd6d05..0000000 --- a/novajoin_tempest_plugin/config.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2015 -# All Rights Reserved. -# -# 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. - diff --git a/novajoin_tempest_plugin/plugin.py b/novajoin_tempest_plugin/plugin.py index 735d981..666ba3b 100644 --- a/novajoin_tempest_plugin/plugin.py +++ b/novajoin_tempest_plugin/plugin.py @@ -16,11 +16,8 @@ import os -from tempest import config from tempest.test_discover import plugins -from novajoin_tempest_plugin import config as project_config - class NovajoinTempestPlugin(plugins.TempestPlugin): def load_tests(self): diff --git a/novajoin_tempest_plugin/tests/scenario/manager.py b/novajoin_tempest_plugin/tests/scenario/manager.py index e7957cb..7eb7c82 100644 --- a/novajoin_tempest_plugin/tests/scenario/manager.py +++ b/novajoin_tempest_plugin/tests/scenario/manager.py @@ -393,10 +393,10 @@ class ScenarioTest(tempest.test.BaseTestCase): network = getattr(net_creds, 'network', None) addresses = (server['addresses'][network['name']] if network else []) - for address in addresses: - if (address['version'] == CONF.validation.ip_version_for_ssh - and address['OS-EXT-IPS:type'] == 'fixed'): - return address['addr'] + for addr in addresses: + if (addr['version'] == CONF.validation.ip_version_for_ssh and + addr['OS-EXT-IPS:type'] == 'fixed'): + return addr['addr'] raise exceptions.ServerUnreachable(server_id=server['id']) else: raise lib_exc.InvalidConfiguration() @@ -453,7 +453,7 @@ class ScenarioTest(tempest.test.BaseTestCase): sg for sg in list(client.list_security_groups().values())[0] if sg['tenant_id'] == tenant_id and sg['name'] == 'default' ] - msg = "No default security group for tenant %s." % (tenant_id) + msg = "No default security group for tenant %s." % tenant_id self.assertGreater(len(sgs), 0, msg) return sgs[0] diff --git a/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py b/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py index 68cae12..afb4ef4 100644 --- a/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py +++ b/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py @@ -13,11 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import base64 -from datetime import datetime -from datetime import timedelta -import os - from oslo_log import log as logging from tempest import config @@ -45,8 +40,8 @@ class NovajoinScenarioTest(mgr.ScenarioTest): def setup_clients(cls): super(NovajoinScenarioTest, cls).setup_clients() - os = getattr(cls, 'os_%s' % cls.credentials[0]) - os_adm = getattr(cls, 'os_%s' % cls.credentials[1]) + # os = getattr(cls, 'os_%s' % cls.credentials[0]) + # os_adm = getattr(cls, 'os_%s' % cls.credentials[1]) # set up ipa client def verify_host_registered_with_ipa(self, host): @@ -72,7 +67,7 @@ class NovajoinScenarioTest(mgr.ScenarioTest): # needed for the triple-O tests pass - def verify_service_deleted(self, servicei, host): + def verify_service_deleted(self, service, host): # verify service entry does not exist pass @@ -82,6 +77,6 @@ class NovajoinScenarioTest(mgr.ScenarioTest): # being tracked pass - def verify_cert_revoked(self, serial): - # verify that the given certificate has been revoked - pass + def verify_cert_revoked(self, serial): + # verify that the given certificate has been revoked + pass diff --git a/novajoin_tempest_plugin/tests/scenario/test_novajoin_enrollment.py b/novajoin_tempest_plugin/tests/scenario/test_novajoin_enrollment.py index 2bc024c..83723fc 100644 --- a/novajoin_tempest_plugin/tests/scenario/test_novajoin_enrollment.py +++ b/novajoin_tempest_plugin/tests/scenario/test_novajoin_enrollment.py @@ -45,7 +45,7 @@ class EnrollmentTest(novajoin_manager.NovajoinScenarioTest): * Add metadata to register and create some cert entries * Validate that the certs for those entries are issued and tracked - * Validate that the service entries arer removed when the + * Validate that the service entries are removed when the instance is deleted. * Validate that the certs issued have been revoked. """ @@ -63,6 +63,9 @@ class EnrollmentTest(novajoin_manager.NovajoinScenarioTest): security_group = self._create_security_group() # TODO(alee) Add metadata for ipa_enroll=True # TODO(alee) Add metadata for service to be created/joined + + service = "random service to be added" + cn = "cn of random service certificate" server = self.create_server( name='passed_metadata_server', image_id=self.no_metadata_img_uuid, @@ -72,6 +75,8 @@ class EnrollmentTest(novajoin_manager.NovajoinScenarioTest): ) self.verify_registered_host(server, keypair, service, cn) self.delete_server(server) + + serial = "serial number of random service certificate" self.verify_unregistered_host(server, service, serial) @decorators.idempotent_id('cbc752ed-b716-4727-910f-956ccf965723') @@ -80,27 +85,32 @@ class EnrollmentTest(novajoin_manager.NovajoinScenarioTest): LOG.info("Creating keypair and security group") keypair = self.create_keypair() security_group = self._create_security_group() + # TODO(alee) Add metadata for service to be created/joined + service = "random service to be added" + cn = "cn of random service certificate" + server = self.create_server( - name='signed_img_server', - image_id=metadata_img_uuid, + name='img_with_metadata_server', + image_id=self.metadata_img_uuid, key_name=keypair['name'], security_groups=[{'name': security_group['name']}], wait_until='ACTIVE' ) self.verify_registered_host(server, keypair, service, cn) self.delete_server(server) + + serial = "serial number of cert for random service" self.verify_unregistered_host(server, service, serial) def verify_registered_host(self, server, keypair, service, cn): self.verify_host_registered_with_ipa(server) self.verify_host_has_keytab(server) - self.verify_host_is_ipaclient(server) + self.verify_host_is_ipaclient(server, keypair) self.verify_service_created(service, server) - self.verify_cert_tracked(self, host, keypair, cn) - + self.verify_cert_tracked(server, keypair, cn) + def verify_unregistered_host(self, server, service, serial): self.verify_host_not_registered_with_ipa(server) self.verify_service_deleted(service, server) self.verify_cert_revoked(serial) - diff --git a/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py b/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py index 2597d2d..e8626b7 100644 --- a/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py +++ b/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py @@ -12,12 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from novajoin_tempest_plugin.tests.scenario import novajoin_manager from oslo_log import log as logging from tempest import config -from tempest.lib import decorators -from tempest import test - -from novajoin_tempest_plugin.tests.scenario import novajoin_manager CONF = config.CONF LOG = logging.getLogger(__name__)