summaryrefslogtreecommitdiff
path: root/test/silmataivas_web/plugs/auth_test.exs
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-14 19:34:59 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-14 19:34:59 +0300
commit50ce8cb96b2b218751c2fc2a6b19372f51846acc (patch)
treee2c634d2ce856062d527667d47815a05a53361c8 /test/silmataivas_web/plugs/auth_test.exs
parent0ab2e5ba2b0631b28b5b1405559237b3913c878f (diff)
feat: rewrite in rust
Diffstat (limited to 'test/silmataivas_web/plugs/auth_test.exs')
-rw-r--r--test/silmataivas_web/plugs/auth_test.exs60
1 files changed, 0 insertions, 60 deletions
diff --git a/test/silmataivas_web/plugs/auth_test.exs b/test/silmataivas_web/plugs/auth_test.exs
deleted file mode 100644
index e6cf0e6..0000000
--- a/test/silmataivas_web/plugs/auth_test.exs
+++ /dev/null
@@ -1,60 +0,0 @@
-defmodule SilmataivasWeb.AuthTest do
- use SilmataivasWeb.ConnCase
-
- import Silmataivas.UsersFixtures
-
- alias SilmataivasWeb.Plugs.Auth
-
- describe "auth plug" do
- test "authenticates user with valid token", %{conn: conn} do
- # Create a user
- user = user_fixture()
-
- # Set up the connection with a valid token
- conn =
- conn
- |> put_req_header("authorization", "Bearer #{user.user_id}")
- |> Auth.call(%{})
-
- # Verify the user is authenticated
- assert conn.assigns.current_user.id == user.id
- refute conn.halted
- end
-
- test "rejects request with invalid token format", %{conn: conn} do
- # Set up the connection with an invalid token format
- conn =
- conn
- |> put_req_header("authorization", "Invalid #{Ecto.UUID.generate()}")
- |> Auth.call(%{})
-
- # Verify the connection is halted
- assert conn.halted
- assert conn.status == 401
- assert conn.resp_body == "Unauthorized"
- end
-
- test "rejects request with non-existent user token", %{conn: conn} do
- # Set up the connection with a non-existent user token
- conn =
- conn
- |> put_req_header("authorization", "Bearer #{Ecto.UUID.generate()}")
- |> Auth.call(%{})
-
- # Verify the connection is halted
- assert conn.halted
- assert conn.status == 401
- assert conn.resp_body == "Unauthorized"
- end
-
- test "rejects request without authorization header", %{conn: conn} do
- # Set up the connection without an authorization header
- conn = Auth.call(conn, %{})
-
- # Verify the connection is halted
- assert conn.halted
- assert conn.status == 401
- assert conn.resp_body == "Unauthorized"
- end
- end
-end