diff --git a/tests/core/core-configuration-layer-ftest.el b/tests/core/core-configuration-layer-ftest.el index 752a99167..be460860f 100644 --- a/tests/core/core-configuration-layer-ftest.el +++ b/tests/core/core-configuration-layer-ftest.el @@ -46,5 +46,48 @@ (should (eq 'spacemacs-base (third configuration-layer--used-layers))))) ;; --------------------------------------------------------------------------- -;; Lazy installation of layers +;; configuration-layer//stable-elpa-verify-archive ;; --------------------------------------------------------------------------- + +(ert-deftest test-stable-elpa-verify-archive--verification-ok () + (cl-letf (((symbol-function 'configuration-layer//stable-elpa-tarball-local-file) + (lambda () + (concat spacemacs-test-directory + "core/data/signed-test-stable-elpa.tar.gz"))) + ((symbol-function 'configuration-layer//stable-elpa-tarball-local-sign-file) + (lambda () + (concat spacemacs-test-directory + "core/data/signed-test-stable-elpa.tar.gz.sig"))) + ((symbol-function 'configuration-layer//stable-elpa-ask-to-continue) + (lambda (x) + (message "Verification Error: %s" x) + nil)) + ((symbol-function 'configuration-layer//error) + (lambda (x) + (message "Fatal Error: %s" x) + nil)) + ((symbol-function 'message) 'ignore)) + (should (equal t (configuration-layer//stable-elpa-verify-archive))))) + +(ert-deftest test-stable-elpa-verify-archive--verification-failed () + (let (verification-error) + (cl-letf (((symbol-function 'configuration-layer//stable-elpa-tarball-local-file) + (lambda () + (concat spacemacs-test-directory + "core/data/test-stable-elpa.tar.gz"))) + ((symbol-function 'configuration-layer//stable-elpa-tarball-local-sign-file) + (lambda () + (concat spacemacs-test-directory + "core/data/signed-test-stable-elpa.tar.gz.sig"))) + ((symbol-function 'configuration-layer//stable-elpa-ask-to-continue) + (lambda (x) + (setq verification-error x) + nil)) + ((symbol-function 'configuration-layer//error) + (lambda (x) + (message "Fatal Error: %s" x) + nil)) + ((symbol-function 'message) 'ignore)) + (should (and (null (configuration-layer//stable-elpa-verify-archive)) + (string-match-p "^Verification failed!.*" + verification-error)))))) diff --git a/tests/core/core-configuration-layer-utest.el b/tests/core/core-configuration-layer-utest.el index 0d300142b..df8a94fda 100644 --- a/tests/core/core-configuration-layer-utest.el +++ b/tests/core/core-configuration-layer-utest.el @@ -3016,3 +3016,44 @@ :reqs '((foo 7))))) (let ((patched-pkg (configuration-layer//package-install-org 'identity pkg))) (should (equal pkg patched-pkg))))) + +;; --------------------------------------------------------------------------- +;; configuration-layer//stable-elpa-verify-archive +;; --------------------------------------------------------------------------- + +(ert-deftest test-stable-elpa-verify-archive--archive-not-found-is-fatal-error () + (mocker-let + ((configuration-layer//stable-elpa-tarball-local-file + nil ((:record-cls 'mocker-stub-record + :output + (concat spacemacs-test-directory + "core/data/not-found.tar.gz") + :occur 1))) + (configuration-layer//stable-elpa-tarball-local-sign-file + nil ((:record-cls 'mocker-stub-record + :output + (concat spacemacs-test-directory + "core/data/stable-elpa.sig") + :occur 1))) + (configuration-layer//error + (msg &rest args) ((:record-cls 'mocker-stub-record :occur 1)))) + (should (null (configuration-layer//stable-elpa-verify-archive))))) + + +(ert-deftest test-stable-elpa-verify-archive--signature-not-found-is-fatal-error () + (mocker-let + ((configuration-layer//stable-elpa-tarball-local-file + nil ((:record-cls 'mocker-stub-record + :output + (concat spacemacs-test-directory + "core/data/signed-stable-elpa.tar.gz") + :occur 1))) + (configuration-layer//stable-elpa-tarball-local-sign-file + nil ((:record-cls 'mocker-stub-record + :output + (concat spacemacs-test-directory + "core/data/not-found.sig") + :occur 1))) + (configuration-layer//error + (msg &rest args) ((:record-cls 'mocker-stub-record :occur 1)))) + (should (null (configuration-layer//stable-elpa-verify-archive))))) diff --git a/tests/core/data/signed-test-stable-elpa.tar.gz b/tests/core/data/signed-test-stable-elpa.tar.gz new file mode 100644 index 000000000..f08c7c8e1 Binary files /dev/null and b/tests/core/data/signed-test-stable-elpa.tar.gz differ diff --git a/tests/core/data/signed-test-stable-elpa.tar.gz.sig b/tests/core/data/signed-test-stable-elpa.tar.gz.sig new file mode 100644 index 000000000..d4e507368 Binary files /dev/null and b/tests/core/data/signed-test-stable-elpa.tar.gz.sig differ diff --git a/tests/core/data/test-stable-elpa.tar.gz b/tests/core/data/test-stable-elpa.tar.gz new file mode 100644 index 000000000..7609213fb Binary files /dev/null and b/tests/core/data/test-stable-elpa.tar.gz differ