Debian Codegraph @

pkg/users/test-list-public-keys.sh

raw
1 #!/bin/sh
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 set -euf
5 cd $(dirname $0)
6
7 echo "1..4"
8
9 # Normalize across various ssh-keygen versions
10 normalize()
11 {
12 sed -e 's/\([0-9]\+ \)[A-Za-z0-9:]\+ \+/\1FINGERPRINT /' \
13 -e 's/authorized_keys is not a public key file.//' \
14 -e 's/FINGERPRINT Comment Here (RSA)/FINGERPRINT no comment (RSA)/' \
15 -e 's/FINGERPRINT authorized_keys (RSA)/FINGERPRINT no comment (RSA)/'
16 }
17
18 test_compare()
19 {
20 input="mock/ssh/$1-input"
21 if /bin/sh ./ssh-list-public-keys.sh < $input | normalize | diff -U3 mock/ssh/$1-output - >&2; then
22 echo "ok $1 $input"
23 else
24 echo "not ok $1 $input"
25 fi
26 }
27
28 for n in 1 2 3 4; do
29 test_compare $n
30 done