jj/cli/tests
Anton Bulakh c99c97c646 sign: Add templater methods to show signature info
Disclaimer: this is the work of @necauqua and @julienvincent (see
#3141). I simply materialized the changes by rebasing them on latest
`main` and making the necessary adjustments to pass CI.

---

I had to fix an issue in `TestSignatureBackend::sign()`.

The following test was failing:
```
---- test_signature_templates::test_signature_templates stdout ----
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: signature_templates
Source: cli/tests/test_signature_templates.rs:28
────────────────────────────────────────────────────────────────────────────────
Expression: stdout
────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────
    0     0 │ @  Commit ID: 05ac066d05701071af20e77506a0f2195194cbc9
    1     1 │ │  Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
    2     2 │ │  Author: Test User <test.user@example.com> (2001-02-03 08:05:07)
    3     3 │ │  Committer: Test User <test.user@example.com> (2001-02-03 08:05:07)
    4       │-│  Signature: Good test signature
          4 │+│  Signature: Bad test signature
    5     5 │ │
    6     6 │ │      (no description set)
    7     7 │ │
    8     8 │ ◆  Commit ID: 0000000000000000000000000000000000000000
────────────┴───────────────────────────────────────────────────────────────────
```

Print debugging revealed that the signature was bad, because of a
missing trailing `\n` in `TestSignatureBackend::sign()`.

```diff
diff --git a/lib/src/test_signing_backend.rs b/lib/src/test_signing_backend.rs
index d47fef1086..0ba249e358 100644
--- a/lib/src/test_signing_backend.rs
+++ b/lib/src/test_signing_backend.rs
@@ -59,6 +59,8 @@
         let key = (!key.is_empty()).then_some(std::str::from_utf8(key).unwrap().to_owned());

         let sig = self.sign(data, key.as_deref())?;
+        dbg!(&std::str::from_utf8(&signature).unwrap());
+        dbg!(&std::str::from_utf8(&sig).unwrap());
         if sig == signature {
             Ok(Verification::new(
                 SigStatus::Good,
```

```
[lib/src/test_signing_backend.rs:62:9] &std::str::from_utf8(&signature).unwrap() = \"--- JJ-TEST-SIGNATURE ---\\nKEY: \\n5300977ff3ecda4555bd86d383b070afac7b7459c07f762af918943975394a8261d244629e430c8554258904f16dd9c18d737f8969f2e7d849246db0d93cc004\\n\"
[lib/src/test_signing_backend.rs:63:9] &std::str::from_utf8(&sig).unwrap() = \"--- JJ-TEST-SIGNATURE ---\\nKEY: \\n5300977ff3ecda4555bd86d383b070afac7b7459c07f762af918943975394a8261d244629e430c8554258904f16dd9c18d737f8969f2e7d849246db0d93cc004\"
```

Thankfully, @yuja pointed out that libgit2 appends a trailing newline
(see bfb7613d5d).

Co-authored-by: necauqua <him@necauq.ua>
Co-authored-by: julienvincent <m@julienvincent.io>
2025-01-04 13:24:08 +01:00
..
common cli: git clone: convert local Git remote path to slash-separated path 2024-12-23 09:40:52 +09:00
cli-reference@.md.snap evolog: Implement --reversed flag 2025-01-02 20:21:59 -05:00
runner.rs cli: delete deprecated jj checkout command 2024-11-21 11:50:03 -06:00
test_abandon_command.rs cli: abandon, describe: parse -rREV option properly 2024-12-23 22:58:06 +09:00
test_absorb_command.rs absorb: abandon source commit if it becomes discardable 2024-12-21 09:19:54 +09:00
test_acls.rs diff: remove duplicated source message from AccessDenied error 2024-10-23 23:51:21 +09:00
test_advance_bookmarks.rs everything: Rename branches to bookmarks 2024-09-11 18:54:45 +02:00
test_alias.rs cli: refer to fileset argument using FILESETS in synopsis 2024-12-18 10:13:44 -08:00
test_backout_command.rs cli: drop support for jj init --{git, git_repo} 2025-01-03 10:15:01 -06:00
test_bookmark_command.rs cli: refer to revset argument using REVSET(S) in synopsis 2024-12-18 10:13:44 -08:00
test_builtin_aliases.rs cli: replace --config-toml=TOML with --config=NAME=VALUE 2024-12-17 20:12:12 +09:00
test_commit_command.rs cli: replace --config-toml=TOML with --config=NAME=VALUE 2024-12-17 20:12:12 +09:00
test_commit_template.rs sign: Add templater methods to show signature info 2025-01-04 13:24:08 +01:00
test_completion.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_concurrent_operations.rs log: emit working-copy branch first if included in the revset 2024-11-20 10:50:16 +09:00
test_config_command.rs config: preserve key formatting on set_value() 2024-12-29 09:57:04 +09:00
test_copy_detection.rs copy-tracking: add a command line driver with a simple test 2024-07-03 20:26:30 -04:00
test_debug_command.rs revset: reorganize expression resolution/evaluation methods 2024-11-08 10:34:02 +09:00
test_describe_command.rs cli: drop support for jj init --{git, git_repo} 2025-01-03 10:15:01 -06:00
test_diff_command.rs tests: use toml_edit to escape editor path, set ui.editor instead of $EDITOR 2024-12-20 19:28:01 +09:00
test_diffedit_command.rs tests: leverage set_up_fake_diff_editor() in test_diffedit_3pane() 2024-12-20 19:28:01 +09:00
test_duplicate_command.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_edit_command.rs cli: refer to revset argument using REVSET(S) in synopsis 2024-12-18 10:13:44 -08:00
test_evolog_command.rs evolog: Implement --reversed flag 2025-01-02 20:21:59 -05:00
test_file_annotate_command.rs cli: don't use format_*() in annotate template, truncate author, omit commit id 2024-11-05 14:49:57 +09:00
test_file_chmod_command.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_file_show_command.rs tests: rename test_file_print_command.rs to_file_show_command.rs 2024-10-04 20:52:59 +09:00
test_file_track_untrack_commands.rs cli: refer to fileset argument using FILESETS in synopsis 2024-12-18 10:13:44 -08:00
test_fix_command.rs cli: drop support for jj init --{git, git_repo} 2025-01-03 10:15:01 -06:00
test_generate_md_cli_help.rs test_generate_cli_reference: fixup to 52c415e, remove mysterious comment 2024-06-15 20:30:40 -07:00
test_git_clone.rs cli: git clone: convert local Git remote path to slash-separated path 2024-12-23 09:40:52 +09:00
test_git_colocated.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_git_fetch.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_git_import_export.rs templates: make op_summary more readable 2024-10-13 20:06:03 -07:00
test_git_init.rs bookmarks: add support for git.auto-local-bookmark (to match docs) 2024-10-30 08:01:02 -07:00
test_git_private_commits.rs cli: replace --config-toml=TOML with --config=NAME=VALUE 2024-12-17 20:12:12 +09:00
test_git_push.rs cli: git clone: convert local Git remote path to slash-separated path 2024-12-23 09:40:52 +09:00
test_git_remotes.rs everything: Rename branches to bookmarks 2024-09-11 18:54:45 +02:00
test_git_submodule.rs tests: avoid deprecated jj init --git/--git-repo 2024-05-17 13:55:20 -07:00
test_gitignores.rs everything: Rename branches to bookmarks 2024-09-11 18:54:45 +02:00
test_global_opts.rs config: load system host/user name by CLI and insert as env-base layer 2025-01-04 17:54:28 +09:00
test_help_command.rs cli: refer to revset argument using REVSET(S) in synopsis 2024-12-18 10:13:44 -08:00
test_immutable_commits.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_init_command.rs cli: drop support for jj init --{git, git_repo} 2025-01-03 10:15:01 -06:00
test_interdiff_command.rs cli: delete deprecated jj checkout command 2024-11-21 11:50:03 -06:00
test_log_command.rs cli: refer to revset argument using REVSET(S) in synopsis 2024-12-18 10:13:44 -08:00
test_new_command.rs cli: refer to revset argument using REVSET(S) in synopsis 2024-12-18 10:13:44 -08:00
test_next_prev_commands.rs cli: drop support for jj init --{git, git_repo} 2025-01-03 10:15:01 -06:00
test_operations.rs cli: replace --config-toml=TOML with --config=NAME=VALUE 2024-12-17 20:12:12 +09:00
test_parallelize_command.rs log: emit working-copy branch first if included in the revset 2024-11-20 10:50:16 +09:00
test_rebase_command.rs cli: refer to revset argument using REVSET(S) in synopsis 2024-12-18 10:13:44 -08:00
test_repo_change_report.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_resolve_command.rs merge_tools: add "$marker_length" variable 2024-12-23 08:42:10 -06:00
test_restore_command.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_revset_output.rs settings: parse TOML date-time value as well as string timestamp 2024-12-18 09:51:56 +09:00
test_root.rs formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04:00
test_shell_completion.rs
test_show_command.rs templater: add Email template type, deprecate Signature.username() 2024-12-15 16:03:34 +08:00
test_simplify_parents_command.rs cli: simplify-parents: add default revsets.simplify-parents config 2024-11-26 13:19:25 +08:00
test_sparse_command.rs windows: avoid UNC paths in run_ui_editor 2024-07-04 11:30:20 +10:00
test_split_command.rs cli: consider "JJ:" lines as comments also when not followed by space 2024-12-04 10:40:56 -08:00
test_squash_command.rs cli: refer to fileset argument using FILESETS in synopsis 2024-12-18 10:13:44 -08:00
test_status_command.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_tag_command.rs everything: Rename branches to bookmarks 2024-09-11 18:54:45 +02:00
test_templater.rs cli: replace --config-toml=TOML with --config=NAME=VALUE 2024-12-17 20:12:12 +09:00
test_undo.rs cli: git push: do not push new bookmarks by default 2024-11-19 21:11:22 +09:00
test_unsquash_command.rs cli: replace --config-toml=TOML with --config=NAME=VALUE 2024-12-17 20:12:12 +09:00
test_util_command.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
test_working_copy.rs local_working_copy: store materialized conflict marker length 2024-12-21 11:36:30 -06:00
test_workspaces.rs docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00