@@ -588,6 +588,64 @@ def test_mv_mix_secrets_folders(cli_runner, vault_with_token):
588588 assert result .exit_code != 0
589589
590590
591+ def test_cp (cli_runner , vault_with_token ):
592+ vault_with_token .db = {
593+ "a/b" : {"value" : "c" },
594+ "d/e" : {"value" : "f" },
595+ "d/g" : {"value" : "h" },
596+ }
597+
598+ result = cli_runner .invoke (cli .cli , ["cp" , "d" , "a" ])
599+
600+ assert result .output .splitlines () == ["Copy 'd/e' to 'a/e'" , "Copy 'd/g' to 'a/g'" ]
601+ assert vault_with_token .db == {
602+ "a/b" : {"value" : "c" },
603+ "a/e" : {"value" : "f" },
604+ "a/g" : {"value" : "h" },
605+ "d/e" : {"value" : "f" },
606+ "d/g" : {"value" : "h" },
607+ }
608+ assert result .exit_code == 0
609+
610+
611+ def test_cp_overwrite_safe (cli_runner , vault_with_token ):
612+ vault_with_token .db = {"a/b" : {"value" : "c" }, "d/b" : {"value" : "f" }}
613+
614+ vault_with_token .safe_write = True
615+
616+ result = cli_runner .invoke (cli .cli , ["cp" , "d" , "a" ])
617+
618+ assert vault_with_token .db == {"a/b" : {"value" : "c" }, "d/b" : {"value" : "f" }}
619+ assert result .exit_code != 0
620+
621+
622+ def test_cp_overwrite_force (cli_runner , vault_with_token ):
623+ vault_with_token .db = {"a/b" : {"value" : "c" }, "d/b" : {"value" : "f" }}
624+
625+ result = cli_runner .invoke (cli .cli , ["cp" , "d" , "a" , "--force" ])
626+
627+ assert vault_with_token .db == {"a/b" : {"value" : "f" }, "d/b" : {"value" : "f" }}
628+ assert result .exit_code == 0
629+
630+
631+ def test_cp_mix_folders_secrets (cli_runner , vault_with_token ):
632+ vault_with_token .db = {"a/b" : {"value" : "c" }, "d" : {"value" : "e" }}
633+
634+ result = cli_runner .invoke (cli .cli , ["cp" , "d" , "a" ])
635+
636+ assert vault_with_token .db == {"a/b" : {"value" : "c" }, "d" : {"value" : "e" }}
637+ assert result .exit_code != 0
638+
639+
640+ def test_cp_mix_secrets_folders (cli_runner , vault_with_token ):
641+ vault_with_token .db = {"a/b" : {"value" : "c" }, "d" : {"value" : "e" }}
642+
643+ result = cli_runner .invoke (cli .cli , ["cp" , "a" , "d" ])
644+
645+ assert vault_with_token .db == {"a/b" : {"value" : "c" }, "d" : {"value" : "e" }}
646+ assert result .exit_code != 0
647+
648+
591649def test_template_from_stdin (cli_runner , vault_with_token ):
592650 vault_with_token .db = {"a/b" : {"value" : "c" }}
593651
0 commit comments