aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-auth-tests.el
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2021-11-08 20:28:25 +0100
committerHolger Dürer <me@hdurer.net>2021-11-10 20:12:12 +0100
commit5df05d94926ada6843cbc65aea4b64c18429fdf1 (patch)
tree4bcf94f80a01c7338e191beffa3bfbac68908c6e /test/mastodon-auth-tests.el
parent6b4a47290bf32f5be670d6aa92c3e7780e667ff3 (diff)
Reformatting `mastodon-search-tests.el`.
- Remove redundant let binding of vars - Re-indent various things to better fit reasonably on a screen.
Diffstat (limited to 'test/mastodon-auth-tests.el')
-rw-r--r--test/mastodon-auth-tests.el80
1 files changed, 40 insertions, 40 deletions
diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el
index 69c34a4..fda04eb 100644
--- a/test/mastodon-auth-tests.el
+++ b/test/mastodon-auth-tests.el
@@ -3,52 +3,52 @@
(ert-deftest generate-token--no-storing-credentials ()
"Should make `mastdon-http--post' request to generate auth token."
(with-mock
- (let ((mastodon-auth-source-file "")
- (mastodon-instance-url "https://instance.url"))
- (mock (mastodon-client) => '(:client_id "id" :client_secret "secret"))
- (mock (read-string "Email: " user-mail-address) => "foo@bar.com")
- (mock (read-passwd "Password: ") => "password")
- (mock (mastodon-http--post "https://instance.url/oauth/token"
- '(("client_id" . "id")
- ("client_secret" . "secret")
- ("grant_type" . "password")
- ("username" . "foo@bar.com")
- ("password" . "password")
- ("scope" . "read write follow"))
- nil
- :unauthenticated))
- (mastodon-auth--generate-token))))
+ (let ((mastodon-auth-source-file "")
+ (mastodon-instance-url "https://instance.url"))
+ (mock (mastodon-client) => '(:client_id "id" :client_secret "secret"))
+ (mock (read-string "Email: " user-mail-address) => "foo@bar.com")
+ (mock (read-passwd "Password: ") => "password")
+ (mock (mastodon-http--post "https://instance.url/oauth/token"
+ '(("client_id" . "id")
+ ("client_secret" . "secret")
+ ("grant_type" . "password")
+ ("username" . "foo@bar.com")
+ ("password" . "password")
+ ("scope" . "read write follow"))
+ nil
+ :unauthenticated))
+ (mastodon-auth--generate-token))))
(ert-deftest generate-token--storing-credentials ()
"Should make `mastdon-http--post' request to generate auth token."
(with-mock
- (let ((mastodon-auth-source-file "~/.authinfo")
- (mastodon-instance-url "https://instance.url"))
- (mock (mastodon-client) => '(:client_id "id" :client_secret "secret"))
- (mock (auth-source-search :create t
- :host "https://instance.url"
- :port 443
- :require '(:user :secret))
- => '((:user "foo@bar.com" :secret (lambda () "password"))))
- (mock (mastodon-http--post "https://instance.url/oauth/token"
- '(("client_id" . "id")
- ("client_secret" . "secret")
- ("grant_type" . "password")
- ("username" . "foo@bar.com")
- ("password" . "password")
- ("scope" . "read write follow"))
- nil
- :unauthenticated))
- (mastodon-auth--generate-token))))
+ (let ((mastodon-auth-source-file "~/.authinfo")
+ (mastodon-instance-url "https://instance.url"))
+ (mock (mastodon-client) => '(:client_id "id" :client_secret "secret"))
+ (mock (auth-source-search :create t
+ :host "https://instance.url"
+ :port 443
+ :require '(:user :secret))
+ => '((:user "foo@bar.com" :secret (lambda () "password"))))
+ (mock (mastodon-http--post "https://instance.url/oauth/token"
+ '(("client_id" . "id")
+ ("client_secret" . "secret")
+ ("grant_type" . "password")
+ ("username" . "foo@bar.com")
+ ("password" . "password")
+ ("scope" . "read write follow"))
+ nil
+ :unauthenticated))
+ (mastodon-auth--generate-token))))
(ert-deftest get-token ()
"Should generate token and return JSON response."
(with-temp-buffer
(with-mock
- (mock (mastodon-auth--generate-token) => (progn
- (insert "\n\n{\"access_token\":\"abcdefg\"}")
- (current-buffer)))
- (should (equal (mastodon-auth--get-token) '(:access_token "abcdefg"))))))
+ (mock (mastodon-auth--generate-token) => (progn
+ (insert "\n\n{\"access_token\":\"abcdefg\"}")
+ (current-buffer)))
+ (should (equal (mastodon-auth--get-token) '(:access_token "abcdefg"))))))
(ert-deftest access-token-found ()
"Should return value in `mastodon-auth--token-alist' if found."
@@ -61,6 +61,6 @@
(let ((mastodon-instance-url "https://instance.url")
(mastodon-auth--token nil))
(with-mock
- (mock (mastodon-auth--get-token) => '(:access_token "foobaz"))
- (should (string= (mastodon-auth--access-token) "foobaz"))
- (should (equal mastodon-auth--token-alist '(("https://instance.url" . "foobaz")))))))
+ (mock (mastodon-auth--get-token) => '(:access_token "foobaz"))
+ (should (string= (mastodon-auth--access-token) "foobaz"))
+ (should (equal mastodon-auth--token-alist '(("https://instance.url" . "foobaz")))))))