-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add test suite for autosign.bash #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
07f2c10 to
f8904f9
Compare
mgorny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use consistent coding style, fix whitespace and add error handling, for a start.
f8904f9 to
a364c61
Compare
|
@mgorny you can recheck it; it does pass on woodpecker btw |
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
a364c61 to
83e8045
Compare
|
What format-checker do you recommend then since neither shfmt-3.1.2 nor shellcheck-0.10.0 are catching these, and I missed two inconsistencies only. |
|
I have never used a formatter for shell code. |
| export AUTOSIGN_TMPDIR GNUPGHOME | ||
| echo "Testing tmpdir is ${AUTOSIGN_TMPDIR}" | ||
|
|
||
| umask 077 && mkdir -p "${GNUPGHOME}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error handling.
| echo "Testing tmpdir is ${AUTOSIGN_TMPDIR}" | ||
|
|
||
| umask 077 && mkdir -p "${GNUPGHOME}" | ||
| [[ -n ${AUTOSIGN_NO_SEND_KEYS} ]] || echo "keyserver ${LOCAL_KEYSERVER}" >"${GNUPGHOME}"/gpg.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error handling.
| # this is to ensure there are other secret keys, and we aren't just lucky with the | ||
| # code picking a random key that was the correct one for the key. | ||
| for f in {1..4}; do | ||
| gpg --batch --passphrase '' --quick-gen-key "Dummy Key 0x$(printf %04x "${f}")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error handling.
| } | ||
|
|
||
| echo "Generating authority keys ..." | ||
| gpg -q --batch --passphrase '' --quick-gen-key "${authuid_foo}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error handling.
| echo "Generating authority keys ..." | ||
| gpg -q --batch --passphrase '' --quick-gen-key "${authuid_foo}" | ||
| authfpr_foo=$( | ||
| gpg --with-colon --list-secret-keys "${authuid_foo}" | gpg_colon_get_sec_fpr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| gpg --with-colon --list-secret-keys "${authuid_foo}" | gpg_colon_get_sec_fpr | |
| gpg_colon_get_sec_fpr < <(gpg --with-colon --list-secret-keys "${authuid_foo}") |
Also no error handling.
| gpg --with-colons --check-sig \ | ||
| --trusted-key "${authfpr_foo}" \ | ||
| --trusted-key "${authfpr_bar}" \ | ||
| >"${AUTOSIGN_TMPDIR}"/verification-${n}.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error handling.
| gpg --with-colons --check-sig \ | ||
| --trusted-key "${authfpr_foo}" \ | ||
| --trusted-key "${authfpr_bar}" \ | ||
| >"${AUTOSIGN_TMPDIR}"/verification-${n}.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error handling.
| <(grep -E -e '^uid:.:.*\<a[^@]+@gentoo.org>:' <"${AUTOSIGN_TMPDIR}"/verification-03.txt) \ | ||
| <(grep -E -e '^uid:.:.*\<a[^@]+@gentoo.org>:' <"${AUTOSIGN_TMPDIR}"/verification-04.txt) \ | ||
| -I '^tru:' \ | ||
| >"${AUTOSIGN_TMPDIR}"/diff-03-04.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error handling.
| <(grep -E -e '^uid:.:.*\<a[^@]+@gentoo.org>:' <"${AUTOSIGN_TMPDIR}"/verification-04.txt) \ | ||
| -I '^tru:' \ | ||
| >"${AUTOSIGN_TMPDIR}"/diff-03-04.txt | ||
| cat "${AUTOSIGN_TMPDIR}"/diff-03-04.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that debug?
| AUTOSIGN_TMPDIR=${AUTOSIGN_TMPDIR}/${n}-foo/ AUTOSIGN_GPG_LOCAL_FPR=${authfpr_foo} bash ./autosign.bash | ||
| AUTOSIGN_TMPDIR=${AUTOSIGN_TMPDIR}/${n}-bar/ AUTOSIGN_GPG_LOCAL_FPR=${authfpr_bar} bash ./autosign.bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to check for unsuccessful return here too.
Redoing #1 work - starting with test suite before any changes.
Signed-off-by: Robin H. Johnson robbat2@gentoo.org