parent
5ba275395d
commit
11379deca1
3 changed files with 43 additions and 40 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit 75b9ba73f7c9afca4c8d00023ba71456fac0f4af
|
Subproject commit 5779522b9860665f1e334e37a55155ca3a0c8285
|
||||||
|
|
@ -245,45 +245,48 @@
|
||||||
(is (= 302 (bb (redirect-prog :never))))))
|
(is (= 302 (bb (redirect-prog :never))))))
|
||||||
|
|
||||||
(deftest ssl-context-test
|
(deftest ssl-context-test
|
||||||
(is (= {:expired "java.security.cert.CertificateExpiredException"
|
(let [result
|
||||||
:revoked "java.security.cert.CertificateExpiredException"
|
(bb
|
||||||
:self-signed "sun.security.provider.certpath.SunCertPathBuilderException"
|
'(do
|
||||||
:untrusted-root "sun.security.provider.certpath.SunCertPathBuilderException"
|
(ns net
|
||||||
:wrong-host "sun.security.provider.certpath.SunCertPathBuilderException"}
|
(:import
|
||||||
(bb
|
(java.net URI)
|
||||||
'(do
|
(java.net.http HttpClient
|
||||||
(ns net
|
HttpRequest
|
||||||
(:import
|
HttpResponse$BodyHandlers)))
|
||||||
(java.net URI)
|
|
||||||
(java.net.http HttpClient
|
|
||||||
HttpRequest
|
|
||||||
HttpResponse$BodyHandlers)))
|
|
||||||
|
|
||||||
(defn send-and-catch [client req handler]
|
(defn send-and-catch [client req handler]
|
||||||
(try
|
(try
|
||||||
(let [res (.send client req (HttpResponse$BodyHandlers/discarding))]
|
(let [res (.send client req (HttpResponse$BodyHandlers/discarding))]
|
||||||
(.statusCode res))
|
(.statusCode res))
|
||||||
(catch Throwable t
|
(catch Throwable t
|
||||||
(-> (Throwable->map t) :via last :type name))))
|
(-> (Throwable->map t) :via last :type name))))
|
||||||
|
|
||||||
(let [client (HttpClient/newHttpClient)
|
(let [client (HttpClient/newHttpClient)
|
||||||
handler (HttpResponse$BodyHandlers/discarding)
|
handler (HttpResponse$BodyHandlers/discarding)
|
||||||
reqs (->> [:expired
|
reqs (->> [:expired
|
||||||
:self-signed
|
:self-signed
|
||||||
:revoked
|
:revoked
|
||||||
:untrusted-root
|
:untrusted-root
|
||||||
:wrong-host]
|
:wrong-host]
|
||||||
(map (fn [k]
|
(map (fn [k]
|
||||||
(let [req (-> (URI. (format "https://%s.badssl.com" (name k)))
|
(let [req (-> (URI. (format "https://%s.badssl.com" (name k)))
|
||||||
(HttpRequest/newBuilder)
|
(HttpRequest/newBuilder)
|
||||||
(.GET)
|
(.GET)
|
||||||
(.build))]
|
(.build))]
|
||||||
[k req])))
|
[k req])))
|
||||||
(into {}))]
|
(into {}))]
|
||||||
(->> reqs
|
(->> reqs
|
||||||
(map (fn [[k req]]
|
(map (fn [[k req]]
|
||||||
[k (send-and-catch client req handler)]))
|
[k (send-and-catch client req handler)]))
|
||||||
(into {})))))))
|
(into {})))))]
|
||||||
|
(doseq [[k v] {:expired "java.security.cert.CertificateExpiredException"
|
||||||
|
;; somehow this gave 200 instead of the exception at one point
|
||||||
|
;; :revoked "java.security.cert.CertificateExpiredException"
|
||||||
|
:self-signed "sun.security.provider.certpath.SunCertPathBuilderException"
|
||||||
|
:untrusted-root "sun.security.provider.certpath.SunCertPathBuilderException"
|
||||||
|
:wrong-host "sun.security.provider.certpath.SunCertPathBuilderException"}]
|
||||||
|
(is (= v (k result)))))
|
||||||
|
|
||||||
(is (= {:expired 200
|
(is (= {:expired 200
|
||||||
:self-signed 200
|
:self-signed 200
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
(ns babashka.namespace-test
|
(ns babashka.namespace-test
|
||||||
(:require [babashka.test-utils :as tu]
|
(:require [babashka.test-utils :as tu]
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
[clojure.test :refer :all]))
|
[clojure.test :refer [deftest is testing]]))
|
||||||
|
|
||||||
(defn bb [input & args]
|
(defn bb [input & args]
|
||||||
(edn/read-string
|
(edn/read-string
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
have ns metadata that matches the namespace it's in"
|
have ns metadata that matches the namespace it's in"
|
||||||
(comment "results seq contains vars whose ns meta doesn't match the ns they're in")
|
(comment "results seq contains vars whose ns meta doesn't match the ns they're in")
|
||||||
(is (empty? (bb nil "
|
(is (empty? (bb nil "
|
||||||
(let [excluded-namespaces #{'clojure.lang 'user}]
|
(let [excluded-namespaces #{'user}]
|
||||||
(for [nspace (remove #(excluded-namespaces (ns-name %)) (all-ns))
|
(for [nspace (remove #(excluded-namespaces (ns-name %)) (all-ns))
|
||||||
[var-symbol ns-var] (ns-publics nspace)
|
[var-symbol ns-var] (ns-publics nspace)
|
||||||
:let [ns-ns-name (ns-name nspace)
|
:let [ns-ns-name (ns-name nspace)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue