From 50ce8cb96b2b218751c2fc2a6b19372f51846acc Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Mon, 14 Jul 2025 19:34:59 +0300 Subject: feat: rewrite in rust --- test/silmataivas_web/plugs/admin_only_test.exs | 49 -------------------------- 1 file changed, 49 deletions(-) delete mode 100644 test/silmataivas_web/plugs/admin_only_test.exs (limited to 'test/silmataivas_web/plugs/admin_only_test.exs') diff --git a/test/silmataivas_web/plugs/admin_only_test.exs b/test/silmataivas_web/plugs/admin_only_test.exs deleted file mode 100644 index cf939a2..0000000 --- a/test/silmataivas_web/plugs/admin_only_test.exs +++ /dev/null @@ -1,49 +0,0 @@ -defmodule SilmataivasWeb.AdminOnlyTest do - use SilmataivasWeb.ConnCase - - import Silmataivas.UsersFixtures - - alias SilmataivasWeb.Plugs.AdminOnly - - describe "admin_only plug" do - test "allows admin users to access protected routes", %{conn: conn} do - # Create an admin user - admin = user_fixture(%{role: "admin"}) - - # Set up the connection with the admin user - conn = - conn - |> assign(:current_user, admin) - |> AdminOnly.call(%{}) - - # Verify the connection is allowed to continue - refute conn.halted - end - - test "rejects non-admin users from accessing protected routes", %{conn: conn} do - # Create a regular user - regular_user = user_fixture(%{role: "user"}) - - # Set up the connection with the regular user - conn = - conn - |> assign(:current_user, regular_user) - |> AdminOnly.call(%{}) - - # Verify the connection is halted - assert conn.halted - assert conn.status == 403 - assert conn.resp_body == "Forbidden" - end - - test "rejects unauthenticated requests from accessing protected routes", %{conn: conn} do - # Set up the connection with no user - conn = AdminOnly.call(conn, %{}) - - # Verify the connection is halted - assert conn.halted - assert conn.status == 403 - assert conn.resp_body == "Forbidden" - end - end -end -- cgit v1.2.3