Commit feb5cae6 authored by Vincent Pelletier's avatar Vincent Pelletier

test: Validate cli.key_id output.

parent fc3bf97e
......@@ -22,6 +22,7 @@ Test suite
"""
# pylint: disable=too-many-lines, too-many-public-methods
from __future__ import absolute_import
from binascii import hexlify
import contextlib
from Cookie import SimpleCookie
import datetime
......@@ -2236,11 +2237,30 @@ class CaucaseTest(unittest.TestCase):
os.unlink(self._server_db)
os.unlink(self._server_key)
# XXX: just for the coverage... Should check output
with captureStdout() as stdout:
cli.key_id([
'--private-key', user_key_path, user2_key_path, user2_new_key_path,
])
key_id_dict = dict(
line.rsplit(' ', 1)
for line in stdout.getvalue().splitlines()
)
key_id = key_id_dict.pop(user_key_path)
key2_id = key_id_dict.pop(user2_key_path)
new_key2_id = key_id_dict.pop(user2_new_key_path)
self.assertFalse(key_id_dict)
with captureStdout() as stdout:
cli.key_id([
'--private-key', user_key_path, user2_key_path,
'--backup', backup_path,
])
self.assertItemsEqual(
[
backup_path,
' ' + key_id,
' ' + key2_id,
],
stdout.getvalue().splitlines(),
)
self.assertEqual(
self._restoreServer(
......@@ -2321,9 +2341,18 @@ class CaucaseTest(unittest.TestCase):
if not backup_path_list: # pragma: no cover
raise AssertionError('Backup file not created after 1 second')
backup_path, = glob.glob(backup_glob)
with captureStdout() as stdout:
cli.key_id([
'--backup', backup_path,
])
self.assertItemsEqual(
[
backup_path,
' ' + key_id,
' ' + new_key2_id,
],
stdout.getvalue().splitlines(),
)
# Now, push a lot of data to exercise chunked checksum in backup &
# restoration code
......@@ -2346,9 +2375,18 @@ class CaucaseTest(unittest.TestCase):
if not backup_path_list: # pragma: no cover
raise AssertionError('Backup file took too long to be created')
backup_path, = glob.glob(backup_glob)
with captureStdout() as stdout:
cli.key_id([
'--backup', backup_path,
])
self.assertItemsEqual(
[
backup_path,
' ' + key_id,
' ' + new_key2_id,
],
stdout.getvalue().splitlines(),
)
self._stopServer()
os.unlink(self._server_db)
os.unlink(self._server_key)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment