Fix missing escaping in test suite command-line calls
Marco Ricci

Marco Ricci commited on 2024-11-13 19:47:46
Zeige 1 geänderte Dateien mit 28 Einfügungen und 28 Löschungen.

... ...
@@ -254,7 +254,7 @@ class TestCLI:
254 254
         ):
255 255
             _result = runner.invoke(
256 256
                 cli.derivepassphrase_vault,
257
-                [option, '0', '-p', DUMMY_SERVICE],
257
+                [option, '0', '-p', '--', DUMMY_SERVICE],
258 258
                 input=DUMMY_PASSPHRASE,
259 259
                 catch_exceptions=False,
260 260
             )
... ...
@@ -276,7 +276,7 @@ class TestCLI:
276 276
         ):
277 277
             _result = runner.invoke(
278 278
                 cli.derivepassphrase_vault,
279
-                ['--repeat', '0', '-p', DUMMY_SERVICE],
279
+                ['--repeat', '0', '-p', '--', DUMMY_SERVICE],
280 280
                 input=DUMMY_PASSPHRASE,
281 281
                 catch_exceptions=False,
282 282
             )
... ...
@@ -329,7 +329,7 @@ class TestCLI:
329 329
             )
330 330
             _result = runner.invoke(
331 331
                 cli.derivepassphrase_vault,
332
-                [DUMMY_SERVICE],
332
+                ['--', DUMMY_SERVICE],
333 333
                 catch_exceptions=False,
334 334
             )
335 335
         result = tests.ReadableResult.parse(_result)
... ...
@@ -361,7 +361,7 @@ class TestCLI:
361 361
             )
362 362
             _result = runner.invoke(
363 363
                 cli.derivepassphrase_vault,
364
-                ['-k', DUMMY_SERVICE],
364
+                ['-k', '--', DUMMY_SERVICE],
365 365
                 input='1\n',
366 366
                 catch_exceptions=False,
367 367
             )
... ...
@@ -419,7 +419,7 @@ class TestCLI:
419 419
             ):
420 420
                 _result = runner.invoke(
421 421
                     cli.derivepassphrase_vault,
422
-                    ['-k', DUMMY_SERVICE],
422
+                    ['-k', '--', DUMMY_SERVICE],
423 423
                     input=f'{key_index}\n',
424 424
                 )
425 425
         result = tests.ReadableResult.parse(_result)
... ...
@@ -457,7 +457,7 @@ class TestCLI:
457 457
             ):
458 458
                 _result = runner.invoke(
459 459
                     cli.derivepassphrase_vault,
460
-                    [DUMMY_SERVICE],
460
+                    ['--', DUMMY_SERVICE],
461 461
                     catch_exceptions=False,
462 462
                 )
463 463
         result = tests.ReadableResult.parse(_result)
... ...
@@ -551,7 +551,7 @@ class TestCLI:
551 551
             for value in '-42', 'invalid':
552 552
                 _result = runner.invoke(
553 553
                     cli.derivepassphrase_vault,
554
-                    [option, value, '-p', DUMMY_SERVICE],
554
+                    [option, value, '-p', '--', DUMMY_SERVICE],
555 555
                     input=DUMMY_PASSPHRASE,
556 556
                     catch_exceptions=False,
557 557
                 )
... ...
@@ -585,7 +585,7 @@ class TestCLI:
585 585
         ):
586 586
             _result = runner.invoke(
587 587
                 cli.derivepassphrase_vault,
588
-                options if service else [*options, DUMMY_SERVICE],
588
+                options if service else [*options, '--', DUMMY_SERVICE],
589 589
                 input=input,
590 590
                 catch_exceptions=False,
591 591
             )
... ...
@@ -614,7 +614,7 @@ class TestCLI:
614 614
                 )
615 615
                 _result = runner.invoke(
616 616
                     cli.derivepassphrase_vault,
617
-                    [*options, DUMMY_SERVICE] if service else options,
617
+                    [*options, '--', DUMMY_SERVICE] if service else options,
618 618
                     input=input,
619 619
                     catch_exceptions=False,
620 620
                 )
... ...
@@ -693,7 +693,7 @@ class TestCLI:
693 693
         ):
694 694
             _result = runner.invoke(
695 695
                 cli.derivepassphrase_vault,
696
-                [*options, DUMMY_SERVICE] if service else options,
696
+                [*options, '--', DUMMY_SERVICE] if service else options,
697 697
                 input=DUMMY_PASSPHRASE,
698 698
                 catch_exceptions=False,
699 699
             )
... ...
@@ -948,7 +948,7 @@ contents go here
948 948
             monkeypatch.setattr(click, 'edit', lambda *a, **kw: edit_result)  # noqa: ARG005
949 949
             _result = runner.invoke(
950 950
                 cli.derivepassphrase_vault,
951
-                ['--notes', 'sv'],
951
+                ['--notes', '--', 'sv'],
952 952
                 catch_exceptions=False,
953 953
             )
954 954
             result = tests.ReadableResult.parse(_result)
... ...
@@ -974,7 +974,7 @@ contents go here
974 974
             monkeypatch.setattr(click, 'edit', lambda *a, **kw: None)  # noqa: ARG005
975 975
             _result = runner.invoke(
976 976
                 cli.derivepassphrase_vault,
977
-                ['--notes', 'sv'],
977
+                ['--notes', '--', 'sv'],
978 978
                 catch_exceptions=False,
979 979
             )
980 980
             result = tests.ReadableResult.parse(_result)
... ...
@@ -997,7 +997,7 @@ contents go here
997 997
             monkeypatch.setattr(click, 'edit', lambda *a, **kw: 'long\ntext')  # noqa: ARG005
998 998
             _result = runner.invoke(
999 999
                 cli.derivepassphrase_vault,
1000
-                ['--notes', 'sv'],
1000
+                ['--notes', '--', 'sv'],
1001 1001
                 catch_exceptions=False,
1002 1002
             )
1003 1003
             result = tests.ReadableResult.parse(_result)
... ...
@@ -1023,7 +1023,7 @@ contents go here
1023 1023
             monkeypatch.setattr(click, 'edit', lambda *a, **kw: '\n\n')  # noqa: ARG005
1024 1024
             _result = runner.invoke(
1025 1025
                 cli.derivepassphrase_vault,
1026
-                ['--notes', 'sv'],
1026
+                ['--notes', '--', 'sv'],
1027 1027
                 catch_exceptions=False,
1028 1028
             )
1029 1029
             result = tests.ReadableResult.parse(_result)
... ...
@@ -1053,7 +1053,7 @@ contents go here
1053 1053
                 },
1054 1054
             ),
1055 1055
             (
1056
-                ['--phrase', 'sv'],
1056
+                ['--phrase', '--', 'sv'],
1057 1057
                 'my passphrase\n',
1058 1058
                 {
1059 1059
                     'global': {'phrase': 'abc'},
... ...
@@ -1061,7 +1061,7 @@ contents go here
1061 1061
                 },
1062 1062
             ),
1063 1063
             (
1064
-                ['--key', 'sv'],
1064
+                ['--key', '--', 'sv'],
1065 1065
                 '1\n',
1066 1066
                 {
1067 1067
                     'global': {'phrase': 'abc'},
... ...
@@ -1069,7 +1069,7 @@ contents go here
1069 1069
                 },
1070 1070
             ),
1071 1071
             (
1072
-                ['--key', '--length', '15', 'sv'],
1072
+                ['--key', '--length', '15', '--', 'sv'],
1073 1073
                 '1\n',
1074 1074
                 {
1075 1075
                     'global': {'phrase': 'abc'},
... ...
@@ -1115,11 +1115,11 @@ contents go here
1115 1115
         [
1116 1116
             ([], '', 'Cannot update global settings without actual settings'),
1117 1117
             (
1118
-                ['sv'],
1118
+                ['--', 'sv'],
1119 1119
                 '',
1120 1120
                 'Cannot update service settings without actual settings',
1121 1121
             ),
1122
-            (['--phrase', 'sv'], '', 'No passphrase given'),
1122
+            (['--phrase', '--', 'sv'], '', 'No passphrase given'),
1123 1123
             (['--key'], '', 'No valid SSH key selected'),
1124 1124
         ],
1125 1125
     )
... ...
@@ -1238,7 +1238,7 @@ contents go here
1238 1238
             )
1239 1239
             _result = runner.invoke(
1240 1240
                 cli.derivepassphrase_vault,
1241
-                ['--config', '--length=15', DUMMY_SERVICE],
1241
+                ['--config', '--length=15', '--', DUMMY_SERVICE],
1242 1242
                 catch_exceptions=False,
1243 1243
             )
1244 1244
         result = tests.ReadableResult.parse(_result)
... ...
@@ -1265,7 +1265,7 @@ contents go here
1265 1265
             monkeypatch.setattr(cli, '_save_config', raiser)
1266 1266
             _result = runner.invoke(
1267 1267
                 cli.derivepassphrase_vault,
1268
-                ['--config', '--length=15', DUMMY_SERVICE],
1268
+                ['--config', '--length=15', '--', DUMMY_SERVICE],
1269 1269
                 catch_exceptions=False,
1270 1270
             )
1271 1271
         result = tests.ReadableResult.parse(_result)
... ...
@@ -1297,7 +1297,7 @@ contents go here
1297 1297
         ):
1298 1298
             _result = runner.invoke(
1299 1299
                 cli.derivepassphrase_vault,
1300
-                [DUMMY_SERVICE],
1300
+                ['--', DUMMY_SERVICE],
1301 1301
                 catch_exceptions=False,
1302 1302
             )
1303 1303
         result = tests.ReadableResult.parse(_result)
... ...
@@ -1431,7 +1431,7 @@ contents go here
1431 1431
                 id='service-weird-name-NFC',
1432 1432
             ),
1433 1433
             pytest.param(
1434
-                ['--config', '-p', DUMMY_SERVICE],
1434
+                ['--config', '-p', '--', DUMMY_SERVICE],
1435 1435
                 'Du\u0308sseldorf',
1436 1436
                 (
1437 1437
                     f'the $.services.{DUMMY_SERVICE} passphrase '
... ...
@@ -1440,7 +1440,7 @@ contents go here
1440 1440
                 id='config-NFC',
1441 1441
             ),
1442 1442
             pytest.param(
1443
-                ['-p', DUMMY_SERVICE],
1443
+                ['-p', '--', DUMMY_SERVICE],
1444 1444
                 'Du\u0308sseldorf',
1445 1445
                 'the interactive passphrase is not NFC-normalized',
1446 1446
                 id='direct-input-NFC',
... ...
@@ -1674,7 +1674,7 @@ Great!
1674 1674
         ), 'expected clean exit'
1675 1675
         _result = runner.invoke(
1676 1676
             driver,
1677
-            ['Will replace with spam, okay? ' '(Please say "y" or "n".)'],
1677
+            ['Will replace with spam, okay? (Please say "y" or "n".)'],
1678 1678
             input='',
1679 1679
         )
1680 1680
         result = tests.ReadableResult.parse(_result)
... ...
@@ -1717,7 +1717,7 @@ Boo.
1717 1717
                 {'services': {}},
1718 1718
             ),
1719 1719
             (
1720
-                ['--delete', DUMMY_SERVICE],
1720
+                ['--delete', '--', DUMMY_SERVICE],
1721 1721
                 {
1722 1722
                     'global': {'phrase': 'abc'},
1723 1723
                     'services': {DUMMY_SERVICE: {'notes': '...'}},
... ...
@@ -2056,7 +2056,7 @@ class TestCLITransition:
2056 2056
         ):
2057 2057
             _result = runner.invoke(
2058 2058
                 cli.derivepassphrase,
2059
-                [option, '0', '-p', DUMMY_SERVICE],
2059
+                [option, '0', '-p', '--', DUMMY_SERVICE],
2060 2060
                 input=DUMMY_PASSPHRASE,
2061 2061
                 catch_exceptions=False,
2062 2062
             )
... ...
@@ -2388,7 +2388,7 @@ class ConfigMergingStateMachine(stateful.RuleBasedStateMachine):
2388 2388
         if ret is not None:
2389 2389
             _result = self.runner.invoke(
2390 2390
                 cli.derivepassphrase_vault,
2391
-                ['--delete', service],
2391
+                ['--delete', '--', service],
2392 2392
                 input='y',
2393 2393
                 catch_exceptions=False,
2394 2394
             )
2395 2395