summaryrefslogtreecommitdiff
path: root/test/plugs/authentication_plug_test.exs
diff options
context:
space:
mode:
authorhref <href@random.sh>2017-12-11 02:45:28 +0100
committerhref <href@random.sh>2017-12-11 02:45:28 +0100
commit9093b2cf4923274572729f46b688ab12f5a0bfdc (patch)
tree1ef3a7bfacc825fdc5ea47da6ceafd7b450aec91 /test/plugs/authentication_plug_test.exs
parentd1806ec07f44b617769bc862048df30b8a3336da (diff)
parentd5a13c10ac6a9a5f8dbb1932ffc85260f079a2dc (diff)
downloadpleroma-9093b2cf4923274572729f46b688ab12f5a0bfdc.tar.gz
pleroma-9093b2cf4923274572729f46b688ab12f5a0bfdc.zip
Merge remote-tracking branch 'upstream/develop' into media-proxy
Diffstat (limited to 'test/plugs/authentication_plug_test.exs')
-rw-r--r--test/plugs/authentication_plug_test.exs27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/plugs/authentication_plug_test.exs b/test/plugs/authentication_plug_test.exs
index 9d6c2cd70..5480dab43 100644
--- a/test/plugs/authentication_plug_test.exs
+++ b/test/plugs/authentication_plug_test.exs
@@ -14,6 +14,13 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
password_hash: Comeonin.Pbkdf2.hashpwsalt("guy")
}
+ @deactivated %User{
+ id: 1,
+ name: "dude",
+ password_hash: Comeonin.Pbkdf2.hashpwsalt("guy"),
+ info: %{"deactivated" => true}
+ }
+
@session_opts [
store: :cookie,
key: "_test",
@@ -131,6 +138,26 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
end
end
+ describe "with a correct authorization header for an deactiviated user" do
+ test "it halts the appication", %{conn: conn} do
+ opts = %{
+ optional: false,
+ fetcher: fn _ -> @deactivated end
+ }
+
+ header = basic_auth_enc("dude", "guy")
+
+ conn = conn
+ |> Plug.Session.call(Plug.Session.init(@session_opts))
+ |> fetch_session
+ |> put_req_header("authorization", header)
+ |> AuthenticationPlug.call(opts)
+
+ assert conn.status == 403
+ assert conn.halted == true
+ end
+ end
+
describe "with a user_id in the session for an existing user" do
test "it assigns the user", %{conn: conn} do
opts = %{