[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/auth-source-pass dc03c63: auth-source: cleanup com
From: |
Teodor Zlatanov |
Subject: |
[Emacs-diffs] feature/auth-source-pass dc03c63: auth-source: cleanup comments and add some tests |
Date: |
Fri, 3 Feb 2017 21:06:28 +0000 (UTC) |
branch: feature/auth-source-pass
commit dc03c63b33472f473387e9d056f4542a4a50081a
Author: Ted Zlatanov <address@hidden>
Commit: Ted Zlatanov <address@hidden>
auth-source: cleanup comments and add some tests
---
lisp/auth-source.el | 58 ----------------------------------------
test/lisp/auth-source-tests.el | 19 +++++++++++++
2 files changed, 19 insertions(+), 58 deletions(-)
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 7402ab2..a1dd4bb 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -373,28 +373,6 @@ with \"[a/b/c] \" if CHOICES is \(?a ?b ?c)."
(setq k (read-char-choice full-prompt choices)))
k)))
-;; (auth-source-pick nil :host "any" :port 'imap :user "joe")
-;; (auth-source-pick t :host "any" :port 'imap :user "joe")
-;; (setq auth-sources '((:source (:secrets default) :host t :port t :user
"joe")
-;; (:source (:secrets "session") :host t :port t :user "joe")
-;; (:source (:secrets "Login") :host t :port t)
-;; (:source "~/.authinfo.gpg" :host t :port t)))
-
-;; (setq auth-sources '((:source (:secrets default) :host t :port t :user
"joe")
-;; (:source (:secrets "session") :host t :port t :user "joe")
-;; (:source (:secrets "Login") :host t :port t)
-;; ))
-
-;; (setq auth-sources '((:source "~/.authinfo.gpg" :host t :port t)))
-
-;; (auth-source-backend-parse "myfile.gpg")
-;; (auth-source-backend-parse 'default)
-;; (auth-source-backend-parse "secrets:Login")
-;; (auth-source-backend-parse 'macos-keychain-internet)
-;; (auth-source-backend-parse 'macos-keychain-generic)
-;; (auth-source-backend-parse "macos-keychain-internet:/path/here.keychain")
-;; (auth-source-backend-parse "macos-keychain-generic:/path/here.keychain")
-
(defun auth-source-backend-parse (entry)
"Creates an auth-source-backend from an ENTRY in `auth-sources'."
(auth-source-backend-parse-parameters
@@ -781,12 +759,6 @@ must call it to obtain the actual value."
(setq matches (append matches bmatches))))))
matches))
-;; (auth-source-search :max 0)
-;; (auth-source-search :max 1)
-;; (funcall (plist-get (nth 0 (auth-source-search :max 1)) :secret))
-;; (auth-source-search :host "nonesuch" :type 'netrc :K 1)
-;; (auth-source-search :host "nonesuch" :type 'secrets)
-
(defun auth-source-delete (&rest spec)
"Delete entries from the authentication backends according to SPEC.
Calls `auth-source-search' with the :delete property in SPEC set to t.
@@ -886,8 +858,6 @@ while \(:host t) would find all host entries."
(cl-return 'no)))
'no))))
-;; (auth-source-pick-first-password :host "z.lifelogs.com")
-;; (auth-source-pick-first-password :port "imap")
(defun auth-source-pick-first-password (&rest spec)
"Pick the first secret found from applying SPEC to `auth-source-search'."
(let* ((result (nth 0 (apply #'auth-source-search (plist-put spec :max 1))))
@@ -897,7 +867,6 @@ while \(:host t) would find all host entries."
(funcall secret)
secret)))
-;; (auth-source-format-prompt "test %u %h %p" '((?u "user") (?h "host")))
(defun auth-source-format-prompt (prompt alist)
"Format PROMPT using %x (for any character x) specifiers in ALIST."
(dolist (cell alist)
@@ -1119,7 +1088,6 @@ Note that the MAX parameter is used so we can exit the
parse early."
(lambda () p)))
passphrase))))
-;; (auth-source-epa-extract-gpg-token
"gpg:LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tClZlcnNpb246IEdudVBHIHYxLjQuMTEgKEdOVS9MaW51eCkKCmpBMEVBd01DT25qMjB1ak9rZnRneVI3K21iNm9aZWhuLzRad3cySkdlbnVaKzRpeEswWDY5di9icDI1U1dsQT0KPS9yc2wKLS0tLS1FTkQgUEdQIE1FU1NBR0UtLS0tLQo="
"~/.netrc")
(defun auth-source-epa-extract-gpg-token (secret file)
"Pass either the decoded SECRET or the gpg:BASE64DATA version.
FILE is the file from which we obtained this token."
@@ -1134,7 +1102,6 @@ FILE is the file from which we obtained this token."
(defvar pp-escape-newlines)
-;; (insert (auth-source-epa-make-gpg-token "mysecret" "~/.netrc"))
(defun auth-source-epa-make-gpg-token (secret file)
(let ((context (epg-make-context 'OpenPGP))
(pp-escape-newlines nil)
@@ -1193,9 +1160,6 @@ FILE is the file from which we obtained this token."
ret))
alist))
-;; (setq secret (plist-get (nth 0 (auth-source-search :host t :type 'netrc :K
1 :max 1)) :secret))
-;; (funcall secret)
-
(cl-defun auth-source-netrc-search (&rest spec
&key backend require create
type max host user port
@@ -1415,7 +1379,6 @@ See `auth-source-search' for details on SPEC."
(list artificial)))
-;;(funcall (plist-get (nth 0 (auth-source-search :host '("nonesuch2") :user
"tzz" :port "imap" :create t :max 1)) :save-function))
(defun auth-source-netrc-saver (file add)
"Save a line ADD in FILE, prompting along the way.
Respects `auth-source-save-behavior'. Uses
@@ -1496,13 +1459,6 @@ Respects `auth-source-save-behavior'. Uses
;;; Backend specific parsing: Secrets API backend
-;; (let ((auth-sources '(default))) (auth-source-search :max 1 :create t))
-;; (let ((auth-sources '(default))) (auth-source-search :max 1 :delete t))
-;; (let ((auth-sources '(default))) (auth-source-search :max 1))
-;; (let ((auth-sources '(default))) (auth-source-search))
-;; (let ((auth-sources '("secrets:Login"))) (auth-source-search :max 1))
-;; (let ((auth-sources '("secrets:Login"))) (auth-source-search :max 1
:signon_realm "https://git.gnus.org/Git"))
-
(defun auth-source-secrets-listify-pattern (pattern)
"Convert a pattern with lists to a list of string patterns.
@@ -1630,20 +1586,6 @@ authentication tokens:
;;; Backend specific parsing: Mac OS Keychain (using /usr/bin/security) backend
-;; (let ((auth-sources '(macos-keychain-internet))) (auth-source-search :max 1
:create t))
-;; (let ((auth-sources '(macos-keychain-internet))) (auth-source-search :max 1
:delete t))
-;; (let ((auth-sources '(macos-keychain-internet))) (auth-source-search :max
1))
-;; (let ((auth-sources '(macos-keychain-internet))) (auth-source-search))
-
-;; (let ((auth-sources '(macos-keychain-generic))) (auth-source-search :max 1
:create t))
-;; (let ((auth-sources '(macos-keychain-generic))) (auth-source-search :max 1
:delete t))
-;; (let ((auth-sources '(macos-keychain-generic))) (auth-source-search :max 1))
-;; (let ((auth-sources '(macos-keychain-generic))) (auth-source-search))
-
-;; (let ((auth-sources
'("macos-keychain-internet:/Users/tzz/Library/Keychains/login.keychain")))
(auth-source-search :max 1))
-;; (let ((auth-sources '("macos-keychain-generic:Login"))) (auth-source-search
:max 1 :host "git.gnus.org"))
-;; (let ((auth-sources '("macos-keychain-generic:Login"))) (auth-source-search
:max 1))
-
(cl-defun auth-source-macos-keychain-search (&rest spec
&key backend create delete type
max
&allow-other-keys)
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el
index e73f55e..8ecef2e 100644
--- a/test/lisp/auth-source-tests.el
+++ b/test/lisp/auth-source-tests.el
@@ -219,5 +219,24 @@
("login" . "user1")
("machine" . "mymachine1"))))))
+(ert-deftest auth-source-test-format-prompt ()
+ (should (equal (auth-source-format-prompt "test %u %h %p" '((?u "user") (?h
"host")))
+ "test user host %p")))
+
+(ert-deftest auth-source-test-remembrances-of-things-past ()
+ (let ((password-cache t)
+ (password-data (make-vector 7 0)))
+ (auth-source-remember '(:host "wedd") '(4 5 6))
+ (should (auth-source-remembered-p '(:host "wedd")))
+ (should-not (auth-source-remembered-p '(:host "xedd")))
+ (auth-source-remember '(:host "xedd") '(1 2 3))
+ (should (auth-source-remembered-p '(:host "xedd")))
+ (should-not (auth-source-remembered-p '(:host "zedd")))
+ (should (auth-source-recall '(:host "xedd")))
+ (should-not (auth-source-recall nil))
+ (auth-source-forget+ :host t)
+ (should-not (auth-source-remembered-p '(:host "xedd")))
+ (should-not (auth-source-remembered-p '(:host t)))))
+
(provide 'auth-source-tests)
;;; auth-source-tests.el ends here