                         {:headers {"authorization"
                                    (format "Basic %s" (encode-basic-authorization-token "alice" "wonderland"))}})]
           (is (= 200 (:status response)))
-          (is (= ["Basic charset=\"UTF-8\", realm=\"WallyWorld\""]
+          (is (= "Basic charset=\"UTF-8\", realm=\"WallyWorld\""
                  (get-in response [:headers "www-authenticate"])))))
 
-      #_(testing "basic authentication challenge in response when no credentials"
+      (testing "basic authentication challenge in response when no credentials"
+        (let [response (yada/response-for resource)]
+          (is (= 401 (:status response)))
+          (is (= "Basic charset=\"UTF-8\", realm=\"WallyWorld\""
+                 (get-in response [:headers "www-authenticate"])))))
+
+      (testing "basic authentication challenge when wrong credentials"
+        (let [response (yada/response-for
+                        resource :get "/"
+                        {:headers {"authorization"
+                                   (format "BASIC %s" (encode-basic-authorization-token "alice" "pa$$w0rd"))}})]
+          (is (= 401 (:status response)))
+          (is (= "Basic charset=\"UTF-8\", realm=\"WallyWorld\""
+                 (get-in response [:headers "www-authenticate"])))))
+
+      (testing "401 challenge due to no authorization header on a protected resource"
+        (let [resource (assoc
+                        resource
+                        :authorize (fn [ctx creds] nil)
+                        )]
           (let [response (yada/response-for resource)]
-            (is (= 200 (:status response)))
-            (is (= ["Basic charset=\"UTF-8\", realm=\"WallyWorld\""]
-                   (get-in response [:headers "www-authenticate"])))))
-
-      #_(testing "no basic authentication challenge when satisfactory credentials"
-          (let [response (yada/response-for
-                          resource :get "/"
-                          {:headers {"authorization"
-                                     (format "BASIC %s" (encode-basic-authorization-token "alice" "wonderland"))}})]
-            (is (= 200 (:status response)))
-            (is (nil? (get-in response [:headers "www-authenticate"])))))
-
-      #_(testing "basic authentication challenge when wrong credentials"
-          (let [response (yada/response-for
-                          resource :get "/"
-                          {:headers {"authorization"
-                                     (format "BASIC %s" (encode-basic-authorization-token "alice" "pa$$w0rd"))}})]
-            (is (= 200 (:status response)))
-            (is (= ["Basic charset=\"UTF-8\", realm=\"WallyWorld\""]
-                   (get-in response [:headers "www-authenticate"])))))
-
-      #_(testing "401 challenge due to no authorization header on a protected resource"
-          (let [resource (assoc
-                          resource
-                          :authorize (fn [ctx creds] nil)
-                          )]
-            (let [response (yada/response-for resource)]
-              (is (= 401 (:status response)))
-              (is (= ["Basic charset=\"UTF-8\", realm=\"WallyWorld\""]
-                     (get-in response [:headers "www-authenticate"]))))))
-
-      #_(testing "401 challenge due to bad credentials"
+            (is (= 401 (:status response)))
+            (is (= "Basic charset=\"UTF-8\", realm=\"WallyWorld\""
+                   (get-in response [:headers "www-authenticate"]))))))
+
+      (testing "401 challenge due to bad credentials"
           (let [resource (assoc
                           resource
                           :authorize (fn [ctx creds] nil)

            [authenticator])))))))

;; Resource test

;; Integration test

#_(deftest basic-auth-test
  (let [resource
        {:methods {:get {:produces {:media-type "application/edn"}
                         :response (fn [ctx] "OK")}}}]

                            {:headers {"authorization"
                                       (format "BASIC %s" (encode-basic-authorization-token "alice" "pa$$w0rd"))}})]
              (is (= 401 (:status response)))
              (is (= "Basic charset=\"UTF-8\", realm=\"WallyWorld\""
                     (get-in response [:headers "www-authenticate"]))))))

      (testing "forbidden when good credentials"
          (let [resource (assoc
                          resource
                          :authorize (fn [ctx creds] nil)
