Tests: accept single user or list from read_sign_in_with_rauthy (get? true)
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
Handle {:ok, user}, {:ok, nil} in addition to {:ok, [user]}, {:ok, []}.
This commit is contained in:
parent
b215282609
commit
f59ed30d48
4 changed files with 80 additions and 8 deletions
|
|
@ -130,6 +130,10 @@ defmodule Mv.Accounts.UserAuthenticationTest do
|
|||
)
|
||||
|
||||
case result do
|
||||
{:ok, found_user} when is_struct(found_user) ->
|
||||
assert found_user.id == user.id
|
||||
assert found_user.oidc_id == "oidc_identifier_12345"
|
||||
|
||||
{:ok, [found_user]} ->
|
||||
assert found_user.id == user.id
|
||||
assert found_user.oidc_id == "oidc_identifier_12345"
|
||||
|
|
@ -137,6 +141,9 @@ defmodule Mv.Accounts.UserAuthenticationTest do
|
|||
{:ok, []} ->
|
||||
flunk("User should be found by oidc_id")
|
||||
|
||||
{:ok, nil} ->
|
||||
flunk("User should be found by oidc_id")
|
||||
|
||||
{:error, error} ->
|
||||
flunk("Unexpected error: #{inspect(error)}")
|
||||
end
|
||||
|
|
@ -231,11 +238,14 @@ defmodule Mv.Accounts.UserAuthenticationTest do
|
|||
actor: system_actor
|
||||
)
|
||||
|
||||
# Either returns empty list OR authentication error - both mean "user not found"
|
||||
# Either returns empty/nil OR authentication error - both mean "user not found"
|
||||
case result do
|
||||
{:ok, []} ->
|
||||
:ok
|
||||
|
||||
{:ok, nil} ->
|
||||
:ok
|
||||
|
||||
{:error, %Ash.Error.Forbidden{errors: [%AshAuthentication.Errors.AuthenticationFailed{}]}} ->
|
||||
:ok
|
||||
|
||||
|
|
@ -272,11 +282,14 @@ defmodule Mv.Accounts.UserAuthenticationTest do
|
|||
actor: system_actor
|
||||
)
|
||||
|
||||
# Either returns empty list OR authentication error - both mean "user not found"
|
||||
# Either returns empty/nil OR authentication error - both mean "user not found"
|
||||
case result do
|
||||
{:ok, []} ->
|
||||
:ok
|
||||
|
||||
{:ok, nil} ->
|
||||
:ok
|
||||
|
||||
{:error, %Ash.Error.Forbidden{errors: [%AshAuthentication.Errors.AuthenticationFailed{}]}} ->
|
||||
:ok
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue