Added classes: - java.net.CookiePolicy - java.net.http.HttpTimeoutException - javax.net.ssl.HostnameVerifier - javax.net.ssl.HttpsURLConnection - javax.net.ssl.KeyManagerFactory - javax.net.ssl.SSLSession - javax.net.ssl.TrustManagerFactory - java.security.KeyStore - java.util.zip.Inflater - java.util.zip.ZipException
34 lines
1.5 KiB
Clojure
34 lines
1.5 KiB
Clojure
(ns clj-http.lite.client-test
|
|
(:require [cheshire.core :as json]
|
|
[clj-http.lite.client :as client]
|
|
[clojure.test :as t :refer [deftest is]]))
|
|
|
|
(deftest client-test
|
|
(is (= 200 (:status (client/get "https://www.clojure.org" {:throw-exceptions false}))))
|
|
|
|
(is (= 200 (:status (client/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2" {:throw-exceptions false}))))
|
|
|
|
(is (= 200 (:status (client/post "https://postman-echo.com/post" {:throw-exceptions false}))))
|
|
|
|
(is (= 200 (:status (client/post "https://postman-echo.com/post"
|
|
{:body (json/generate-string {:a 1})
|
|
:headers {"X-Hasura-Role" "admin"}
|
|
:content-type :json
|
|
:accept :json
|
|
:throw-exceptions false}))))
|
|
|
|
(is (= 200 (:status (client/put "https://postman-echo.com/put"
|
|
{:body (json/generate-string {:a 1})
|
|
:headers {"X-Hasura-Role" "admin"}
|
|
:content-type :json
|
|
:accept :json
|
|
:throw-exceptions false})))))
|
|
|
|
(deftest insecure-test
|
|
(is (= 200 (:status (client/get "https://self-signed.badssl.com/" {:insecure? true})))))
|
|
|
|
(deftest exception-test
|
|
(try (client/get "https://site.com/broken")
|
|
(is false "should not reach here")
|
|
(catch Exception e
|
|
(is (:headers (ex-data e))))))
|