Skip to content

Commit

Permalink
Expand wrap-validation schema to allow string values for :request-method
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcompton committed Mar 27, 2024
1 parent eef3c66 commit 0487992
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Unreleased

* Loosen `wrap-validation` validation to support strings in :request-method. (See release in 0.6.2 for more information).

### 0.7.1

* Bump Manifold to 0.4.2 to fix Promesa print-method hierarchy bug
Expand Down Expand Up @@ -34,11 +38,14 @@ Contributions by Matthew Davidson and Stefan van den Oord.

* Fix backwards-compatibility for transport options
* Bump Netty to 4.1.89.Final, and io_uring to 0.0.18.Final
* Add `wrap-validation` middleware to validate Ring maps
* Bump deps and example deps
* Upgrade CircleCI instance size
* Switch to pedantic deps for CircleCI

### Breaking changes

* Add `wrap-validation` middleware to validate Ring maps [#679](https://github.com/clj-commons/aleph/pull/679). This adds a stricter interpretation of the ring spec, which may fail on previously valid input. For example, strings (e.g. `"GET"`) and keywords (e.g. `:get`) were both accepted values for `:request-method`, but now only keywords are accepted. This will be fixed in the release after 0.7.1.

Contributions by Arnaud Geiser, Ertuğrul Çetin, Jeroen van Dijk, David Ongaro,
Matthew Davidson, and Moritz Heidkamp.

Expand Down
2 changes: 1 addition & 1 deletion src/aleph/http/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(def uri [:maybe :string])
(def query-string [:maybe :string])
(def scheme [:enum :http :https])
(def request-method :keyword)
(def request-method [:or :string :keyword])
(def content-type [:maybe [:or :string :keyword]])
(def content-length [:maybe :int])
(def character-encoding [:maybe :string])
Expand Down
6 changes: 6 additions & 0 deletions test/aleph/http/client_middleware_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@
(doseq [req (mg/sample schema/ring-request)]
(is (middleware/wrap-validation req)))

(testing "Request methods can be strings"
(is (middleware/wrap-validation {:remote-addr "localhost"
:server-name "computer"
:scheme :http
:request-method "GET"})))

(is (thrown-with-msg?
IllegalArgumentException
#"Invalid spec.*:in \[:request-method\].*:type :malli.core/missing-key"
Expand Down

0 comments on commit 0487992

Please sign in to comment.