feat: the author edits a material in the app
- PUT /_bm/api/v1/materials/{id} (jwt.auth only, no token twin): every
key of the edit body required, revision checked on the row locked FOR
UPDATE, 409 with the student detail of the server version
- editableMaterialForCaller: 404 for what the caller cannot see, 403 for
what they see but may not manage
- tags from the dictionary only (at most 4), http(s) urls, the body
normalised as bm-notatka push does; course, author and publication kept
- loadMaterialDetail shared by GET /materials/{id} and the edit answers
This commit is contained in:
21
mcp_test.go
21
mcp_test.go
@@ -497,6 +497,14 @@ var studentRoutes = []string{
|
||||
"DELETE /checklist-items/{id}/done",
|
||||
}
|
||||
|
||||
// authorRoutes are the author's material routes under APIPrefix: JWT only,
|
||||
// with no token twin.
|
||||
var authorRoutes = []string{
|
||||
"GET /materials/{id}/access",
|
||||
"PUT /materials/{id}/access",
|
||||
"PUT /materials/{id}",
|
||||
}
|
||||
|
||||
// TestTokenMirrorRoutes is the invariant of the two student surfaces: every
|
||||
// student route exists under APIPrefix (jwt.auth, no user.* middleware) and
|
||||
// under TokenPrefix (user.api_token, the token bucket and the matching
|
||||
@@ -560,6 +568,19 @@ func TestTokenMirrorRoutes(t *testing.T) {
|
||||
t.Errorf("%s has a token twin", route)
|
||||
}
|
||||
}
|
||||
// The author's routes (D-07) are JWT-only, like the access panel.
|
||||
for _, route := range authorRoutes {
|
||||
method, pattern, _ := strings.Cut(route, " ")
|
||||
jwt, ok := byRoute[method+" "+bm.APIPrefix+pattern]
|
||||
if !ok {
|
||||
t.Errorf("%s %s is not registered", method, bm.APIPrefix+pattern)
|
||||
} else if !slices.Contains(jwt, "jwt.auth") {
|
||||
t.Errorf("%s %s lacks jwt.auth: %v", method, bm.APIPrefix+pattern, jwt)
|
||||
}
|
||||
if _, ok := byRoute[method+" "+bm.TokenPrefix+pattern]; ok {
|
||||
t.Errorf("%s %s has a token twin", method, bm.TokenPrefix+pattern)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dispatched returns r as pier dispatches it in-process: the api_token
|
||||
|
||||
Reference in New Issue
Block a user