Skip to content

Commit

Permalink
AE-2284: Add anonymize-and-delete-expired internal api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
solita-juhohaa committed Sep 4, 2024
1 parent 93e56de commit 50a6cda
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
[solita.etp.schema.viesti :as viesti-schema]
[solita.etp.security :as security]
[solita.etp.service.energiatodistus :as energiatodistus-service]
[solita.etp.service.energiatodistus-destruction :as energiatodistus-destruction-service]
[solita.etp.service.energiatodistus-csv :as energiatodistus-csv-service]
[solita.etp.service.energiatodistus-pdf :as energiatodistus-pdf-service]
[solita.etp.service.energiatodistus-search :as energiatodistus-search-service]
[solita.etp.service.energiatodistus-xlsx :as energiatodistus-xlsx-service]
[solita.etp.service.kayttaja :as kayttaja-service]
[solita.etp.service.json :as json]
[solita.etp.service.rooli :as rooli-service]
[solita.etp.service.viesti :as viesti-service])
Expand Down Expand Up @@ -257,3 +259,15 @@
["/legacy"
["/2013" (xml-api/post 2013)]
["/2018" (xml-api/post 2018)]]]])

(def internal-routes
[["/energiatodistukset"
["/anonymize-and-delete-expired"
{:post {:summary "Anonymisoi vanhentuneet energiatodistukset ja poistaa niihin linkittyvät dokumentit."
:middleware [[security/wrap-db-application-name
(kayttaja-service/system-kayttaja :expiration)]
[security/wrap-whoami-for-internal-expiration-api]]
:responses {200 {:body nil}}
:handler (fn [{:keys [db aws-s3-client]}]
(r/response (energiatodistus-destruction-service/destroy-expired-energiatodistukset!
db aws-s3-client)))}}]]])
1 change: 1 addition & 0 deletions etp-core/etp-backend/src/main/clj/solita/etp/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
["/internal"
(concat (tag "Laskutus API" laskutus-api/routes)
(tag "Laatija Internal API" laatija-api/internal-routes)
(tag "Energiatodistus Internal API" energiatodistus-api/internal-routes)
(tag "Aineisto Internal API" aineisto-api/internal-routes))]]
(when config/allow-palveluvayla-api
["/palveluvayla" ["/openapi.json" {:get {:no-doc true :openapi {:info {:title "Energiatodistuspalvelu API" :description "Hae energiatodistuksia pdf tai json muodoissa"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
(->> (energiatodistus-destruction-db/select-expired-energiatodistus-ids db)
(map :id)))

(defn destroy-expired-energiatodistukset! [db aws-s3-client]
(log/info (str "Destruction of expired energiatodistukset initiated."))
(let [expired-todistukset (get-currently-expired-todistus-ids db)]
;; TODO:
nil))

(defn- hard-delete-energiatodistus!
"Hard deletes energiatodistus."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns solita.etp.api.energiatodistus-destruction-test
(:require
[clojure.test :as t]
[ring.mock.request :as mock]
[solita.etp.test-system :as ts]))

(t/use-fixtures :each ts/fixture)

(t/deftest can-call-energiatodistus-expiration-endpoint
(t/testing "Can call energiatodistus expiration endpoint"
(let [response (ts/handler (-> (mock/request :post "/api/internal/energiatodistukset/anonymize-and-delete-expired")
(mock/header "Accept" "application/json")))]
(t/is (= (:status response) 200)))))

0 comments on commit 50a6cda

Please sign in to comment.