Skip to content

Commit

Permalink
wip: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nlwstein committed Aug 28, 2023
1 parent 2f6e846 commit e205768
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion apps/api_web/lib/api_web/plugs/require_2factor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ defmodule ApiWeb.Plugs.Require2Factor do
Plug enforcing a user to have 2fa enabled
"""

# , only: [render: 3, put_view: 2]
import Phoenix.Controller

def init(opts), do: opts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ defmodule ApiWeb.Admin.Accounts.KeyControllerTest do

on_exit(fn -> ApiAccounts.Dynamo.delete_all_tables() end)

{:ok, user} = ApiAccounts.create_user(%{email: "test@mbta.com", role: "administrator"})
{:ok, user} =
ApiAccounts.create_user(%{email: "test@mbta.com", role: "administrator", totp_enabled: true})

{:ok, user} = ApiAccounts.generate_totp_secret(user)
ApiAccounts.enable_totp(user, NimbleTOTP.verification_code(user.totp_secret_bin))

conn =
conn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ defmodule ApiWeb.Admin.Accounts.UserControllerTest do

on_exit(fn -> ApiAccounts.Dynamo.delete_all_tables() end)

params = %{email: "admin@mbta.com", role: "administrator"}
{:ok, user} = ApiAccounts.create_user(params)
params = %{email: "admin@mbta.com", role: "administrator", totp_enabled: true}

{:ok, user} =
ApiAccounts.create_user(%{email: "test@mbta.com", role: "administrator", totp_enabled: true})

{:ok, user} = ApiAccounts.generate_totp_secret(user)
ApiAccounts.enable_totp(user, NimbleTOTP.verification_code(user.totp_secret_bin))

conn =
conn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ApiWeb.Admin.SessionControllerTest do
@authorized_user_attrs %{
email: "authorized@mbta.com",
role: "administrator",
totp_enabled: true,
password: @test_password
}
@unauthorized_user_attrs %{
Expand Down

0 comments on commit e205768

Please sign in to comment.