From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.devel Subject: Re: RFC: feature/auth-source-pass branch integrating auth-source with the pass secret manager Date: Tue, 28 Mar 2017 16:26:30 -0400 Message-ID: References: <87shly62bx.fsf@lifelogs.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1490732812 4265 195.159.176.226 (28 Mar 2017 20:26:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 28 Mar 2017 20:26:52 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 28 22:26:46 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csxhJ-0007e1-JU for ged-emacs-devel@m.gmane.org; Tue, 28 Mar 2017 22:26:33 +0200 Original-Received: from localhost ([::1]:55149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csxhP-0007Lk-D4 for ged-emacs-devel@m.gmane.org; Tue, 28 Mar 2017 16:26:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csxhJ-0007Le-S1 for emacs-devel@gnu.org; Tue, 28 Mar 2017 16:26:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csxhI-0001xO-Pz for emacs-devel@gnu.org; Tue, 28 Mar 2017 16:26:33 -0400 Original-Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:36722) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csxhI-0001wo-L1 for emacs-devel@gnu.org; Tue, 28 Mar 2017 16:26:32 -0400 Original-Received: by mail-oi0-x22b.google.com with SMTP id r203so46093516oib.3 for ; Tue, 28 Mar 2017 13:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=9ASVH4Rm8uJWy/I6eArcaHPn27bwjgvHmJwB0bsLVfc=; b=rPnFGcvSS4VybcC5aK06bJQ0SxlNasb0rnzjWQ/YecwJC1aCCosBUmF2IYMsEBYHkH ls0lwvC0Cf9EWnZDBFOsVkDT9cz5w1wppGmGpS/lLTEaDg0wAPDmsLt8N2DbnC6tP2pw 9zixBWMWoMM9LQcNaTsoXfr9otZkEYX7micREe8GNUKRj4sdjLZY2wwuefzDSjGV7qgd G4K3Lus55rWEBzAPYqaiOqwt/aGr2AL11XjPAYQJiknaW1F4l45UdSoagUV/fFkaA/U2 rcNWaYsaD77JaPSKtMbjY4/KZPZx+tLT3sofwYsuRgXSAutpFlIAU3qW22A/mE6SauA/ /3Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=9ASVH4Rm8uJWy/I6eArcaHPn27bwjgvHmJwB0bsLVfc=; b=pP/APX3pGE7HNRA1Xbr9/ieiV3y7zC3eIcBFLwJnApAtZFlV0fY3+C/ouy4OQn6Rr/ lCb43gtuIV9ib+pxJVELQ8jDJ/G5qS7HUaMaWgkHX046IC4dX+KMFYbeqC8ZlrfqSSga GXmEDyIQjtyqwlhf5LxQ03vQUpZaspzd0q9jD0KtRZDtZGA76zZ+9sXyrSGWIDzu3wFa R7FHnWw/ne4giAD38PkIGr75+vQ31Z1UYNLd5bPm6SsrTPjgBVfHSVCZOhKaUvvcveZh D6Cs3Fbdqy1WgS0xsd6qraO1uMZSTyVAdhOkcLthpA1E6WIvrZkNNsTJag9ffjoRU1nx Fx/w== X-Gm-Message-State: AFeK/H0+xV519xK44VEP/Y6v4aj2nEwk0Hy3GZFw33anHkBNZX4pRvlIHDYnr5hRTvPFwwQszX+iIZNUHq/3+g== X-Received: by 10.202.74.87 with SMTP id x84mr12848850oia.187.1490732791321; Tue, 28 Mar 2017 13:26:31 -0700 (PDT) Original-Received: by 10.157.80.172 with HTTP; Tue, 28 Mar 2017 13:26:30 -0700 (PDT) In-Reply-To: <87shly62bx.fsf@lifelogs.com> X-Google-Sender-Auth: 5BEow3jIXZx0d1ENLaDAJJez8z8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213461 Archived-At: On Mon, Mar 27, 2017 at 1:45 PM, Ted Zlatanov wrote: > Please comment on the code, if you have any questions or concerns. +(defun auth-source-pass--remove-directory-name (name) + "Remove directories from NAME. +E.g., if NAME is \"foo/bar\", return \"bar\"." + (replace-regexp-in-string ".*/" "" name)) This could be replaced with `file-name-nondirectory', I think. +(defun auth-source-pass--should-have-message-containing (regexp) + "Assert that at least one `auth-source-do-debug` matched REGEXP." + (should (seq-find (lambda (message) + (string-match regexp message)) + auth-source-pass--debug-log))) The reliance on debug prints for the tests seems a bit strange to me (I don't really have a better suggestion though). +(defmacro auth-source-pass--deftest (name arglist store &rest body) + "Define a new ert-test NAME with ARGLIST using STORE as password-store. +BODY is a sequence of instructions that will be evaluated. + +This macro overrides `auth-source-pass-parse-entry' and `auth-source-pass-entries' to +test code without touching the file system." I would suggest rather defining auth-source-pass--with-store, and leaving the test defining part to ert-deftest. So that, e.g., (auth-source-pass--deftest auth-source-pass-find-match-matching-at-entry-name () '(("foo")) (should (equal (auth-source-pass--find-match "foo" nil) "foo"))) becomes (ert-deftest auth-source-pass-find-match-matching-at-entry-name () (auth-source-pass--with-store '(("foo")) (should (equal (auth-source-pass--find-match "foo" nil) "foo"))))