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
changes/33/356433/2
Thomas Bechtold 6 years ago
parent 778f144fd4
commit 52224c5c09
  1. 37
      magnum/tests/contrib/post_test_hook.sh
  2. 18
      magnum/tests/functional/api/v1/test_cluster.py
  3. 14
      magnum/tests/functional/common/datagen.py
  4. 4
      magnum/tests/functional/tempest_tests/config.py

@ -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 <<EOF > $CSR_FILE
-----BEGIN CERTIFICATE REQUEST-----
MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w
HQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29v
Z2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfV
IlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZr
WFlRQddZ1IzXAlVRDWwAo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-----
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

@ -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)

@ -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

@ -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",

Loading…
Cancel
Save