feat: serve quizzes:import over HTTP behind the shared user API token

POST /api/v1/quizzes/import runs behind golem15.user's user.api_token with
the write scope and the golem15.quizzes.access_quizzes permission.
This commit is contained in:
Jakub Zych
2026-10-04 23:15:01 +02:00
parent a5be13c2be
commit 032f2da17f
5 changed files with 169 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ func TestRoutesRegistered(t *testing.T) {
"GET /_quizzes/api/v1/attempts/{id}",
"POST /_quizzes/api/v1/attempts/{id}/answers",
"POST /_quizzes/api/v1/attempts/{id}/finish",
"POST /api/v1/quizzes/import",
}
var got []string
for _, r := range router.Routes() {
@@ -71,6 +72,14 @@ func TestRoutesRegistered(t *testing.T) {
continue
}
got = append(got, r.Method+" "+r.Pattern)
if r.Pattern == "/api/v1/quizzes/import" {
for _, mw := range []string{"user.api_token", "user.scope:write", "user.permission:golem15.quizzes.access_quizzes"} {
if !slices.Contains(r.Middleware, mw) {
t.Errorf("%s %s is not behind %s: %v", r.Method, r.Pattern, mw, r.Middleware)
}
}
continue
}
if !slices.Contains(r.Middleware, "jwt.auth") {
t.Errorf("%s %s is not behind jwt.auth: %v", r.Method, r.Pattern, r.Middleware)
}