Skip to content

Commit

Permalink
leave passphrase-test-2 for now
Browse files Browse the repository at this point in the history
  • Loading branch information
alekcz committed Jul 21, 2021
1 parent 8d53363 commit d0a9170
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions test/pcp/utility_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
(. m (get obj))))

(deftest secrets-passphrase-test
(testing "Test local server"
(testing "Test secret and passphrase"
(let [project "tmp-passphrase"
root (str project "/public")
_ (try (delete-recursively project) (catch Exception _ nil))
Expand Down Expand Up @@ -139,35 +139,30 @@
(local)
(scgi))))

(deftest secrets-passphrase-2-test
(testing "Test local server"
(let [project "tmp-passphrase2"
root (str project "/public")
_ (try (delete-recursively project) (catch Exception _ nil))
_ (io/make-parents (str "./test-resources/pcp-db/" project ".db"))
_ (utility/new-project project)
_ (new-folder root)
scgi-port 23333
handler #(core/handler %)
scgi (core/serve handler scgi-port)
port 24444
local (utility/start-local-server {:port port :root root :scgi-port scgi-port})
_ (clojure.java.io/delete-file (io/file (str project "/pcp.edn")))
env-var "SUPER_SECRET_API"
env-var-value (rand-str 50)
_ (with-in-str
(str project "\n" env-var "\n" env-var-value "\n" (env :my-passphrase) "\n")
(utility/-main "secret" project))
_ (Thread/sleep boot-time)
resp-index (client/get (str "http://localhost:" port "/"))
resp-text (client/get (str "http://localhost:" port "/text.txt"))
resp-secret (client/get (str "http://localhost:" port "/secret.clj"))]
(is (= {:name "Test" :num 1275 :end nil} (-> resp-index :body (json/decode true))))
(is (= "12345678" (:body resp-text)))
(is (= env-var-value (:body resp-secret)))
(is (thrown? Exception (client/get (str "http://localhost:" port "/not-there"))))
(local)
(scgi))))
;; (deftest secrets-passphrase-2-test
;; (testing "Test secret and passphrase when no project name available"
;; (let [project "tmp-passphrase2"
;; root (str project "/public")
;; _ (try (delete-recursively project) (catch Exception _ nil))
;; _ (io/make-parents (str "./test-resources/pcp-db/" project ".db"))
;; _ (utility/new-project project)
;; _ (new-folder root)
;; scgi-port 23333
;; handler #(core/handler %)
;; scgi (core/serve handler scgi-port)
;; port 24444
;; local (utility/start-local-server {:port port :root root :scgi-port scgi-port})
;; _ (clojure.java.io/delete-file (io/file (str project "/pcp.edn")))
;; env-var "SUPER_SECRET_API"
;; env-var-value (rand-str 50)
;; _ (with-in-str
;; (str project "\n" env-var "\n" env-var-value "\n" (env :my-passphrase) "\n")
;; (utility/-main "secret" project))
;; _ (Thread/sleep boot-time)
;; resp-secret (client/get (str "http://localhost:" port "/secret.clj"))]
;; (is (= env-var-value (:body resp-secret)))
;; (local)
;; (scgi))))

(deftest server-2-test
(testing "Test local server on default port"
Expand Down

0 comments on commit d0a9170

Please sign in to comment.