Skip to content

Commit

Permalink
Transfer asset routes to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
josh1248 committed Oct 13, 2024
1 parent 79c5a5d commit 9686184
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/cadet_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ defmodule CadetWeb.Router do
scope "/v2/courses/:course_id/admin", CadetWeb do
pipe_through([:api, :auth, :ensure_auth, :course, :ensure_admin])

get("/assets/:foldername", AdminAssetsController, :index)
post("/assets/:foldername/*filename", AdminAssetsController, :upload)
delete("/assets/:foldername/*filename", AdminAssetsController, :delete)

Expand Down Expand Up @@ -188,8 +189,6 @@ defmodule CadetWeb.Router do
:get_score_leaderboard
)

get("/assets/:foldername", AdminAssetsController, :index)

get("/grading", AdminGradingController, :index)
get("/grading/summary", AdminGradingController, :grading_summary)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ defmodule CadetWeb.AdminAssetsControllerTest do
end
end

describe "read-only permission for non-admin staff" do
describe "non-admin staff permission, forbidden" do
@tag authenticate: :staff
test "GET /assets/:foldername", %{conn: conn} do
course_id = conn.assigns.course_id
conn = get(conn, build_url(course_id, "testFolder"), %{})
assert response(conn, 200) =~ "OK"

assert response(conn, 403) =~ "Forbidden"
end

@tag authenticate: :staff
Expand Down

0 comments on commit 9686184

Please sign in to comment.