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:
parent
c68c5d2a07
commit
3e93aeee72
@ -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...")
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user