@@ -6,35 +6,70 @@ if [[ "$(uname -s)" != Linux ]]; then
66 exit 0
77fi
88
9- secret_tool_path=" $( command -v secret-tool || true) "
10- if [[ -n " $secret_tool_path " ]]; then
11- echo " === secret-tool -> ${secret_tool_path} ==="
12- secret-tool --version 2> /dev/null || true
13- echo " OK: secret-tool on PATH"
9+ echo " === apt ==="
10+ if command -v apt-get > /dev/null 2>&1 ; then
11+ echo " apt-get is available at $( command -v apt-get) "
12+
13+ missing_tools=()
14+ command -v secret-tool > /dev/null 2>&1 || missing_tools+=(" secret-tool" )
15+ command -v gnome-keyring-daemon > /dev/null 2>&1 || missing_tools+=(" gnome-keyring-daemon" )
16+ command -v dbus-run-session > /dev/null 2>&1 || missing_tools+=(" dbus-run-session" )
17+
18+ if [[ " ${# missing_tools[@]} " -gt 0 ]]; then
19+ echo " Installing missing Linux keyring dependencies for: ${missing_tools[*]} "
20+ apt_cmd=" apt-get"
21+ if [[ " $( id -u) " -ne 0 ]] && command -v sudo > /dev/null 2>&1 ; then
22+ apt_cmd=" sudo apt-get"
23+ fi
24+ $apt_cmd update
25+ $apt_cmd install -y libsecret-tools gnome-keyring dbus-user-session
26+ fi
1427else
15- echo " === secret-tool ==="
16- echo " MISSING: secret-tool not on PATH"
28+ echo " apt-get not on PATH"
1729fi
1830
19- if command -v which > /dev/null 2>&1 ; then
20- echo " === which ==="
21- echo " which is available at $( command -v which) "
22- else
23- echo " which not on PATH"
31+ if ! command -v dbus-run-session > /dev/null 2>&1 ; then
32+ echo " MISSING: dbus-run-session (cannot run secret-tool probe session)"
33+ exit 1
2434fi
2535
26- echo " === related binaries (gnome-keyring / dbus session) ==="
27- for cmd in gnome-keyring-daemon dbus-run-session; do
28- if command -v " $cmd " > /dev/null 2>&1 ; then
29- echo " OK: ${cmd} -> $( command -v " $cmd " ) "
30- else
31- echo " MISSING: ${cmd} "
32- fi
33- done
36+ if ! command -v gnome-keyring-daemon > /dev/null 2>&1 ; then
37+ echo " MISSING: gnome-keyring-daemon (cannot run secret-tool probe session)"
38+ exit 1
39+ fi
3440
35- echo " === apt ==="
36- if command -v apt-get > /dev/null 2>&1 ; then
37- echo " apt-get is available at $( command -v apt-get) "
38- else
39- echo " apt-get not on PATH"
41+ if ! command -v secret-tool > /dev/null 2>&1 ; then
42+ echo " MISSING: secret-tool (cannot run secret-tool probe session)"
43+ exit 1
4044fi
45+
46+ echo " === secret-tool round-trip in dbus session ==="
47+ dbus-run-session -- bash -c '
48+ set -euo pipefail
49+ eval "$(echo -n "heroku-credential-manager-ci" | gnome-keyring-daemon --unlock --components=secrets)"
50+
51+ service="heroku-cli-probe-linux"
52+ account="probe-linux@example.com"
53+ token="probe-linux-token"
54+
55+ echo "store credential"
56+ printf "%s" "$token" | secret-tool store --label="Heroku CLI Probe" service "$service" account "$account"
57+
58+ echo "lookup credential"
59+ looked_up="$(secret-tool lookup service "$service" account "$account")"
60+ if [[ "$looked_up" != "$token" ]]; then
61+ echo "ERROR: lookup mismatch (got: ${looked_up})"
62+ exit 1
63+ fi
64+ echo "OK: lookup matched expected token"
65+
66+ echo "remove credential"
67+ secret-tool clear service "$service" account "$account"
68+
69+ echo "verify removal"
70+ if secret-tool lookup service "$service" account "$account" >/dev/null 2>&1; then
71+ echo "ERROR: credential still present after clear"
72+ exit 1
73+ fi
74+ echo "OK: credential removed"
75+ '
0 commit comments