Skip to content

Commit

Permalink
Merge pull request #511 from solita/AE-2259-update-puumerkki
Browse files Browse the repository at this point in the history
AE-2259: Get puumerkki via Clojars and remove the old jar from reposi…
  • Loading branch information
solita-juhohaa authored Aug 19, 2024
2 parents e74c4c9 + 2aa8978 commit 7ea4b46
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
1 change: 0 additions & 1 deletion etp-core/etp-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
FROM --platform=amd64 clojure:temurin-17-tools-deps-alpine@sha256:b9cd40ebdbf0da1835b42835ca0b80b34857a7978b8f51fa8d87503870dc2bb9 as builder

# Preload dependencies for better caching
COPY ./lib /usr/src/etp-backend/lib
COPY deps.edn /usr/src/etp-backend/
WORKDIR /usr/src/etp-backend
RUN clojure -P -M:uberjar
Expand Down
2 changes: 1 addition & 1 deletion etp-core/etp-backend/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
org.apache.commons/commons-compress {:mvn/version "1.27.0"}

org.apache.pdfbox/pdfbox {:mvn/version "2.0.32"}
puumerkki/puumerkki {:local/root "lib/puumerkki-0.9.3-SNAPSHOT.jar"}
io.github.solita/puumerkki {:mvn/version "0.12.0"}
org.clojure/core.match {:mvn/version "1.1.0"}
com.cognitect.aws/api {:mvn/version "0.8.692"}
com.cognitect.aws/endpoints {:mvn/version "1.1.12.718"}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@
response (ts/handler (-> (mock/request :post url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json")))
;; Wait for the signing process to finish. Otherwise the test-system fails.
;; Wait for the signing process to finish. Otherwise, the test-system fails.
_ @signing-process]
(t/is (= (:status response) 409))
(t/is (= (:body response) (format "Energiatodistus %s is already in signing process" todistus-2018-future-id)))))
(t/testing "Trying to cancel the signing and then sign again should work"
(let [url (energiatodistus-sign-url todistus-2018-future-2-id 2018)
cancel-url (str "/api/private/energiatodistukset/" 2018 "/" todistus-2018-future-2-id "/signature/cancel")
response-cancel (atom nil)
;; Start a signing process in another thread.
signing-process (future
(with-bindings
Expand All @@ -152,19 +153,24 @@
(ts/handler (-> (mock/request :post url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json")))))
;; Wait naively so that the signing process starts in the other thread.
_ (Thread/sleep 100)
;; Cancel the signing
response-cancel (ts/handler (-> (mock/request :post cancel-url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json")))
;; Wait for the signing process to finish. Otherwise the test-system fails.
;; Try to cancel in a loop for two seconds
_ (let [time-before (time/now)
timeout-seconds (Duration/ofSeconds 2)]
(loop [elapsed-time-seconds (Duration/ofSeconds 0)]
(when (every? true? [(not= (:body @response-cancel) "Ok")
(> 0 (.compareTo elapsed-time-seconds timeout-seconds))])
(do
(reset! response-cancel (ts/handler (-> (mock/request :post cancel-url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json"))))
(recur (Duration/between (time/now) time-before))))))
;; Wait for the signing process to finish. Otherwise, the test-system fails.
_ @signing-process
response-sign (ts/handler (-> (mock/request :post url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json")))]
(t/is (= (:status response-cancel) 200))
(t/is (= (:body response-cancel) "Ok"))
(t/is (= (:status @response-cancel) 200))
(t/is (= (:body @response-cancel) "Ok"))
(t/is (= (:status response-sign) 200))
(t/is (= (:body response-sign) "Ok"))))))))

Expand All @@ -189,8 +195,8 @@
(t/is (= response-body {:signing-allowed true})))))
(t/testing "Signing is allowed 89 minutes after auth_time"
(with-bindings {#'config/system-signature-session-timeout-minutes config/system-signature-session-timeout-default-value
#'time/clock (Clock/fixed (.plus laatija-auth-time (Duration/ofMinutes 89))
(ZoneId/systemDefault))}
#'time/clock (Clock/fixed (.plus laatija-auth-time (Duration/ofMinutes 89))
(ZoneId/systemDefault))}
(let [response (ts/handler (-> (mock/request :get check-session-url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json")))
Expand All @@ -199,8 +205,8 @@
(t/is (= response-body {:signing-allowed true})))))
(t/testing "Signing is not allowed 1 min before auth_time"
(with-bindings {#'config/system-signature-session-timeout-minutes config/system-signature-session-timeout-default-value
#'time/clock (Clock/fixed (.minus laatija-auth-time (Duration/ofMinutes 1))
(ZoneId/systemDefault))}
#'time/clock (Clock/fixed (.minus laatija-auth-time (Duration/ofMinutes 1))
(ZoneId/systemDefault))}
(let [response (ts/handler (-> (mock/request :get check-session-url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json")))
Expand All @@ -209,8 +215,8 @@
(t/is (= response-body {:signing-allowed false})))))
(t/testing "Signing is not allowed 91 min after auth_time"
(with-bindings {#'config/system-signature-session-timeout-minutes config/system-signature-session-timeout-default-value
#'time/clock (Clock/fixed (.plus laatija-auth-time (Duration/ofMinutes 91))
(ZoneId/systemDefault))}
#'time/clock (Clock/fixed (.plus laatija-auth-time (Duration/ofMinutes 91))
(ZoneId/systemDefault))}
(let [response (ts/handler (-> (mock/request :get check-session-url)
(test-data.laatija/with-virtu-laatija)
(mock/header "Accept" "application/json")))
Expand Down

0 comments on commit 7ea4b46

Please sign in to comment.