1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-18 08:51:45 -08:00
emacs/test/lisp
Keith Amidon 0a580c187d
Minimize entry parsing in auth-source-pass
Prior to this commit, while searching for the most applicable entry
password-store entries were decrypted and parsed to ensure they were
valid.  The entries were parsed in the order they were found on the
filesystem and all applicable entries would be decrypted and parsed,
which varied based on the contents of the password-store and the entry
to be found.

This is fine when the GPG key is cached and each entry can be
decrypted without user interaction.  However, for security some people
have their GPG on a hardware token like a Yubikey setup so that they
have to touch a sensor on the toke for every cryptographic operation,
in which case it becomes inconvenient as each attempt to find an entry
requires a variable number of touches of the hardware token.

The implementation already assumes that names which contain more of
the information in the search key should be preferred so there is an
ordering of preference of applicable entries.  If the decrypt and
parsing is removed from the initial identification of applicable
entries in the store then in most cases a single decrypt and parse of
the most preferred entry will suffice, improving the experience for
hardware token users that require interaction with the token.

This commit implements that strategy.  It is in spirit a refactor of
the existing code.

* lisp/auth-source-pass.el (auth-source-pass--matching-entries): New
function, generate an ordered list of regular expression matchers for
all possible names that could be in the password-store for the entry
to be found and then makes a pass over the password-store entry names
accumulating the matching entries in a list after the regexp that
matched.  This implementation ensures the password-store entry list
still only has to be scanned once.
(auth-source-pass--find-match-unambiguous): Use it to obtain candidate
entries and then parse them one by one until an entry containing the
desired information is located.  When complete, return the parsed data
of the entry instead of the entry name so that the information can be
used directly to construct the auth-source response.
(auth-source-pass--build-result): Update accordingly.
(auth-source-pass--find-match): Update docstring accordingly.
(auth-source-pass--select-one-entry)
(auth-source-pass--entry-valid-p)
(auth-source-pass--find-all-by-entry-name)
(auth-source-pass--find-one-by-entry-name): Remove.
(auth-source-pass--select-from-entries)
(auth-source-pass--accumulate-matches)
(auth-source-pass--entry-reducer)
(auth-source-pass--generate-entry-suffixes)
(auth-source-pass--domains)
(auth-source-pass--name-port-user-suffixes): New functions.

* test/lisp/auth-source-pass-tests.el: One test case was added to the
test suite to verify that only the minimal number of entries are
parsed in common cases.  The
auth-source-pass-only-return-entries-that-can-be-open test case had to
be re-implemented because the function it was used eliminated as the
functionality is provided elsewhere.  All the other fairly substantial
changes to the test suite are the result of mechanical changes that
were required to adapt to auth-source-pass--find-match returning the
data from a parsed password-store entry instead of the entry name.
2019-06-24 09:15:40 +02:00
..
calc
calendar
custom-resources New test custom--test-theme-variables 2019-01-10 13:27:34 +01:00
emacs-lisp Compile any subsequence of `cond' clauses to switch (bug#36139) 2019-06-19 11:22:21 +02:00
emulation
erc
eshell Update more copyright years 2018-12-31 18:47:22 -08:00
gnus ; Copyright years and license copyedits 2019-04-02 21:40:56 -07:00
international * lisp/international/mule-cmds.el (encode-coding-char): Fix ASCII case 2019-05-28 19:33:20 -04:00
mail Add tests for mail/flow-fill.el 2019-06-22 12:15:40 +03:00
net Make rcirc parsing more RFC2812 compliant (Bug#36233) 2019-06-22 19:25:44 -04:00
nxml Keep nxml prolog updated via syntax-propertize 2019-06-05 20:30:23 -04:00
org Go back to "Maintainer: emacs-devel@gnu.org" 2019-05-25 14:25:18 -07:00
play Use lexical-binding in morse.el and studly.el and add tests 2019-06-01 18:52:22 -07:00
progmodes Fix python docstring auto-fill (Bug#36056) 2019-06-22 19:25:44 -04:00
textmodes Split up and add tests for two page.el functions 2019-06-23 07:27:19 +02:00
url Merge from origin/emacs-26 2019-06-15 09:50:33 -07:00
vc Go back to "Maintainer: emacs-devel@gnu.org" 2019-05-25 14:25:18 -07:00
abbrev-tests.el Fix defining inverse abbrevs on previous words (Bug#36243) 2019-06-22 19:25:44 -04:00
arc-mode-tests.el * lisp/tar-mode.el (tar-extract): Call tar--try-jka-compr (bug#34251) 2019-02-03 23:00:29 +02:00
auth-source-pass-tests.el Minimize entry parsing in auth-source-pass 2019-06-24 09:15:40 +02:00
auth-source-tests.el
autoinsert-tests.el Use lexical-binding in autoinsert.el and add tests 2019-05-31 19:07:48 +02:00
autorevert-tests.el Tag remote autorevert tests as unstable 2019-06-15 11:08:05 +02:00
buff-menu-tests.el
button-tests.el Distinguish buttons from widgets (bug#34506) 2019-04-07 03:56:27 +01:00
char-fold-tests.el * lisp/char-fold.el (char-fold-make-table): New function 2019-06-03 23:18:31 +03:00
color-tests.el
comint-tests.el Add "pin" to password-word-equivalents (Bug#35523) 2019-06-06 19:29:42 -04:00
custom-tests.el New test custom--test-theme-variables 2019-01-10 13:27:34 +01:00
dabbrev-tests.el
delim-col-tests.el Use lexical-binding in delim-col.el and add tests 2019-05-20 15:29:26 +01:00
descr-text-tests.el Update author/maintainer info 2019-05-26 01:00:16 -07:00
dired-aux-tests.el
dired-tests.el
dired-x-tests.el
dom-tests.el
electric-tests.el electric-layout-mode kicks in before electric-pair-mode 2019-01-22 16:42:43 +00:00
epg-tests.el
faces-tests.el Fix bug with face-id after restoring from pdump 2019-01-28 17:24:04 +02:00
ffap-tests.el
filenotify-tests.el Fix problem in remote file notification 2019-06-14 19:45:00 +02:00
files-tests.el Optional space and unit in `file-size-human-readable' (bug#35756) 2019-06-23 20:30:50 +02:00
files-x-tests.el Do not hardcode "/bin/sh" in compile. Bug#24338, Bug#29723 2019-03-09 16:44:24 +01:00
font-lock-tests.el Stop splicing anonymous faces in font-lock-append-text-property 2019-05-13 20:41:02 -04:00
help-fns-tests.el Go back to "Maintainer: emacs-devel@gnu.org" 2019-05-25 14:25:18 -07:00
hi-lock-tests.el
htmlfontify-tests.el
ibuffer-tests.el
ido-tests.el Add a new user option 'ido-big-directories'. 2019-04-19 10:31:02 +02:00
image-file-tests.el Replace use of obsolete string-make-unibyte 2019-04-28 16:45:13 -04:00
image-tests.el For SVG, 8192 is the new 256 2019-05-18 10:01:10 -07:00
imenu-tests.el
info-xref-tests.el
isearch-tests.el
jit-lock-tests.el
json-tests.el
jsonrpc-tests.el Remove Maintainer: when it duplicates Author: 2019-05-26 01:00:15 -07:00
kmacro-tests.el
ls-lisp-tests.el
makesum-tests.el Use lexical-binding in makesum.el and add tests 2019-05-29 20:47:16 +02:00
man-tests.el
md4-tests.el Go back to "Maintainer: emacs-devel@gnu.org" 2019-05-25 14:25:18 -07:00
minibuffer-tests.el * test/lisp/minibuffer-tests.el (completion-table-subvert-test): New test 2019-03-20 10:52:30 -04:00
mouse-tests.el
obarray-tests.el
paren-tests.el Use lexical-binding in paren.el and add tests 2019-05-26 11:22:27 +02:00
password-cache-tests.el Use lexical-binding in password-cache.el and add tests 2019-06-09 10:08:36 -07:00
ps-print-tests.el
register-tests.el
replace-tests.el
rot13-tests.el
ses-tests.el
shadowfile-tests.el
shell-tests.el
simple-tests.el Fix recently extended delete-indentation behavior 2019-03-31 17:08:21 +01:00
sort-tests.el
soundex-tests.el Go back to "Maintainer: emacs-devel@gnu.org" 2019-05-25 14:25:18 -07:00
subr-tests.el * lisp/subr.el (add-hook): Turn append into depth (bug#35508) 2019-05-29 15:56:14 -04:00
tabify-tests.el Tweak recent additions in tabify-tests.el 2019-05-26 11:56:57 +01:00
tar-mode-tests.el * lisp/tar-mode.el (tar-extract): Call tar--try-jka-compr (bug#34251) 2019-02-03 23:00:29 +02:00
tempo-tests.el Use lexical-binding in tempo.el and add tests 2019-05-21 15:23:23 +01:00
term-tests.el Fix failures of term-tests on MS-Widows 2019-06-07 12:01:11 +03:00
thingatpt-tests.el
thread-tests.el Update more copyright years 2018-12-31 18:47:22 -08:00
timezone-tests.el Use lexical-binding in timezone.el and add tests 2019-06-01 01:44:31 -07:00
wdired-tests.el Make wdired-mode ignore ls file indicators 2019-04-25 19:17:23 +02:00
whitespace-tests.el
wid-edit-tests.el Distinguish buttons from widgets (bug#34506) 2019-04-07 03:56:27 +01:00
xdg-tests.el Go back to "Maintainer: emacs-devel@gnu.org" 2019-05-25 14:25:18 -07:00
xml-tests.el
xt-mouse-tests.el