Fix tests

We do not need to mock and verify connections are closed as the new Pleroma.LDAP GenServer will handle managing the connection lifetime
This commit is contained in:
Mark Felder 2024-09-16 16:24:27 -04:00
parent 7c04098dde
commit 44b836c94c

View file

@ -28,11 +28,7 @@ test "authorizes the existing user using LDAP credentials" do
{:eldap, [], {:eldap, [],
[ [
open: fn [^host], [{:port, ^port}, {:ssl, false} | _] -> {:ok, self()} end, open: fn [^host], [{:port, ^port}, {:ssl, false} | _] -> {:ok, self()} end,
simple_bind: fn _connection, _dn, ^password -> :ok end, simple_bind: fn _connection, _dn, ^password -> :ok end
close: fn _connection ->
send(self(), :close_connection)
:ok
end
]} ]}
] do ] do
conn = conn =
@ -50,7 +46,6 @@ test "authorizes the existing user using LDAP credentials" do
token = Repo.get_by(Token, token: token) token = Repo.get_by(Token, token: token)
assert token.user_id == user.id assert token.user_id == user.id
assert_received :close_connection
end end
end end
@ -72,10 +67,6 @@ test "creates a new user after successful LDAP authorization" do
wholeSubtree: fn -> :ok end, wholeSubtree: fn -> :ok end,
search: fn _connection, _options -> search: fn _connection, _options ->
{:ok, {:eldap_search_result, [{:eldap_entry, ~c"", []}], []}} {:ok, {:eldap_search_result, [{:eldap_entry, ~c"", []}], []}}
end,
close: fn _connection ->
send(self(), :close_connection)
:ok
end end
]} ]}
] do ] do
@ -94,7 +85,6 @@ test "creates a new user after successful LDAP authorization" do
token = Repo.get_by(Token, token: token) |> Repo.preload(:user) token = Repo.get_by(Token, token: token) |> Repo.preload(:user)
assert token.user.nickname == user.nickname assert token.user.nickname == user.nickname
assert_received :close_connection
end end
end end
@ -111,11 +101,7 @@ test "disallow authorization for wrong LDAP credentials" do
{:eldap, [], {:eldap, [],
[ [
open: fn [^host], [{:port, ^port}, {:ssl, false} | _] -> {:ok, self()} end, open: fn [^host], [{:port, ^port}, {:ssl, false} | _] -> {:ok, self()} end,
simple_bind: fn _connection, _dn, ^password -> {:error, :invalidCredentials} end, simple_bind: fn _connection, _dn, ^password -> {:error, :invalidCredentials} end
close: fn _connection ->
send(self(), :close_connection)
:ok
end
]} ]}
] do ] do
conn = conn =
@ -129,7 +115,6 @@ test "disallow authorization for wrong LDAP credentials" do
}) })
assert %{"error" => "Invalid credentials"} = json_response(conn, 400) assert %{"error" => "Invalid credentials"} = json_response(conn, 400)
assert_received :close_connection
end end
end end
end end