From 52224c5c09a338944b044af616ebe6f47ce2030c Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Wed, 17 Aug 2016 14:31:22 +0200 Subject: [PATCH] Simplify test_create_list_sign_delete_clusters() tempest test The test needs a valid CSR which was created in the devstack post_test_hook in a static way (always the same CSR). This commit simplifies the process and just adds the CSR to the test itself so that the CSR string can be used to check the CSR. That way there is no need to provide a file with the CSR content and point the tempest configuration via the "csr_location" parameter to that file. So the "csr_location" parameter is now deprecated for removal. Also remove the unused "invalid.csr" which was also created in the post_test_hook. Change-Id: I907130576cfb59267643b4639681331acfcfa07f --- magnum/tests/contrib/post_test_hook.sh | 37 ------------------- .../tests/functional/api/v1/test_cluster.py | 18 ++++++++- magnum/tests/functional/common/datagen.py | 14 ++----- .../tests/functional/tempest_tests/config.py | 4 +- 4 files changed, 23 insertions(+), 50 deletions(-) diff --git a/magnum/tests/contrib/post_test_hook.sh b/magnum/tests/contrib/post_test_hook.sh index ad6077ce54..291fb31f60 100755 --- a/magnum/tests/contrib/post_test_hook.sh +++ b/magnum/tests/contrib/post_test_hook.sh @@ -88,7 +88,6 @@ keypair_id = default flavor_id = ${bm_flavor_id:-s1.magnum} master_flavor_id = ${bm_flavor_id:-m1.magnum} copy_logs = true -csr_location = $MAGNUM_DIR/default.csr dns_nameserver = 8.8.8.8 EOF @@ -100,41 +99,6 @@ EOF echo_summary "Generate a key-pair" ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa nova keypair-add --pub-key ~/.ssh/id_rsa.pub default - - # create a valid sample csr - export CSR_FILE=$MAGNUM_DIR/default.csr - cat < $CSR_FILE ------BEGIN CERTIFICATE REQUEST----- -MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh -MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w -HQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29v -Z2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfV -IlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZr -WFlRQddZ1IzXAlVRDWwAo60KecqeAXnnUK+5fXoTI/UgWshre8tJ+x/TMHaQKR/J -cIWPhqaQhsJuzZbvAdGA80BLxdMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIhl -4PvFq+e7ipARgI5ZM+GZx6mpCz44DTo0JkwfRDf+BtrsaC0q68eTf2XhYOsq4fkH -Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D -6iNh8f8z0ShGsFqjDgFHyF3o+lUyj+UC6H1QW7bn ------END CERTIFICATE REQUEST----- -EOF - - # create an ivalid sample csr - export INVALID_CSR_FILE=$MAGNUM_DIR/invalid.csr - cat < $INVALID_CSR_FILE ------BEGIN CERTIFICATE REQUEST----- -FAKERFAKERyjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh -MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w -HQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29v -Z2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfV -IlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZr -WFlRQddZ1IzXAlVRDWwAo60KecqeAXnnUK+5fXoTI/UgWshre8tJ+x/TMHaQKR/J -cIWPhqaQhsJuzZbvAdGA80BLxdMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIhl -4PvFq+e7ipARgI5ZM+GZx6mpCz44DTo0JkwfRDf+BtrsaC0q68eTf2XhYOsq4fkH -Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D -6iNh8f8z0ShGsFqjDgFHyF3o+lUyj+UC6H1QW7bn ------END CERTIFICATE REQUEST----- -EOF - } function add_flavor { @@ -218,7 +182,6 @@ if [[ "api" == "$coe" ]]; then iniset $BASE/new/tempest/etc/tempest.conf magnum keypair_id default iniset $BASE/new/tempest/etc/tempest.conf magnum flavor_id s1.magnum iniset $BASE/new/tempest/etc/tempest.conf magnum master_flavor_id m1.magnum - iniset $BASE/new/tempest/etc/tempest.conf magnum csr_location $CSR_FILE iniset $BASE/new/tempest/etc/tempest.conf magnum copy_logs True # show tempest config with magnum diff --git a/magnum/tests/functional/api/v1/test_cluster.py b/magnum/tests/functional/api/v1/test_cluster.py index 9c943628f6..2a356a0594 100644 --- a/magnum/tests/functional/api/v1/test_cluster.py +++ b/magnum/tests/functional/api/v1/test_cluster.py @@ -162,7 +162,23 @@ class ClusterTest(base.BaseTempestTest): self.assertIn('-----END CERTIFICATE-----', cert_model.pem) # test ca sign - cert_data_model = datagen.cert_data(cluster_model.uuid) + + csr_sample = """-----BEGIN CERTIFICATE REQUEST----- +MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh +MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w +HQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29v +Z2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfV +IlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZr +WFlRQddZ1IzXAlVRDWwAo60KecqeAXnnUK+5fXoTI/UgWshre8tJ+x/TMHaQKR/J +cIWPhqaQhsJuzZbvAdGA80BLxdMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIhl +4PvFq+e7ipARgI5ZM+GZx6mpCz44DTo0JkwfRDf+BtrsaC0q68eTf2XhYOsq4fkH +Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D +6iNh8f8z0ShGsFqjDgFHyF3o+lUyj+UC6H1QW7bn +-----END CERTIFICATE REQUEST----- +""" + + cert_data_model = datagen.cert_data(cluster_model.uuid, + csr_data=csr_sample) resp, cert_model = self.cert_client.post_cert(cert_data_model) self.LOG.debug("cert resp: %s" % resp) self.assertEqual(201, resp.status) diff --git a/magnum/tests/functional/common/datagen.py b/magnum/tests/functional/common/datagen.py index 14a03c8a1e..4b15301c35 100644 --- a/magnum/tests/functional/common/datagen.py +++ b/magnum/tests/functional/common/datagen.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import os import random import socket import string @@ -323,18 +322,11 @@ def bay_node_count_patch_data(node_count=2): return baypatch_model.BayPatchCollection.from_dict(data) -def cert_data(bay_uuid, csr_data=None): - if csr_data is None: - csr_data = config.Config.csr_location +def cert_data(bay_uuid, csr_data): data = { - "bay_uuid": bay_uuid + "bay_uuid": bay_uuid, + "csr": csr_data, } - if csr_data is not None and os.path.isfile(csr_data): - with open(csr_data, 'r') as f: - data['csr'] = f.read() - else: - data['csr'] = csr_data - model = cert_model.CertEntity.from_dict(data) return model diff --git a/magnum/tests/functional/tempest_tests/config.py b/magnum/tests/functional/tempest_tests/config.py index 61f89c1ca6..3601fd5221 100644 --- a/magnum/tests/functional/tempest_tests/config.py +++ b/magnum/tests/functional/tempest_tests/config.py @@ -54,7 +54,9 @@ MagnumGroup = [ cfg.StrOpt("csr_location", default="/opt/stack/new/magnum/default.csr", - help="CSR location for certificates."), + deprecated_for_removal=True, + help="CSR location for certificates. This option is no " + "longer used for anything."), cfg.StrOpt("dns_nameserver", default="8.8.8.8",