diff options
author | Maksim Pechnikov <parallel588@gmail.com> | 2020-05-08 08:51:09 +0300 |
---|---|---|
committer | Maksim Pechnikov <parallel588@gmail.com> | 2020-05-08 08:51:09 +0300 |
commit | b078e0567dbecc768f88d991a2565141eb9e8c50 (patch) | |
tree | ed376fc3c17c6e508ac91d8e72cddad128c07c69 /test/plugs/ensure_authenticated_plug_test.exs | |
parent | bd261309cc27ebf5d2f78ea3c1474fe71ae8046d (diff) | |
parent | 769d95644daf07bf27fb483e91d0e793eaa18bd8 (diff) | |
download | pleroma-b078e0567dbecc768f88d991a2565141eb9e8c50.tar.gz pleroma-b078e0567dbecc768f88d991a2565141eb9e8c50.zip |
Merge branch 'develop' into issue/1276-2
Diffstat (limited to 'test/plugs/ensure_authenticated_plug_test.exs')
-rw-r--r-- | test/plugs/ensure_authenticated_plug_test.exs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/plugs/ensure_authenticated_plug_test.exs b/test/plugs/ensure_authenticated_plug_test.exs index 4e6142aab..a0667c5e0 100644 --- a/test/plugs/ensure_authenticated_plug_test.exs +++ b/test/plugs/ensure_authenticated_plug_test.exs @@ -24,6 +24,31 @@ defmodule Pleroma.Plugs.EnsureAuthenticatedPlugTest do end end + test "it halts if user is assigned and MFA enabled", %{conn: conn} do + conn = + conn + |> assign(:user, %User{multi_factor_authentication_settings: %{enabled: true}}) + |> assign(:auth_credentials, %{password: "xd-42"}) + |> EnsureAuthenticatedPlug.call(%{}) + + assert conn.status == 403 + assert conn.halted == true + + assert conn.resp_body == + "{\"error\":\"Two-factor authentication enabled, you must use a access token.\"}" + end + + test "it continues if user is assigned and MFA disabled", %{conn: conn} do + conn = + conn + |> assign(:user, %User{multi_factor_authentication_settings: %{enabled: false}}) + |> assign(:auth_credentials, %{password: "xd-42"}) + |> EnsureAuthenticatedPlug.call(%{}) + + refute conn.status == 403 + refute conn.halted + end + describe "with :if_func / :unless_func options" do setup do %{ |