Merge pull request #4458 from ThomasWaldmann/fix-4348-1.1

Fix 4348 (1.1-maint backport)
This commit is contained in:
TW 2019-03-21 01:49:16 +01:00 committed by GitHub
commit 1cd8ca297a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View file

@ -352,10 +352,14 @@ class Archiver:
if not args.path:
self.print_error("output file to export key to expected")
return EXIT_ERROR
if args.qr:
manager.export_qr(args.path)
else:
manager.export(args.path)
try:
if args.qr:
manager.export_qr(args.path)
else:
manager.export(args.path)
except IsADirectoryError:
self.print_error("'{}' must be a file, not a directory".format(args.path))
return EXIT_ERROR
return EXIT_SUCCESS
@with_repository(lock=False, exclusive=False, manifest=False, cache=False)

View file

@ -2650,6 +2650,14 @@ class ArchiverTestCase(ArchiverTestCaseBase):
assert export_contents.startswith('<!doctype html>')
assert export_contents.endswith('</html>')
def test_key_export_directory(self):
export_directory = self.output_path + '/exported'
os.mkdir(export_directory)
self.cmd('init', self.repository_location, '--encryption', 'repokey')
self.cmd('key', 'export', self.repository_location, export_directory, exit_code=EXIT_ERROR)
def test_key_import_errors(self):
export_file = self.output_path + '/exported'
self.cmd('init', self.repository_location, '--encryption', 'keyfile')