From b8f232722167be60ff6e68d86a9189291338a90b Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Thu, 20 Oct 2016 12:33:18 -0700 Subject: [PATCH] Correct structure of :headers for :options Was returning sequence of maps instead of just a map. Test needed updating to reflect that and also that Ring's default middleware adds headers. --- src/framework/one.clj | 12 ++++++------ test/basic/expectations/server.clj | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/framework/one.clj b/src/framework/one.clj index edb30c6..2b1af05 100644 --- a/src/framework/one.clj +++ b/src/framework/one.clj @@ -404,12 +404,12 @@ methods "OPTIONS,GET,POST,PUT,PATCH,DELETE"] ; should be dynamic, also include HEAD? {:status 200 :body "" - :headers [{"Content-Type" "text/plain; charset=utf-8"} - {"Access-Control-Allow-Origin" (:origin access-control)} - {"Access-Control-Allow-Methods" methods} - {"Access-Control-Allow-Headers" (:headers access-control)} - {"Access-Control-Allow-Credentials" (:credentials access-control)} - {"Access-Control-Max-Age" (str (:max-age access-control))}]})) + :headers {"Content-Type" "text/plain; charset=utf-8" + "Access-Control-Allow-Origin" (:origin access-control) + "Access-Control-Allow-Methods" methods + "Access-Control-Allow-Headers" (:headers access-control) + "Access-Control-Allow-Credentials" (:credentials access-control) + "Access-Control-Max-Age" (str (:max-age access-control))}})) (defn- default-middleware "The default Ring middleware we apply in FW/1. Returns a single diff --git a/test/basic/expectations/server.clj b/test/basic/expectations/server.clj index 85cd733..336f1b0 100644 --- a/test/basic/expectations/server.clj +++ b/test/basic/expectations/server.clj @@ -23,12 +23,12 @@ (defn- header-name? [name] (fn [header] - (str/starts-with? (ffirst header) name))) + (str/starts-with? (first header) name))) (expect (more-of {:keys [status headers body]} - 200 status - "" body - 6 (count headers) - 5 (count (filter (header-name? "Access-Control") headers)) - 4 (count (filter (header-name? "Access-Control-Allow") headers))) + 200 status + "" body + (partial <= 6) (count headers) + 5 (count (filter (header-name? "Access-Control") headers)) + 4 (count (filter (header-name? "Access-Control-Allow") headers))) (((fw1/configure-router {})) {:uri "/" :request-method :options}))