1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-22 16:25:17 +00:00

cli: Make sure user doesn't accidentally overwrite existing setup

This commit is contained in:
Priit Laes 2015-09-29 15:04:35 +03:00
parent c68c5d2a07
commit 3e93aeee72
2 changed files with 12 additions and 1 deletions

View File

@ -469,7 +469,10 @@ def certidude_setup_authority(parent, country, state, locality, organization, or
if not re.match(r"^[_a-zA-Z0-9]+$", slug):
raise click.ClickException("CA name can contain only alphanumeric and '_' characters")
click.echo("CA configuration files are saved to: {}".format(os.path.abspath(slug)))
if os.path.lexists(directory):
raise click.ClickException("Output directory {} already exists.".format(directory))
click.echo("CA configuration files are saved to: {}".format(directory))
click.echo("Generating 4096-bit RSA key...")

View File

@ -41,3 +41,11 @@ def test_cli_setup_authority_invalid_name():
result = runner.invoke(cli, ['setup', 'authority', '""'])
assert result.exception
def test_cli_setup_authority_overwrite():
with runner.isolated_filesystem():
result = runner.invoke(cli, ['setup', 'authority', 'foo'])
assert not result.exception
result = runner.invoke(cli, ['setup', 'authority', 'foo'])
assert result.exception