Add persistent dark mode and server-assigned content IDs
This commit is contained in:
@@ -48,6 +48,10 @@ func (h *HTTP) catalogRoutes(mux *http.ServeMux) {
|
||||
fail(w, 400, "invalid catalog change")
|
||||
return
|
||||
}
|
||||
if change.HasDefinitionID() {
|
||||
fail(w, 400, "Content IDs are assigned by the server. Refresh the editor and omit the definition ID.")
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
|
||||
defer cancel()
|
||||
var result any
|
||||
|
||||
@@ -80,7 +80,12 @@ func TestControlAuthorizationAndExecution(t *testing.T) {
|
||||
if request("GET", "/api/control", "", token, "") != 200 {
|
||||
t.Fatal("admin denied")
|
||||
}
|
||||
previewBody := `{"id":"` + game.ID() + `","expectedVersion":1,"op":"create-effect-set","reason":"Preview effects","effectSet":{"id":"test_effect","name":"Test effect","description":"","modifiers":[{"stat":"strength","flat":2,"percent":0}]}}`
|
||||
previewBody := `{"id":"` + game.ID() + `","expectedVersion":1,"op":"create-effect-set","reason":"Preview effects","effectSet":{"name":"Test effect","description":"","modifiers":[{"stat":"strength","flat":2,"percent":0}]}}`
|
||||
for _, path := range []string{"/api/control/catalog", "/api/control/catalog/preview"} {
|
||||
if request("POST", path, strings.Replace(previewBody, `"effectSet":{`, `"effectSet":{"id":"client_chosen",`, 1), token, server.URL) != 400 {
|
||||
t.Fatal("client selected a permanent content ID")
|
||||
}
|
||||
}
|
||||
if request("POST", "/api/control/catalog/preview", previewBody, token, "https://evil.example") != 403 {
|
||||
t.Fatal("cross-origin preview")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user