]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py
update sources to v12.2.3
[ceph.git] / ceph / src / ceph-volume / ceph_volume / tests / devices / simple / test_scan.py
index d68fe63cb65b883316662ebde11b364ce1b5c1c9..08ca37f669099fda532a0c09299d31b755083c0a 100644 (file)
@@ -8,7 +8,7 @@ class TestScan(object):
     def test_main_spits_help_with_no_arguments(self, capsys):
         scan.Scan([]).main()
         stdout, stderr = capsys.readouterr()
-        assert 'Scan an OSD directory for files' in stdout
+        assert 'Scan an OSD directory (or data device) for files' in stdout
 
 
 class TestGetContents(object):
@@ -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=='