Commit feb5cae6 authored by Vincent Pelletier's avatar Vincent Pelletier

test: Validate cli.key_id output.

parent fc3bf97e
...@@ -22,6 +22,7 @@ Test suite ...@@ -22,6 +22,7 @@ Test suite
""" """
# pylint: disable=too-many-lines, too-many-public-methods # pylint: disable=too-many-lines, too-many-public-methods
from __future__ import absolute_import from __future__ import absolute_import
from binascii import hexlify
import contextlib import contextlib
from Cookie import SimpleCookie from Cookie import SimpleCookie
import datetime import datetime
...@@ -2236,11 +2237,30 @@ class CaucaseTest(unittest.TestCase): ...@@ -2236,11 +2237,30 @@ class CaucaseTest(unittest.TestCase):
os.unlink(self._server_db) os.unlink(self._server_db)
os.unlink(self._server_key) os.unlink(self._server_key)
# XXX: just for the coverage... Should check output with captureStdout() as stdout:
cli.key_id([ cli.key_id([
'--private-key', user_key_path, user2_key_path, '--private-key', user_key_path, user2_key_path, user2_new_key_path,
'--backup', backup_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([
'--backup', backup_path,
])
self.assertItemsEqual(
[
backup_path,
' ' + key_id,
' ' + key2_id,
],
stdout.getvalue().splitlines(),
)
self.assertEqual( self.assertEqual(
self._restoreServer( self._restoreServer(
...@@ -2321,9 +2341,18 @@ class CaucaseTest(unittest.TestCase): ...@@ -2321,9 +2341,18 @@ class CaucaseTest(unittest.TestCase):
if not backup_path_list: # pragma: no cover if not backup_path_list: # pragma: no cover
raise AssertionError('Backup file not created after 1 second') raise AssertionError('Backup file not created after 1 second')
backup_path, = glob.glob(backup_glob) backup_path, = glob.glob(backup_glob)
cli.key_id([ with captureStdout() as stdout:
'--backup', backup_path, 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 & # Now, push a lot of data to exercise chunked checksum in backup &
# restoration code # restoration code
...@@ -2346,9 +2375,18 @@ class CaucaseTest(unittest.TestCase): ...@@ -2346,9 +2375,18 @@ class CaucaseTest(unittest.TestCase):
if not backup_path_list: # pragma: no cover if not backup_path_list: # pragma: no cover
raise AssertionError('Backup file took too long to be created') raise AssertionError('Backup file took too long to be created')
backup_path, = glob.glob(backup_glob) backup_path, = glob.glob(backup_glob)
cli.key_id([ with captureStdout() as stdout:
'--backup', backup_path, cli.key_id([
]) '--backup', backup_path,
])
self.assertItemsEqual(
[
backup_path,
' ' + key_id,
' ' + new_key2_id,
],
stdout.getvalue().splitlines(),
)
self._stopServer() self._stopServer()
os.unlink(self._server_db) os.unlink(self._server_db)
os.unlink(self._server_key) 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