]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests for keyring parsing
authorAlfredo Deza <adeza@redhat.com>
Fri, 2 Feb 2018 13:13:12 +0000 (08:13 -0500)
committerAlfredo Deza <adeza@redhat.com>
Fri, 2 Feb 2018 13:13:12 +0000 (08:13 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py

index d68fe63cb65b883316662ebde11b364ce1b5c1c9..bd713f3d4f8ebdde909584624da818ac5bd649ff 100644 (file)
@@ -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=='