[core] Add "unit" and functional tests for archvie verification
This commit is contained in:
parent
cfb12e9bd5
commit
09af9fc40b
|
@ -46,5 +46,48 @@
|
||||||
(should (eq 'spacemacs-base (third configuration-layer--used-layers)))))
|
(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))))))
|
||||||
|
|
|
@ -3016,3 +3016,44 @@
|
||||||
:reqs '((foo 7)))))
|
:reqs '((foo 7)))))
|
||||||
(let ((patched-pkg (configuration-layer//package-install-org 'identity pkg)))
|
(let ((patched-pkg (configuration-layer//package-install-org 'identity pkg)))
|
||||||
(should (equal pkg patched-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)))))
|
||||||
|
|
BIN
tests/core/data/signed-test-stable-elpa.tar.gz
Normal file
BIN
tests/core/data/signed-test-stable-elpa.tar.gz
Normal file
Binary file not shown.
BIN
tests/core/data/signed-test-stable-elpa.tar.gz.sig
Normal file
BIN
tests/core/data/signed-test-stable-elpa.tar.gz.sig
Normal file
Binary file not shown.
BIN
tests/core/data/test-stable-elpa.tar.gz
Normal file
BIN
tests/core/data/test-stable-elpa.tar.gz
Normal file
Binary file not shown.
Loading…
Reference in a new issue