mirror of
https://github.com/DictXiong/dotfiles.git
synced 2026-08-24 16:06:52 +08:00
* feat(riot): support literal ipv6 addresses (with or without ports given) feat(riot): -v, -4, and -6 fix(riot): do not call external binaries if possible * feat(riot): command git * build(riot-config): nasp.fit -> jump.nasp.fit * feat: add bnd and nor and completions * fix(zshrc): bnd exit when build error * fix(tmux): press ^a twice to send ^a * feat(riot): sshl supports specifying local port and unix sock * feat(riot): sshr for ssh -R * feat(riot): -o ServerAliveInterval=60 * feat(riot): conditionally RequestTTY * feat: zsh completion for beam and beaml * fix(frigg): ddns get ip * fix(riot): tmux error with window number and spaces The fix to spaces is just a workaround. Issue may still exist when command contains spaces. * feat(riot): ControlPersist=60s * fix(ci): riot * feat(tmux): prevent tmux from exiting copy mode after selection with mouse see: - https://www.reddit.com/r/tmux/comments/v73005/how_to_prevent_tmux_from_exiting_copy_mode_after/ - https://www.reddit.com/r/tmux/comments/1ltms6a/how_to_select_text_in_tmux_without_having_it_jump/ * feat(tmux): F12 to passthru * fix(riot): ControlPersist 60s -> 5s * feat: sne: search and edit * feat(ssh): add key ip17/sep * feat(tmux): press ESC to exit copy mode * feat(ssh): add key sk1/piv/9a * feat(ssh): add key sk1/fido2 * feat(ssh): add key openpgp:0x8774BF70 and remove key ip14/sep and ltp2 (asu127) * feat(sagent): sagt gpg; improve code * feat(sagent): check pinentry and give notes * feat(riot): add GPG agent forwarding Signed-off-by: Dict Xiong <me@beardic.cn> * feat: gitconf add gpg signature; remove macos from ci * feat(eid): add sk1 9a cert * feat(riot): better help and fix option quite->quiet * feat(riot): separate command options from riot options * feat(sagt): gpg-pin and associated tests * feat(riot): zsh completions * fix: Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix(riot): simplify and secure * fix: syntax --------- Signed-off-by: Dict Xiong <me@beardic.cn> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
76 lines
2.3 KiB
Bash
Executable File
76 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
THIS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
SAGENT="$THIS_DIR/sagent.sh"
|
|
TEST_DIR=$(mktemp -d /tmp/sagent-gpg-pin.XXXXXX)
|
|
trap 'rm -rf "$TEST_DIR"' EXIT
|
|
|
|
MOCK_BIN="$TEST_DIR/bin"
|
|
MOCK_HOME="$TEST_DIR/home"
|
|
MOCK_TMP="$TEST_DIR/tmp"
|
|
MOCK_GPG_ARGS="$TEST_DIR/gpg-args"
|
|
MOCK_GPG_INPUT="$TEST_DIR/gpg-input"
|
|
MOCK_AGENT_LOG="$TEST_DIR/agent-log"
|
|
mkdir -p "$MOCK_BIN" "$MOCK_HOME/gnupg" "$MOCK_HOME/sysconf" "$MOCK_TMP"
|
|
export MOCK_BIN MOCK_HOME MOCK_GPG_ARGS MOCK_GPG_INPUT MOCK_AGENT_LOG
|
|
|
|
cat > "$MOCK_BIN/gpgconf" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf 'gpgconf %s\n' "$*" >> "$MOCK_AGENT_LOG"
|
|
case "$*" in
|
|
'--list-dirs homedir') printf '%s\n' "$MOCK_HOME/gnupg" ;;
|
|
'--list-dirs sysconfdir') printf '%s\n' "$MOCK_HOME/sysconf" ;;
|
|
'--list-dirs bindir') printf '%s\n' "$MOCK_BIN" ;;
|
|
'--launch gpg-agent') ;;
|
|
*) exit 1 ;;
|
|
esac
|
|
EOF
|
|
|
|
cat > "$MOCK_BIN/gpg-connect-agent" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf 'gpg-connect-agent %s\n' "$*" >> "$MOCK_AGENT_LOG"
|
|
EOF
|
|
|
|
cat > "$MOCK_BIN/tty" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf '/dev/pts/mock\n'
|
|
EOF
|
|
|
|
cat > "$MOCK_BIN/gpg" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf '%s\n' "$@" > "$MOCK_GPG_ARGS"
|
|
output=''
|
|
while [[ $# -gt 0 ]]; do
|
|
if [[ "$1" == '--output' ]]; then
|
|
output=$2
|
|
shift 2
|
|
else
|
|
shift
|
|
fi
|
|
done
|
|
cat > "$MOCK_GPG_INPUT"
|
|
printf 'mock signature\n' > "$output"
|
|
EOF
|
|
|
|
printf '#!/usr/bin/env bash\n' > "$MOCK_BIN/pinentry"
|
|
chmod +x "$MOCK_BIN/gpgconf" "$MOCK_BIN/gpg-connect-agent" "$MOCK_BIN/tty" \
|
|
"$MOCK_BIN/gpg" "$MOCK_BIN/pinentry"
|
|
|
|
output=$(HOME="$MOCK_HOME" TMPDIR="$MOCK_TMP" PATH="$MOCK_BIN:$PATH" "$SAGENT" gpg-pin TEST-KEY 2> "$TEST_DIR/stderr")
|
|
[[ -z "$output" ]]
|
|
grep -Fxq -- '--detach-sign' "$MOCK_GPG_ARGS"
|
|
grep -Fxq -- '--local-user' "$MOCK_GPG_ARGS"
|
|
grep -Fxq -- 'TEST-KEY' "$MOCK_GPG_ARGS"
|
|
grep -Fxq -- 'sagt gpg-pin' "$MOCK_GPG_INPUT"
|
|
grep -Fq -- 'gpgconf --launch gpg-agent' "$MOCK_AGENT_LOG"
|
|
grep -Fq -- 'gpg-connect-agent updatestartuptty /bye' "$MOCK_AGENT_LOG"
|
|
grep -Fq -- 'test signature completed' "$TEST_DIR/stderr"
|
|
|
|
output=$(HOME="$MOCK_HOME" TMPDIR="$MOCK_TMP" PATH="$MOCK_BIN:$PATH" "$SAGENT" gpg-pin 2> "$TEST_DIR/stderr")
|
|
[[ -z "$output" ]]
|
|
! grep -Fxq -- '--local-user' "$MOCK_GPG_ARGS"
|
|
[[ -z $(find "$MOCK_TMP" -mindepth 1 -print -quit) ]]
|
|
|
|
echo "sagent gpg-pin tests passed"
|