diff --git a/functional_tests/test_server.py b/functional_tests/test_server.py index 4417d81b3e16adbf9274e0eb1d62eb7b976d2204..8e95f4bb5eaccdb92b20871c618e8fca9d1c1a4e 100644 --- a/functional_tests/test_server.py +++ b/functional_tests/test_server.py @@ -202,73 +202,3 @@ def test_server_command_does_not_overwrite_existing_artifacts(tmpdir): # unchanged. assert tmpdir.join(".gimmecert", "server", "myserver.key.pem").read() == private_key assert tmpdir.join(".gimmecert", "server", "myserver.cert.pem").read() == certificate - - -def test_server_command_key_specification(tmpdir): - # John is setting-up a quick and dirty project to test some - # functionality revolving around X.509 certificates. Since he does - # not care much about the strength of private keys for it, he - # wants to use 1024-bit RSA keys. - - # He switches to his project directory, and initialises the CA - # hierarchy, requesting that 1024-bit RSA keys should be used. - tmpdir.chdir() - run_command("gimmecert", "init", "--key-specification", "rsa:1024") - - # John issues a server certificates. - stdout, stderr, exit_code = run_command('gimmecert', 'server', 'myserver1') - - # John observes that the process was completed successfully. - assert exit_code == 0 - assert stderr == "" - - # He runs a command to see details about the generated private - # key. - stdout, _, _ = run_command('openssl', 'rsa', '-noout', '-text', '-in', '.gimmecert/server/myserver1.key.pem') - - # And indeed, the generated private key uses the same size as the - # one he specified for the CA hierarchy. - assert "Private-Key: (1024 bit)" in stdout - - # He then has a look at the certificate. - stdout, _, _ = run_command('openssl', 'x509', '-noout', '-text', '-in', '.gimmecert/server/myserver1.cert.pem') - - # Likewise with the private key, the certificate is also using the - # 1024-bit RSA key. - assert "Public-Key: (1024 bit)" in stdout - - # At some point John realises that to cover all bases, he needs to - # have a test with a server that uses 2048-bit RSA keys as - # well. He does not want to regenerate all of the X.509 artefacts, - # and would like to instead issues a single 2048-bit RSA key for a - # specific server instead. - - # He starts off by having a look at the help for the server command. - stdout, stderr, exit_code = run_command("gimmecert", "server", "-h") - - # John notices the option for passing-in a key specification. - assert " --key-specification" in stdout - assert " -k" in stdout - - # John goes ahead and tries to issue a server certificate using - # key specification option. - stdout, stderr, exit_code = run_command("gimmecert", "server", "--key-specification", "rsas:2048", "myserver2") - - # Unfortunately, the command fails due to John's typo. - assert exit_code != 0 - assert "invalid key_specification" in stderr - - # John tries again, fixing his typo. - stdout, stderr, exit_code = run_command("gimmecert", "server", "--key-specification", "rsa:2048", "myserver2") - - # This time around he succeeds. - assert exit_code == 0 - assert stderr == "" - - # He runs a command to see details about the generated private - # key. - stdout, _, _ = run_command('openssl', 'rsa', '-noout', '-text', '-in', '.gimmecert/server/myserver2.key.pem') - - # He nods with his head, observing that the generated private key - # uses the same key size as he has specified. - assert "Private-Key: (2048 bit)" in stdout