From: Alfredo Deza Date: Fri, 2 Feb 2018 13:13:12 +0000 (-0500) Subject: ceph-volume tests for keyring parsing X-Git-Tag: v12.2.3~19^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d015b1933920a855a6a2cafdda863162b804ecbe;p=ceph.git ceph-volume tests for keyring parsing Signed-off-by: Alfredo Deza (cherry picked from commit b90c1a86843d8f0c8c7fb68fe059bdd72f3730fd) --- diff --git a/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py b/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py index d68fe63cb65..bd713f3d4f8 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py +++ b/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py @@ -50,3 +50,27 @@ class TestEtcPath(object): scanner._etc_path = path with pytest.raises(RuntimeError): scanner.etc_path + + +class TestParseKeyring(object): + + def test_newlines_are_removed(self): + contents = [ + '[client.osd-lockbox.8d7a8ab2-5db0-4f83-a785-2809aba403d5]', + '\tkey = AQDtoGha/GYJExAA7HNl7Ukhqr7AKlCpLJk6UA==', ''] + assert '\n' not in scan.parse_keyring('\n'.join(contents)) + + def test_key_has_spaces_removed(self): + contents = [ + '[client.osd-lockbox.8d7a8ab2-5db0-4f83-a785-2809aba403d5]', + '\tkey = AQDtoGha/GYJExAA7HNl7Ukhqr7AKlCpLJk6UA==', ''] + result = scan.parse_keyring('\n'.join(contents)) + assert result.startswith(' ') is False + assert result.endswith(' ') is False + + def test_actual_key_is_extracted(self): + contents = [ + '[client.osd-lockbox.8d7a8ab2-5db0-4f83-a785-2809aba403d5]', + '\tkey = AQDtoGha/GYJExAA7HNl7Ukhqr7AKlCpLJk6UA==', ''] + result = scan.parse_keyring('\n'.join(contents)) + assert result == 'AQDtoGha/GYJExAA7HNl7Ukhqr7AKlCpLJk6UA=='