diff options
author | lambda <lain@soykaf.club> | 2019-05-02 14:17:17 +0000 |
---|---|---|
committer | lambda <lain@soykaf.club> | 2019-05-02 14:17:17 +0000 |
commit | 497d34b825bd3600b2067a8c47e29f41234fa315 (patch) | |
tree | 91e753d7ff43aaa6611c9c4cbe143ce904d6f43e /test | |
parent | d107919b3d8b2275ddb7b17846cab182682098a7 (diff) | |
parent | a53a6c9d64f2c32ca3b53a4317980b3e7c0b37a5 (diff) | |
download | pleroma-497d34b825bd3600b2067a8c47e29f41234fa315.tar.gz |
Merge branch 'iss-849' into 'develop'
Parse access_token from body parameters and URL parameters
See merge request pleroma/pleroma!1103
Diffstat (limited to 'test')
-rw-r--r-- | test/plugs/oauth_plug_test.exs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/plugs/oauth_plug_test.exs b/test/plugs/oauth_plug_test.exs index 17fdba916..5a2ed11cc 100644 --- a/test/plugs/oauth_plug_test.exs +++ b/test/plugs/oauth_plug_test.exs @@ -38,6 +38,26 @@ defmodule Pleroma.Plugs.OAuthPlugTest do assert conn.assigns[:user] == opts[:user] end + test "with valid token(downcase) in url parameters, it assings the user", opts do + conn = + :get + |> build_conn("/?access_token=#{opts[:token]}") + |> put_req_header("content-type", "application/json") + |> fetch_query_params() + |> OAuthPlug.call(%{}) + + assert conn.assigns[:user] == opts[:user] + end + + test "with valid token(downcase) in body parameters, it assigns the user", opts do + conn = + :post + |> build_conn("/api/v1/statuses", access_token: opts[:token], status: "test") + |> OAuthPlug.call(%{}) + + assert conn.assigns[:user] == opts[:user] + end + test "with invalid token, it not assigns the user", %{conn: conn} do conn = conn |