                       (wrap-authorization backend)
                       (wrap-authentication backend))
           response (handler request)]
-      (is (= (:status response) 3000)))))
-
+      (is (= (:status response) 3000))))
+
+  (testing "Jws token with wrong token"
+    (let [request (assoc (make-request "xyz")
+                         :foo :bar)
+          backend (token/jws-backend {:secret jws-secret})
+          handler (-> identity
+                      (wrap-authorization backend)
+                      (wrap-authentication backend))
+          response (handler request)]
+      (is (nil? (:identity request)))
+      (is (= :bar (:foo request)))))
+)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Tests: JWE

          response (handler request)]
      (is (= (:status response) 3000))))

  (testing "Jwe token wrongdata - onerror handler called when provided"
    (let [request (make-jwe-request jws-data (hash/sha256 "foobar"))
          onerror (fn [_ _] {:status 3000})
          backend (token/jwe-backend {:secret jwe-secret

      (is (= (:status response) 403))
      (is (= (:body response) "Permission denied"))))

  (testing "Jws token unathorized with :unauthorized-handlercalled when provided"
    (let [request (make-jws-request jws-data "wrong-key")
          onerror (fn [_ _] {:status 3000})
          backend (token/jws-backend {:secret jws-secret
