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))))))
|
||||
|
||||
(deftest ssl-context-test
|
||||
(is (= {:expired "java.security.cert.CertificateExpiredException"
|
||||
: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"}
|
||||
(bb
|
||||
'(do
|
||||
(ns net
|
||||
(:import
|
||||
(java.net URI)
|
||||
(java.net.http HttpClient
|
||||
HttpRequest
|
||||
HttpResponse$BodyHandlers)))
|
||||
(let [result
|
||||
(bb
|
||||
'(do
|
||||
(ns net
|
||||
(:import
|
||||
(java.net URI)
|
||||
(java.net.http HttpClient
|
||||
HttpRequest
|
||||
HttpResponse$BodyHandlers)))
|
||||
|
||||
(defn send-and-catch [client req handler]
|
||||
(try
|
||||
(let [res (.send client req (HttpResponse$BodyHandlers/discarding))]
|
||||
(.statusCode res))
|
||||
(catch Throwable t
|
||||
(-> (Throwable->map t) :via last :type name))))
|
||||
(defn send-and-catch [client req handler]
|
||||
(try
|
||||
(let [res (.send client req (HttpResponse$BodyHandlers/discarding))]
|
||||
(.statusCode res))
|
||||
(catch Throwable t
|
||||
(-> (Throwable->map t) :via last :type name))))
|
||||
|
||||
(let [client (HttpClient/newHttpClient)
|
||||
handler (HttpResponse$BodyHandlers/discarding)
|
||||
reqs (->> [:expired
|
||||
:self-signed
|
||||
:revoked
|
||||
:untrusted-root
|
||||
:wrong-host]
|
||||
(map (fn [k]
|
||||
(let [req (-> (URI. (format "https://%s.badssl.com" (name k)))
|
||||
(HttpRequest/newBuilder)
|
||||
(.GET)
|
||||
(.build))]
|
||||
[k req])))
|
||||
(into {}))]
|
||||
(->> reqs
|
||||
(map (fn [[k req]]
|
||||
[k (send-and-catch client req handler)]))
|
||||
(into {})))))))
|
||||
(let [client (HttpClient/newHttpClient)
|
||||
handler (HttpResponse$BodyHandlers/discarding)
|
||||
reqs (->> [:expired
|
||||
:self-signed
|
||||
:revoked
|
||||
:untrusted-root
|
||||
:wrong-host]
|
||||
(map (fn [k]
|
||||
(let [req (-> (URI. (format "https://%s.badssl.com" (name k)))
|
||||
(HttpRequest/newBuilder)
|
||||
(.GET)
|
||||
(.build))]
|
||||
[k req])))
|
||||
(into {}))]
|
||||
(->> reqs
|
||||
(map (fn [[k req]]
|
||||
[k (send-and-catch client req handler)]))
|
||||
(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
|
||||
:self-signed 200
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
(ns babashka.namespace-test
|
||||
(:require [babashka.test-utils :as tu]
|
||||
[clojure.edn :as edn]
|
||||
[clojure.test :refer :all]))
|
||||
[clojure.test :refer [deftest is testing]]))
|
||||
|
||||
(defn bb [input & args]
|
||||
(edn/read-string
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
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")
|
||||
(is (empty? (bb nil "
|
||||
(let [excluded-namespaces #{'clojure.lang 'user}]
|
||||
(let [excluded-namespaces #{'user}]
|
||||
(for [nspace (remove #(excluded-namespaces (ns-name %)) (all-ns))
|
||||
[var-symbol ns-var] (ns-publics nspace)
|
||||
:let [ns-ns-name (ns-name nspace)
|
||||
|
|
|
|||
Loading…
Reference in a new issue