Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ok 540 astu maksun virkailija käsittely #22

Merged
merged 21 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
36ee753
Poistettu tutu-spesifisyyttä, uusia geneerisiä rajapintoja, configura…
hajoa Sep 3, 2024
3e3cd4e
Haetaan maksut pelkän hakemuksen oidin perusteella
hajoa Sep 10, 2024
f057973
Lint fixes
hajoa Sep 10, 2024
c5b4d93
Korjattu protokollassa muuttunut funktion nimi myös serviceen
hajoa Sep 10, 2024
4333d6f
Päivitetty testejä, siivottu tutu spesifisyyttä myös maksamisen puolelta
hajoa Sep 11, 2024
2c73eb4
Lisätty maksun vahvistuksen lähetys astulle (toistaiseksi tutu pohjalla)
hajoa Sep 11, 2024
027051d
Uusi maksut-ui pathiin /maksut-ui, revertoitu cljs frontin poistoja
hajoa Sep 13, 2024
89dfd8b
Palautettu pm2 config ja makefile
hajoa Sep 13, 2024
4858c68
Korjattu makefile sisennys
hajoa Sep 13, 2024
2924e14
Palautettu aliakset project.clj
hajoa Sep 13, 2024
916cda8
Palautettu shadow-cljs.edn
hajoa Sep 13, 2024
c07f650
Palautettu cljs-time
hajoa Sep 13, 2024
0644e75
Testi konfiguraatioihin vanha path, poistettu playwrigth skipit
hajoa Sep 13, 2024
d3780f3
Korjattu testi callback url
hajoa Sep 13, 2024
86af852
Korjattu github testi konfiguraatiota
hajoa Sep 13, 2024
d7bc377
Poistettu kuitti emailin testitarkistuksesta ympäristöstä riippuva osa
hajoa Sep 16, 2024
6bd1f5a
Poistettu kuitti emailin testitarkistuksesta ympäristöstä riippuva osa
hajoa Sep 16, 2024
84d43ab
Lisää conffi korjauksia
hajoa Sep 16, 2024
2996759
Lisätty test-result gitignoreen
hajoa Sep 16, 2024
09cc3aa
Lisää conffi korjauksia
hajoa Sep 16, 2024
5012c1b
Korjattu cdk stackin certin domain
hajoa Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
/maksut.iws
/maksut.ipr
.clj-kondo/
.open-next
.open-next
/test-results/
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NODE_MODULES = node_modules
PM2 = PM2_HOME=.pm2 npx pm2
DOCKER_COMPOSE=COMPOSE_PARALLEL_LIMIT=8 $(if $(DOCKER_SUDO),sudo )docker-compose
DOCKER_COMPOSE=COMPOSE_PARALLEL_LIMIT=8 $(if $(DOCKER_SUDO),sudo )docker compose

$(NODE_MODULES): package.json package-lock.json
npm ci
Expand Down Expand Up @@ -29,9 +29,11 @@ kill-docker-test:
@$(DOCKER_COMPOSE) kill maksut-e2e-db-local

start: $(NODE_MODULES) start-docker
@$(PM2) start pm2.config.js --only maksut-frontend
@$(PM2) start pm2.config.js --only maksut-backend

start-local: $(NODE_MODULES) start-docker-local
@$(PM2) start pm2.config.js --only maksut-frontend
@$(PM2) start pm2.config.js --only maksut-backend

log: $(NODE_MODULES)
Expand All @@ -46,6 +48,7 @@ kill: $(NODE_MODULES) kill-docker
@$(PM2) kill

start-test: start-docker-test
@$(PM2) start pm2.config.js --only maksut-frontend
@$(PM2) start pm2.config.js --only maksut-backend-test

kill-test: kill-docker-test
Expand All @@ -57,4 +60,5 @@ restart-test: kill-test start-test

reload:
@$(PM2) kill
@$(PM2) start pm2.config.js --only maksut-frontend
@$(PM2) start pm2.config.js --only maksut-backend
6 changes: 3 additions & 3 deletions cdk/lib/sovellus-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ export class SovellusStack extends cdk.Stack {
this,
'SiteCertificate',
{
domainName: `maksut.${publicHostedZones[props.environmentName]}`,
domainName: `maksut-ui.${publicHostedZones[props.environmentName]}`,
hostedZone: zone,
region: 'us-east-1', // Cloudfront only checks this region for certificates.
},
);

const nextjs = new Nextjs(this, 'maksut-ui', {
nextjsPath: '../src/maksut-ui', // relative path from your project root to NextJS
basePath: '/maksut',
basePath: '/maksut-ui',
environment: {
STANDALONE: 'true',
MAKSUT_URL: `https://virkailija.${publicHostedZones[props.environmentName]}/maksut/api`,
},
domainProps: {
domainName: `maksut.${publicHostedZones[props.environmentName]}`,
domainName: `maksut-ui.${publicHostedZones[props.environmentName]}`,
certificate: certificate,
hostedZone: zone
},
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.7'
services:
maksut-nginx-local:
image: nginx
Expand Down
7 changes: 4 additions & 3 deletions oph-configuration/config.dev.edn
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
:merchant-id 375917
:merchant-secret "SAIPPUAKAUPPIAS"}
:callback-uri "https://maksut-local.test:9000/maksut/api/payment/paytrail"
:order-id-prefix "MKS"
:order-id-prefix {:tutu "TTU"
:astu "ASTU"}
:currency "EUR"}
:tutu {:lasku-origin "tutu"
:order-id-prefix "TTU"}
Expand All @@ -30,8 +31,8 @@
:email {:service-url-property :cas.service.ryhmasahkoposti-service
:session-cookie-name "JSESSIONID"}}}
:urls {:virkailija-baseurl "https://localhost"
:maksut-url "https://localhost:9000/maksut/"
:oppija-baseurl "http://localhost:3000/maksut"}
:maksut-url "https://localhost:9000/maksut"
:oppija-baseurl "http://localhost:3000/maksut-ui"}
:oph-organisaatio-oid "1.2.246.562.10.00000000001"
:public-config {:environment :development
:default-panel :panel/tutu-maksut
Expand Down
3 changes: 2 additions & 1 deletion oph-configuration/config.edn.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
:merchant-id {{ maksut_payment_paytrail_id | default('375917')}}
:merchant-secret "{{ maksut_payment_paytrail_secret | default('SAIPPUAKAUPPIAS')}}"}
:callback-uri "{{ maksut_payment_callback_uri }}"
:order-id-prefix "MKS"
:order-id-prefix {:tutu "TTU"
:astu "ASTU"}
:currency "EUR"}
:tutu {:lasku-origin "tutu"
:order-id-prefix "TTU"}
Expand Down
7 changes: 4 additions & 3 deletions oph-configuration/config.test.github.edn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
:merchant-id 12345
:merchant-secret "sikrot"}
:callback-uri "<ei käytetä mock paytrail käyttöliittymätestissä>"
:order-id-prefix "MKS"
:order-id-prefix {:tutu "TTU"
:astu "ASTU"}
:currency "EUR"}
:tutu {:lasku-origin "tutu"
:order-id-prefix "TTU"}
Expand All @@ -26,8 +27,8 @@
:email {:service-url-property :cas.service.ryhmasahkoposti-service
:session-cookie-name "JSESSIONID"}}}
:urls {:virkailija-baseurl "http://localhost"
:maksut-url "http://localhost:19033/maksut/"
:oppija-baseurl "https://testiopintopolku.fi/maksut"}
:maksut-url "http://localhost:19033/maksut"
:oppija-baseurl "http://localhost:19033/maksut"}
:oph-organisaatio-oid "1.2.246.562.10.00000000001"
:public-config {:environment :it
:default-panel :panel/tutu-maksut
Expand Down
9 changes: 5 additions & 4 deletions oph-configuration/config.test.local-environment.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
:database-name "maksut"
:host "localhost"
:port 15432}
:payment {:paytrail-config {:host "http://localhost:12345"
:payment {:paytrail-config {:host "http://localhost:9040/payments"
:merchant-id 12345
:merchant-secret "sikrot"}
:callback-uri "http://localhost:19033/maksut/payment/paytrail"
:order-id-prefix "MKS"
:order-id-prefix {:tutu "TTU"
:astu "ASTU"}
:currency "EUR"}
:tutu {:lasku-origin "tutu"
:order-id-prefix "TTU"}
Expand All @@ -26,8 +27,8 @@
:email {:service-url-property :cas.service.ryhmasahkoposti-service
:session-cookie-name "JSESSIONID"}}}
:urls {:virkailija-baseurl "http://localhost"
:maksut-url "http://localhost:19033/maksut/"
:oppija-baseurl "https://testiopintopolku.fi/maksut"}
:maksut-url "http://localhost:19033/maksut"
:oppija-baseurl "http://localhost:19033/maksut"}
:oph-organisaatio-oid "1.2.246.562.10.00000000001"
:public-config {:environment :it
:default-panel :panel/tutu-maksut
Expand Down
13 changes: 5 additions & 8 deletions playwright/tests/fullflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const expectPageAccessibilityOk = async (page: Page) => {
await expect(accessibilityScanResults.violations).toEqual([]);
};

const assertInvoiceMarkedPaid: (secret: string) => void = async (secret) => {
const assertInvoiceMarkedPaid = async (secret: string) => {
await expect(userPage).toHaveURL(`/maksut/?secret=${secret}&locale=fi`, {
timeout: 20000,
});
await expect(userPage.getByText("Maksettu", { exact: true })).toBeVisible();
};

const assertEmailsSent: (payerEmail: string) => void = async (payerEmail) => {
const assertEmailsSent = async (payerEmail: string) => {
await expect
.poll(async () => {
const emailResponse = await apiContext.get(
Expand Down Expand Up @@ -103,7 +103,6 @@ test.afterAll(async () => {
});

test("Accessibility", async () => {
test.skip();
// luodaan ataruna uusi lasku
const invoice = await createInvoice(apiContext);

Expand All @@ -115,7 +114,6 @@ test("Accessibility", async () => {
});

test.describe("Real Paytrail", () => {
test.skip();
test.skip(() => process.env.WITH_PAYTRAIL != "TRUE");

test("Paytrail maksuflow", async () => {
Expand All @@ -141,7 +139,6 @@ test.describe("Real Paytrail", () => {
});

test.describe("Mocked Paytrail", () => {
test.skip();
test.skip(() => process.env.WITH_PAYTRAIL == "TRUE");

test("Paytrail mocked maksuflow", async () => {
Expand All @@ -166,8 +163,8 @@ test.describe("Mocked Paytrail", () => {
linkin takaisin maksut-sovellukseen.
*/
const callbackUrl =
`/maksut/api/payment/paytrail/success?tutulocale=fi` +
`&tutusecret=${invoice.secret}` +
`/maksut/api/payment/paytrail/success?locale=fi` +
`&secret=${invoice.secret}` +
`&checkout-account=${checkoutData["checkout-account"]}` +
`&checkout-algorithm=${checkoutData["checkout-algorithm"]}` +
`&checkout-amount=${checkoutData["checkout-amount"]}` +
Expand All @@ -187,7 +184,7 @@ test.describe("Mocked Paytrail", () => {
},
},
);
await expect(newStub.ok()).toBeTruthy();
expect(newStub.ok()).toBeTruthy();

// mennään käyttäjänä maksusivulle
await userPage.goto(`/maksut/?secret=${invoice.secret}&locale=fi`);
Expand Down
17 changes: 17 additions & 0 deletions pm2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ const config =

module.exports = {
apps: [
{
name: 'maksut-frontend',
script: 'lein',
interpreter: '/bin/sh',
args: ['frontend:dev'],
cwd: __dirname,
log_file: 'logs/maksut-frontend.log',
pid_file: 'pids/maksut-frontend.pid',
combine_logs: true,
min_uptime: 30000,
max_restarts: 5,
restart_delay: 4000,
wait_ready: true,
watch: false,
exec_interpreter: 'none',
exec_mode: 'fork',
},
{
name: 'maksut-backend',
script: 'lein',
Expand Down
34 changes: 28 additions & 6 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
(defproject maksut "0.1.0-SNAPSHOT"
;TODO Tässä on todennäköisesti paljon kopioitua depsejä mitä ei tarvita, käy läpi myöhemmin mitkä voi jättää pois
:dependencies [[org.clojure/clojure "1.11.1"]
[org.clojure/clojurescript "1.11.132"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[camel-snake-kebab "0.4.3"]
[cheshire "5.12.0"]
[clj-http "3.12.3"]
[clj-time "0.15.2"]
[com.amazonaws/aws-java-sdk-s3 "1.12.663"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[com.taoensso/timbre "6.3.1"]
[com.fzakaria/slf4j-timbre "0.4.1"]
[timbre-ns-pattern-level "0.1.2"]
Expand All @@ -31,6 +36,8 @@
[org.clojure/core.match "1.1.0"]
[org.postgresql/postgresql "42.7.2"]
[com.layerware/hugsql "0.5.3"]
[re-frame "1.4.3"]
[reagent "1.2.0"]
[markdown-clj "1.11.9"]
[com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer "20220608.1" :exclusions [com.google.guava/guava]]
[com.fasterxml.jackson.core/jackson-core "2.15.2"]
Expand All @@ -39,8 +46,11 @@
[ring/ring-json "0.5.1"]
[ring/ring-session-timeout "0.3.0"]
[selmer "1.12.59"]
[stylefy "3.2.0"
:exclusions [[org.clojure/core.async]]]
[stylefy/reagent "3.0.0"]
[prismatic/schema "1.4.1"]
[thheller/shadow-cljs "2.27.4"]
[yogthos/config "1.2.0"]
[environ "1.2.0"]
[com.sun.mail/jakarta.mail "2.0.1"]
Expand All @@ -53,11 +63,13 @@

:main maksut.core

:source-paths ["src/clj" "src/cljc"]
:source-paths ["src/clj" "src/cljs" "src/cljc"]
:test-paths ["test/clj"]

:clean-targets ^{:protect false} ["target"]

:clean-targets ^{:protect false} ["resources/public/maksut/js/compiled"
"target"
".shadow-cljs"
".ts-out"]

:shell {:commands {"open" {:windows ["cmd" "/c" "start"]
:macosx "open"
Expand All @@ -66,8 +78,12 @@
:jvm-opts ["-Dclojure.main.report=stderr"]

:aliases {"server:dev" ["with-profile" "dev" "run"]
"frontend:dev" ["with-profile" "dev" "do"
["run" "-m" "shadow.cljs.devtools.cli" "watch" "maksut"]]
"frontend:prod" ["with-profile" "prod" "do"
["run" "-m" "shadow.cljs.devtools.cli" "release" "maksut"]]
"build-report" ["with-profile" "prod" "do"
["maksut" "target/build-report.html"]
["run" "-m" "shadow.cljs.devtools.cli" "run" "shadow.cljs.build-report" "maksut" "target/build-report.html"]
["shell" "open" "target/build-report.html"]]
"lint" ["with-profile" "dev" "do"
["run" "-m" "clj-kondo.main" "--config" "oph-configuration/clj-kondo.config.edn" "--lint" "src"]]}
Expand All @@ -78,14 +94,20 @@
{:dev
{:dependencies [[binaryage/devtools "1.0.7"]
[clj-kondo "2024.02.12"]
[day8.re-frame/re-frame-10x "1.9.8"]
[day8.re-frame/tracing "0.6.2"]
[reloaded.repl "0.2.4"]
[clj-http-fake "1.0.4"]]
:source-paths ["dev/clj"]}
:source-paths ["dev/clj" "dev/cljs"]}

:prod {:dependencies [[day8.re-frame/tracing-stubs "0.6.2"]]}

:uberjar {:source-paths ["env/prod/clj"]
:dependencies [[day8.re-frame/tracing-stubs "0.6.2"]]
:omit-source false
:aot [maksut.core]
:uberjar-name "maksut.jar"}}
:uberjar-name "maksut.jar"
:prep-tasks ["compile" ["frontend:prod"]]}}

:repositories [["releases" {:url "https://artifactory.opintopolku.fi/artifactory/oph-sade-release-local"
:sign-releases false
Expand Down
2 changes: 2 additions & 0 deletions resources/maksut-oph.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ ryhmasahkoposti-service.email = ${virkailija.baseurl}/ryhmasahkoposti-service/em
cas.service.kayttooikeus-service=${virkailija.baseurl}/kayttooikeus-service/j_spring_cas_security_check
kayttooikeus-service.kayttooikeus.kayttaja = ${virkailija.baseurl}/kayttooikeus-service/kayttooikeus/kayttaja

front.lokalisointi-service.baseurl=${virkailija.baseurl}

lokalisointi-service.get-lokalisations=${virkailija.baseurl}/lokalisointi/cxf/rest/v1/localisation?category=maksut&locale=$1
25 changes: 25 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{:lein true

:nrepl {:port 9034 :host "0.0.0.0"}

:builds {:maksut {:target :browser
:output-dir "resources/public/maksut/js/compiled"
:asset-path "/maksut/js/compiled"
:modules {:maksut
{ :init-fn maksut.core/init
:preloads [devtools.preload
;day8.re-frame-10x.preload
]}}
:dev {:compiler-options
{:closure-defines
{ re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}
:external-config
{:devtools/config
{ :features-to-install [:hints :async]
:fn-symbol "F"
:dont-detect-custom-formatters true}}}}
:devtools { :http-root "resources/public"
:http-port 9035}}}

:fs-watch {:watcher :polling}}
2 changes: 1 addition & 1 deletion src/clj/maksut/audit_logger.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[schema.core :as s])
(:import [fi.vm.sade.auditlog ApplicationType Audit]))

(defn- ^Audit create-audit-log [base-path]
(defn- create-audit-log ^Audit [base-path]
(cta-audit-log/create-audit-logger "maksut" base-path ApplicationType/OPPIJA))

(defrecord AuditLogger [config]
Expand Down
6 changes: 3 additions & 3 deletions src/clj/maksut/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
:merchant-id s/Int
:merchant-secret s/Str}
:callback-uri s/Str
:order-id-prefix s/Str
:currency s/Str
}
:order-id-prefix {:tutu s/Str
:astu s/Str}
:currency s/Str}
:tutu {:lasku-origin s/Str
:order-id-prefix s/Str}
:file-store {:engine s/Keyword
Expand Down
1 change: 1 addition & 0 deletions src/clj/maksut/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
:operationsSorter "alpha"}
:path "/maksut/swagger"
:url "/maksut/swagger.json"})
(ring/create-resource-handler {:path "/maksut" :root "public/maksut"})
(ring/create-default-handler {:not-found (constantly {:status 404, :body "<h1>Not found</h1>"})}))))

(def reloader #'reload/reloader)
Expand Down
Loading
Loading