From 97b43a00271d3895e2caa28266ec15dcbaf3eca4 2020-07-13 16:45:47 From: Branko Majic Date: 2020-07-13 16:45:47 Subject: [PATCH] GC-37: Parametrise tests for init command stdout/stderr to cover ECDSA as well. --- diff --git a/tests/test_commands.py b/tests/test_commands.py index 09814f11c36a364b110e62f3541cd6137b7a53dc..5d85800e0504d5123f126175337bec9d0f128e46 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -247,33 +247,41 @@ def test_server_errors_out_if_certificate_already_issued(gctmpdir): assert gctmpdir.join('.gimmecert', 'server', 'myserver.cert.pem').read() == certificate -def test_init_command_stdout_and_stderr_for_single_ca(tmpdir): +@pytest.mark.parametrize("key_specification, key_specification_representation", [ + [("rsa", 2048), "2048-bit RSA"], + [("ecdsa", ec.SECP192R1), "secp192r1 ECDSA"], +]) +def test_init_command_stdout_and_stderr_for_single_ca(tmpdir, key_specification, key_specification_representation): stdout_stream = io.StringIO() stderr_stream = io.StringIO() - gimmecert.commands.init(stdout_stream, stderr_stream, tmpdir.strpath, "myproject", 1, ("rsa", 2048)) + gimmecert.commands.init(stdout_stream, stderr_stream, tmpdir.strpath, "myproject", 1, key_specification) stdout = stdout_stream.getvalue() stderr = stderr_stream.getvalue() assert stderr == "" - assert "CA hierarchy initialised using 2048-bit RSA keys" in stdout + assert "CA hierarchy initialised using %s keys" % key_specification_representation in stdout assert ".gimmecert/ca/level1.cert.pem" in stdout assert ".gimmecert/ca/level1.key.pem" in stdout assert ".gimmecert/ca/chain-full.cert.pem" in stdout -def test_init_command_stdout_and_stderr_for_multiple_cas_with_rsa_1024(tmpdir): +@pytest.mark.parametrize("key_specification, key_specification_representation", [ + [("rsa", 1024), "1024-bit RSA"], + [("ecdsa", ec.SECP192R1), "secp192r1 ECDSA"], +]) +def test_init_command_stdout_and_stderr_for_multiple_cas_with_key_specification(tmpdir, key_specification, key_specification_representation): stdout_stream = io.StringIO() stderr_stream = io.StringIO() - gimmecert.commands.init(stdout_stream, stderr_stream, tmpdir.strpath, "myproject", 3, ("rsa", 1024)) + gimmecert.commands.init(stdout_stream, stderr_stream, tmpdir.strpath, "myproject", 3, key_specification) stdout = stdout_stream.getvalue() stderr = stderr_stream.getvalue() assert stderr == "" - assert "CA hierarchy initialised using 1024-bit RSA keys" in stdout + assert "CA hierarchy initialised using %s keys" % key_specification_representation in stdout assert ".gimmecert/ca/level1.cert.pem" in stdout assert ".gimmecert/ca/level1.key.pem" in stdout assert ".gimmecert/ca/level2.cert.pem" in stdout