mirror of
https://github.com/penpot/penpot.git
synced 2026-09-24 12:56:15 +00:00
* ✨ Enable closed schemas for RPC methods * 🐛 Fix duplicate make-dummy-request test helper definition The branch added a variadic DummyRequest/make-dummy-request pair but left the pre-existing single-arg definition in place. Because it was loaded last, zero-arg (make-dummy-request) calls added by prepare-rpc-params and rpc-nitrate-test threw ArityException, which broke 384 tests and caused 14 downstream assertion failures. Remove the stale duplicate so the variadic definition is the only one, and drop the now-unused yrq alias and duplicate yres alias. AI-assisted-by: deepseek-v4.1-flash * ✨ Add focused tests for make-dummy-request helper Pin the call contract of make-dummy-request, which the suite uses in three styles: no arguments, a single options map, and keyword arguments. The helper's redefinition shadowing in 8ca95adb98 was only caught by a full-suite run with hundreds of unrelated errors; these tests fail locally in a focused --focus run. Cover the zero-arg defaults, map and keyword overrides, the :body-bytes -> ByteArrayInputStream wrapping, :body-stream precedence, and cookie readback. Also clarify the docstring to list all supported call styles. AI-assisted-by: deepseek-v4.1-flash * 🚑 Prevent RPC client params from overriding auth context Strip qualified keys from decoded request params before merging them with the server-built auth context, so transit bodies can no longer override ::profile-id, ::auth-type or ::token-perms. Adds a regression test proving the override and the fix. AI-assisted-by: muse-spark-1.3-contributor * 📚 Merge backend subtleties memories under generic name Rename rpc-db-worker-subtleties to subtleties and fold in http-storage-filedata-subtleties, so the name no longer enumerates topics. Update all mem: references accordingly. AI-assisted-by: muse-spark-1.3-contributor * ✨ Add realistic tests for RPC auth override Cover the transit wire vector and the real wrapped :get-profile method with two database profiles, proving a session cannot read another profile by smuggling :app.rpc/profile-id in the body. AI-assisted-by: muse-spark-1.3-contributor * ✨ Add e2e test for RPC auth context override Parametrize rpcPost with contentType, accept and query so e2e can send hand-written transit bodies without new dependencies. The new test proves a transit-smuggled :app.rpc/profile-id no longer overrides the session in get-profile. Also fix the demo email assertion in auth-flow to the current uuid format. AI-assisted-by: muse-spark-1.3-contributor
75 lines
2.6 KiB
Clojure
75 lines
2.6 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
|
|
|
(ns backend-tests.rpc-binfile-test
|
|
(:require
|
|
[app.common.schema :as sm]
|
|
[app.common.uuid :as uuid]
|
|
[app.rpc :as-alias rpc]
|
|
[app.rpc.commands.binfile :as binfile]
|
|
[backend-tests.helpers :as th]
|
|
[clojure.test :as t]
|
|
[datoteka.fs :as fs]))
|
|
|
|
(t/use-fixtures :once th/state-init)
|
|
(t/use-fixtures :each th/database-reset)
|
|
|
|
(t/deftest import-binfile-schema-omits-file-id
|
|
;; N1-06: file-id parameter must be removed from schema for security
|
|
(let [schema @#'binfile/schema:import-binfile
|
|
validator (sm/lazy-validator schema)
|
|
|
|
valid-params
|
|
{:name "test"
|
|
:project-id (uuid/random)
|
|
:version 3
|
|
:upload-id (uuid/random)}
|
|
|
|
params-with-file-id
|
|
(assoc valid-params :file-id (uuid/random))]
|
|
|
|
(t/is (true? (validator valid-params))
|
|
"params without file-id should be valid")
|
|
|
|
(t/is (not (contains? (sm/keys (second schema)) :file-id))
|
|
"file-id should not be a declared parameter")
|
|
|
|
;; Params with file-id should fail (schema closed)
|
|
(t/is (false? (validator params-with-file-id))
|
|
"params with file-id should be rejected")))
|
|
|
|
(t/deftest import-binfile-schema-rejects-unsupported-version
|
|
;; T1-N2-03: version parameter should be restricted to supported values (1 or 3)
|
|
(let [schema @#'binfile/schema:import-binfile
|
|
validator (sm/lazy-validator schema)
|
|
base-params {:name "test"
|
|
:project-id (uuid/random)
|
|
:upload-id (uuid/random)}]
|
|
|
|
;; Version 1 should be accepted
|
|
(t/is (true? (validator (assoc base-params :version 1)))
|
|
"version 1 should be valid")
|
|
|
|
;; Version 3 should be accepted
|
|
(t/is (true? (validator (assoc base-params :version 3)))
|
|
"version 3 should be valid")
|
|
|
|
;; Version 2 should be rejected
|
|
(t/is (false? (validator (assoc base-params :version 2)))
|
|
"version 2 should be rejected")
|
|
|
|
;; Version 0 should be rejected
|
|
(t/is (false? (validator (assoc base-params :version 0)))
|
|
"version 0 should be rejected")
|
|
|
|
;; Negative version should be rejected
|
|
(t/is (false? (validator (assoc base-params :version -1)))
|
|
"negative version should be rejected")
|
|
|
|
;; Version 4 should be rejected
|
|
(t/is (false? (validator (assoc base-params :version 4)))
|
|
"version 4 should be rejected")))
|