diff options
author | Tusooa Zhu <tusooa@kazv.moe> | 2022-08-19 14:09:42 -0400 |
---|---|---|
committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-08-19 20:24:24 -0400 |
commit | 3522852c6196cafa63804240f52dd593e09ba694 (patch) | |
tree | 6bb3d929938bdc5baebed816d1b7382a9d3de790 /test/pleroma | |
parent | eb42e90c4f9ca35a6dc0e84e6f87b6f4b680173c (diff) | |
download | pleroma-3522852c6196cafa63804240f52dd593e09ba694.tar.gz |
Test that server will disconnect websocket upon token revocation
Diffstat (limited to 'test/pleroma')
-rw-r--r-- | test/pleroma/integration/mastodon_websocket_test.exs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/pleroma/integration/mastodon_websocket_test.exs b/test/pleroma/integration/mastodon_websocket_test.exs index 1e0319144..adb2d7004 100644 --- a/test/pleroma/integration/mastodon_websocket_test.exs +++ b/test/pleroma/integration/mastodon_websocket_test.exs @@ -91,7 +91,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do {:ok, token} = OAuth.Token.exchange_token(app, auth) - %{user: user, token: token} + %{app: app, user: user, token: token} end test "accepts valid tokens", state do @@ -126,5 +126,21 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do Process.sleep(30) end) end + + test "disconnect when token is revoked", %{app: app, user: user, token: token} do + assert {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}") + assert {:ok, _} = start_socket("?stream=user&access_token=#{token.token}") + + {:ok, auth} = OAuth.Authorization.create_authorization(app, user) + + {:ok, token2} = OAuth.Token.exchange_token(app, auth) + assert {:ok, _} = start_socket("?stream=user&access_token=#{token2.token}") + + OAuth.Token.Strategy.Revoke.revoke(token) + + assert_receive {:close, _} + assert_receive {:close, _} + refute_receive {:close, _} + end end end |