Skip to content

Commit 1fd6d6e

Browse files
authored
Merge pull request #348 from nl-portal/feature/117302-openklant-2.0
Feature/117302 openklant 2.0
2 parents 258172a + 3ed2e4d commit 1fd6d6e

File tree

73 files changed

+4698
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4698
-29
lines changed

app/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626
implementation(project(":form"))
2727
implementation(project(":zgw:berichten"))
2828
implementation(project(":zgw:taak"))
29+
implementation(project(":zgw:openklant"))
2930
implementation(project(":zgw:zaken-api"))
3031
implementation(project(":zgw:catalogi-api"))
3132
implementation(project(":zgw:documenten-api"))

app/src/main/resources/config/application.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ spring:
3838
jpa:
3939
database-platform: org.hibernate.dialect.PostgreSQLDialect
4040
database: postgresql
41-
show_sql: true
41+
show_sql: false
4242
open-in-view: false
4343
properties:
4444
hibernate:
@@ -69,9 +69,15 @@ graphql:
6969

7070
logging:
7171
level:
72-
org.springframework.amqp: DEBUG
72+
root: INFO
7373

7474
nl-portal:
75+
config:
76+
openklant:
77+
enabled: true
78+
properties:
79+
klantinteracties-api-url: http://localhost:8007/klantinteracties/api/v1
80+
token: ac045222c9e7cde8120b48735560f9b920bb58cd
7581
zgw:
7682
besluiten:
7783
url: http://localhost:8001
@@ -185,4 +191,4 @@ nl-portal:
185191
shaInKey: de14f0e3-2ff0-45eb-95a6-1cdc35ca7a00
186192
shaOutKey: de14f0e3-2ff0-45eb-95a6-1cdc35ca7a00
187193
failureUrl: http://localhost:3000
188-
successUrl: http://localhost:3000
194+
successUrl: http://localhost:3000

build.gradle.kts

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
2+
import io.spring.gradle.dependencymanagement.org.codehaus.plexus.interpolation.os.Os.FAMILY_MAC
3+
import org.apache.tools.ant.taskdefs.condition.Os
24
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
35
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
46
import java.net.URI
@@ -122,6 +124,10 @@ subprojects {
122124
freeCompilerArgs.add("-Xjsr305=strict")
123125
freeCompilerArgs.add("-Xemit-jvm-type-annotations")
124126
}
127+
val ktlintFormat: Task? by tasks
128+
if (ktlintFormat != null) {
129+
dependsOn(ktlintFormat)
130+
}
125131
}
126132

127133
println("Enabling Spring Boot Dependency Management in project ${project.name}...")
@@ -134,10 +140,6 @@ subprojects {
134140
}
135141
}
136142

137-
tasks.withType<Test> {
138-
useJUnitPlatform()
139-
}
140-
141143
publishing {
142144
repositories {
143145
maven {
@@ -208,6 +210,16 @@ subprojects {
208210
sign(publishing.publications["default"])
209211
}
210212
}
213+
214+
apply(from = "${rootProject.projectDir}/gradle/testing.gradle.kts")
215+
216+
if (Os.isFamily(FAMILY_MAC)) {
217+
println("Configure docker compose for macOs")
218+
dockerCompose {
219+
executable = "/usr/local/bin/docker-compose"
220+
dockerExecutable = "/usr/local/bin/docker"
221+
}
222+
}
211223
}
212224

213225
tasks.register<HtmlDependencyReportTask>("htmlDependencyReport")

case/build.gradle.kts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import io.spring.gradle.dependencymanagement.org.codehaus.plexus.interpolation.os.Os.FAMILY_MAC
2-
import org.apache.tools.ant.taskdefs.condition.Os
3-
41
/*
52
* Copyright 2015-2023 Ritense BV, the Netherlands.
63
*
@@ -21,12 +18,8 @@ plugins {
2118
}
2219

2320
dockerCompose {
24-
if (Os.isFamily(FAMILY_MAC)) {
25-
executable = "/usr/local/bin/docker-compose"
26-
dockerExecutable = "/usr/local/bin/docker"
27-
}
28-
projectNamePrefix = "case"
29-
isRequiredBy(tasks.getByName("test"))
21+
setProjectName("$name-test")
22+
isRequiredBy(tasks.getByName("integrationTest"))
3023
useComposeFiles.addAll("../docker-resources/docker-compose-base-test.yml", "docker-compose-override.yml")
3124
}
3225

docker-resources/docker-compose-base-test.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
version: '3.9'
21
services:
32
db:
4-
image: "postgres"
3+
image: postgres:15
54
environment:
65
- POSTGRES_USER=postgres
76
- POSTGRES_PASSWORD=test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
echo ">>>> Starting Open Klant data import script <<<<"
4+
5+
sh /docker-entrypoint-initdb.d/sql/fill-data-on-startup.sh &
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSERT INTO public.token_tokenauth (id, token, contact_person, email, organization, last_modified, created, application, administration) VALUES (1, 'ac045222c9e7cde8120b48735560f9b920bb58cd', 'Admin', '[email protected]', '', '2024-09-06 07:26:53.703312 +00:00', '2024-09-06 07:26:53.703384 +00:00', '', '');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
echo ">>>> Waiting until Open Klant has initialized the database <<<<"
4+
while true
5+
do
6+
initiated=$(psql -U openklant -d openklant -t -A -c "SELECT EXISTS (SELECT table_name FROM information_schema.tables WHERE table_name = 'accounts_user');")
7+
if [ "t" = "${initiated}" ]
8+
then
9+
echo "Running database setup scripts"
10+
for file in /docker-entrypoint-initdb.d/sql/*.sql
11+
do
12+
echo "Running $file"
13+
psql -U openklant -d openklant -f $file
14+
done
15+
break
16+
else
17+
echo "Open Klanten is not initiated yet"
18+
sleep 5
19+
fi
20+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Apply database migrations
4+
>&2 echo "Apply database migrations"
5+
python src/manage.py migrate
6+
7+
exists=$(echo "from django.contrib.auth import get_user_model; User = get_user_model(); print(User.objects.filter(username='admin').exists())" | python src/manage.py shell)
8+
if [ "False" = "${exists}" ]
9+
then
10+
echo "Creating user 'admin'"
11+
python src/manage.py createsuperuser --username=admin [email protected] --noinput
12+
else
13+
echo "User 'admin' already exists"
14+
fi
15+
echo "Setting 'admin' password."
16+
echo "from django.contrib.auth import get_user_model; User = get_user_model(); user = User.objects.get(username='admin'); user.set_password('admin'); user.save()" | python src/manage.py shell
17+
echo "Loading fixtures"
18+
python src/manage.py loaddata klantinteracties contactgegevens
19+
echo "Finished setup"
20+
21+
sh /start.sh

form/build.gradle.kts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import io.spring.gradle.dependencymanagement.org.codehaus.plexus.interpolation.os.Os.FAMILY_MAC
2-
import org.apache.tools.ant.taskdefs.condition.Os
3-
41
/*
52
* Copyright 2015-2023 Ritense BV, the Netherlands.
63
*
@@ -21,12 +18,8 @@ plugins {
2118
}
2219

2320
dockerCompose {
24-
if (Os.isFamily(FAMILY_MAC)) {
25-
executable = "/usr/local/bin/docker-compose"
26-
dockerExecutable = "/usr/local/bin/docker"
27-
}
28-
projectNamePrefix = "form"
29-
isRequiredBy(tasks.getByName("test"))
21+
setProjectName("$name-test")
22+
isRequiredBy(tasks.getByName("integrationTest"))
3023
useComposeFiles.addAll("../docker-resources/docker-compose-base-test.yml", "docker-compose-override.yml")
3124
}
3225

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ springBootVersion=3.4.1
88
springDependencyManagementVersion=1.1.7
99
benManesVersionsVersion=0.51.0
1010
ktlintVersion=12.1.2
11-
spotlessVersion=6.25.0
11+
spotlessVersion=7.0.2
1212
gradleDockerComposeVersion=0.17.12
1313
dokkaVersion=2.0.0
1414

1515
org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=2048m
1616
org.gradle.workers.max=10
17-
version=1.4.36-SNAPSHOT
17+
version=1.4.37-SNAPSHOT

gradle/testing.gradle.kts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2015-2024 Ritense BV, the Netherlands.
3+
*
4+
* Licensed under EUPL, Version 1.2 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" basis,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
tasks.register<Test>("integrationTest") {
18+
group = "verification"
19+
description =
20+
"""
21+
Composes docker containers and runs Tests tagged with "integration".
22+
NB! Project root must contain a docker compose file with the following name: docker-compose-override.yml
23+
""".trimIndent()
24+
useJUnitPlatform {
25+
includeTags("integration")
26+
}
27+
}
28+
29+
tasks.named<Test>("test") {
30+
useJUnitPlatform {
31+
excludeTags("integration")
32+
}
33+
}
34+
35+
tasks.named("check") {
36+
dependsOn(tasks.getByName("integrationTest"))
37+
}

settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ include(
5858
"zgw:zaken-api",
5959
"zgw:objectenapi",
6060
"zgw:besluiten",
61+
"zgw:openklant",
6162
)

zgw/openklant/build.gradle.kts

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import org.springframework.boot.gradle.tasks.bundling.BootJar
2+
3+
/*
4+
* Copyright (c) 2024 Ritense BV, the Netherlands.
5+
*
6+
* Licensed under EUPL, Version 1.2 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" basis,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
plugins {
19+
kotlin("jvm")
20+
}
21+
22+
val isLib = true
23+
24+
dockerCompose {
25+
setProjectName("$name-test")
26+
isRequiredBy(tasks.getByName("integrationTest"))
27+
useComposeFiles.addAll("../../docker-resources/docker-compose-base-test.yml", "docker-compose-override.yml")
28+
}
29+
30+
dependencies {
31+
api(project(":graphql"))
32+
api(project(":portal-authentication"))
33+
api(project(":zgw:common-ground-authentication"))
34+
35+
testImplementation(project(":zgw:common-ground-authentication-test"))
36+
testImplementation(TestDependencies.postgresql)
37+
testImplementation("org.springframework.boot", "spring-boot-starter-test")
38+
testImplementation("org.springframework.security", "spring-security-test")
39+
testImplementation(TestDependencies.kotlinCoroutines)
40+
testImplementation(TestDependencies.mockitoKotlin)
41+
testImplementation(TestDependencies.okHttpMockWebserver)
42+
testImplementation(TestDependencies.okHttp)
43+
}
44+
45+
val jar: Jar by tasks
46+
val bootJar: BootJar by tasks
47+
bootJar.enabled = false
48+
jar.enabled = true
49+
50+
apply(from = "gradle/publishing.gradle.kts")
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
services:
2+
3+
# openklant 2
4+
openklant-2:
5+
image: maykinmedia/open-klant:2.1.0
6+
container_name: openklant-2-test
7+
ports:
8+
- "9007:8000"
9+
depends_on:
10+
- openklant-2-db
11+
- redis
12+
environment:
13+
- DJANGO_SETTINGS_MODULE=openklant.conf.docker
14+
- IS_HTTPS=no
15+
- DB_NAME=openklant
16+
- DB_USER=openklant
17+
- DB_PASSWORD=openklant
18+
- DB_HOST=openklant-2-db
19+
- ALLOWED_HOSTS=*
20+
- CACHE_DEFAULT=redis-test:6379/0
21+
- CACHE_AXES=redis-test:6379/0
22+
- SUBPATH=${SUBPATH:-/}
23+
- SECRET_KEY=${SECRET_KEY:-django-insecure-f8s@b*ds4t84-q_2#c0j0506@!l2q6r5_pq5e!vm^_9c*#^66b}
24+
- CELERY_BROKER_URL=redis://redis-test:6379/0
25+
- CELERY_RESULT_BACKEND=redis://redis-test:6379/0
26+
- DISABLE_2FA=true
27+
volumes:
28+
- ./imports/openklant-2/init:/app/init
29+
command: sh /app/init/init.sh
30+
31+
openklant-2-db:
32+
image: postgres:15
33+
container_name: openklant-2-db-test
34+
environment:
35+
- POSTGRES_USER=openklant
36+
- POSTGRES_PASSWORD=openklant
37+
- POSTGRES_DB=openklant
38+
volumes:
39+
- ./imports/openklant-2/database:/docker-entrypoint-initdb.d/
40+
41+
redis:
42+
image: redis:6.2.6
43+
container_name: redis-test

zgw/openklant/gradle.properties

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright (c) 2024 Ritense BV, the Netherlands.
3+
#
4+
# Licensed under EUPL, Version 1.2 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" basis,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
isLib = true

0 commit comments

Comments
 (0)