diff options
author | kaniini <nenolod@gmail.com> | 2018-10-14 19:29:58 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2018-10-14 19:29:58 +0000 |
commit | e0c035589a570d1be7bf0f2f9ab3d78b2ed79462 (patch) | |
tree | 5654d6c9657fd92cd05bdfee3e20d5898da982f2 /test/web/oauth/token_test.exs | |
parent | 117e005409c75c2d53df88fa19211823bdf3d61e (diff) | |
parent | eacab0fb056ffc018b7e0abea27db7af435dc553 (diff) | |
download | pleroma-e0c035589a570d1be7bf0f2f9ab3d78b2ed79462.tar.gz pleroma-e0c035589a570d1be7bf0f2f9ab3d78b2ed79462.zip |
Merge branch 'security/clear-oauth-with-password' into 'develop'
Delete Tokens and Authorizations on password change
Closes #320
See merge request pleroma/pleroma!375
Diffstat (limited to 'test/web/oauth/token_test.exs')
-rw-r--r-- | test/web/oauth/token_test.exs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/web/oauth/token_test.exs b/test/web/oauth/token_test.exs index 58448949c..f926ff50b 100644 --- a/test/web/oauth/token_test.exs +++ b/test/web/oauth/token_test.exs @@ -29,4 +29,36 @@ defmodule Pleroma.Web.OAuth.TokenTest do auth = Repo.get(Authorization, auth.id) {:error, "already used"} = Token.exchange_token(app, auth) end + + test "deletes all tokens of a user" do + {:ok, app1} = + Repo.insert( + App.register_changeset(%App{}, %{ + client_name: "client1", + scopes: "scope", + redirect_uris: "url" + }) + ) + + {:ok, app2} = + Repo.insert( + App.register_changeset(%App{}, %{ + client_name: "client2", + scopes: "scope", + redirect_uris: "url" + }) + ) + + user = insert(:user) + + {:ok, auth1} = Authorization.create_authorization(app1, user) + {:ok, auth2} = Authorization.create_authorization(app2, user) + + {:ok, token1} = Token.exchange_token(app1, auth1) + {:ok, token2} = Token.exchange_token(app2, auth2) + + {tokens, _} = Token.delete_user_tokens(user) + + assert tokens == 2 + end end |