Skip to content

Commit 0caff3d

Browse files
committed
Merge branch 'development' into feature/change-kotlin-logging-dependency
# Conflicts: # gradle.properties # product/src/main/kotlin/nl/nlportal/product/service/ProductService.kt
2 parents 67be2b0 + 396ed45 commit 0caff3d

File tree

99 files changed

+5278
-43
lines changed

Some content is hidden

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

99 files changed

+5278
-43
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

+11-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
@@ -164,6 +170,8 @@ nl-portal:
164170
allowedMethods: "*"
165171
endpoints:
166172
unsecured: /api/public/**
173+
machtingsdienst:
174+
#resource-url: classpath:machtigingsdiensten.json
167175
product:
168176
product-type-url: http://host.docker.internal:8011/api/v1/objecttypes/972e92ce-b964-4ca8-ad4d-ddc43dd7b244
169177
product-instantie-type-url: http://host.docker.internal:8011/api/v1/objecttypes/3e852115-277a-4570-873a-9a64be3aeb34
@@ -185,4 +193,4 @@ nl-portal:
185193
shaInKey: de14f0e3-2ff0-45eb-95a6-1cdc35ca7a00
186194
shaOutKey: de14f0e3-2ff0-45eb-95a6-1cdc35ca7a00
187195
failureUrl: http://localhost:3000
188-
successUrl: http://localhost:3000
196+
successUrl: http://localhost:3000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"uuid":"dd95bdee-c493-4757-bae3-fe0a5b5063f8",
4+
"naam":"Uitvoeren WMO-dienstverlening",
5+
"zaakTypes": [
6+
"dd95bdee-c493-4757-bae3-fe0a5b5063f8"
7+
],
8+
"taakTypes": [
9+
"RMWA"
10+
]
11+
}
12+
]

build.gradle.kts

+17-5
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
@@ -44,7 +46,7 @@ plugins {
4446

4547
id("org.jetbrains.dokka")
4648

47-
id("org.owasp.dependencycheck") version "11.1.1"
49+
id("org.owasp.dependencycheck") version "12.0.0"
4850

4951
`maven-publish`
5052
`signing`
@@ -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=7.0.1
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+
}

product/src/main/kotlin/nl/nlportal/product/autoconfiguration/ProductAutoConfiguration.kt

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package nl.nlportal.product.autoconfiguration
1717

18+
import nl.nlportal.commonground.authentication.AuthenticationMachtigingsDienstService
1819
import nl.nlportal.core.ssl.ClientSslContextResolver
1920
import nl.nlportal.product.client.DmnClient
2021
import nl.nlportal.product.client.DmnConfig
@@ -58,6 +59,7 @@ class ProductAutoConfiguration {
5859
taakObjectConfig: TaakObjectConfig,
5960
objectsApiTaskConfig: TaakObjectConfig,
6061
dmnClient: DmnClient,
62+
authenticationMachtigingsDienstService: AuthenticationMachtigingsDienstService,
6163
): ProductService {
6264
return ProductService(
6365
productConfig,
@@ -66,6 +68,7 @@ class ProductAutoConfiguration {
6668
taakObjectConfig,
6769
objectsApiTaskConfig,
6870
dmnClient,
71+
authenticationMachtigingsDienstService,
6972
)
7073
}
7174

product/src/main/kotlin/nl/nlportal/product/graphql/ProductQuery.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ProductQuery(
8686
dfe: DataFetchingEnvironment,
8787
productTypeId: UUID? = null,
8888
productName: String,
89-
pageSize: Int? = 20,
89+
pageSize: Int? = null,
9090
isOpen: Boolean? = null,
9191
): List<Zaak> {
9292
return productService.getProductZaken(

product/src/main/kotlin/nl/nlportal/product/service/ProductService.kt

+22-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package nl.nlportal.product.service
1717

1818
import com.fasterxml.jackson.databind.node.ObjectNode
1919
import io.github.oshai.kotlinlogging.KotlinLogging
20+
import nl.nlportal.commonground.authentication.AuthenticationMachtigingsDienstService
2021
import nl.nlportal.commonground.authentication.CommonGroundAuthentication
2122
import nl.nlportal.core.util.Mapper
2223
import nl.nlportal.product.client.DmnClient
@@ -50,6 +51,7 @@ class ProductService(
5051
val taakObjectConfig: TaakObjectConfig,
5152
val objectsApiTaskConfig: TaakObjectConfig,
5253
val dmnClient: DmnClient,
54+
val authenticationMachtigingsDienstService: AuthenticationMachtigingsDienstService,
5355
) {
5456
suspend fun getProduct(
5557
authentication: CommonGroundAuthentication,
@@ -154,17 +156,30 @@ class ProductService(
154156
return emptyList()
155157
}
156158

159+
// val zaakTypes = mutableSetOf<UUID>()
160+
val zaakTypes = productType.zaaktypen
157161
val request =
158162
zakenApiClient.zoeken()
159163
.search()
160164
.page(pageNumber)
161165
.withAuthentication(authentication)
162-
.ofZaakTypes(productType.zaaktypen.map { it })
163166
pageSize?.let { request.pageSize(it) }
164167
isOpen?.let {
165168
request.isOpen(isOpen)
166169
}
167170

171+
/*authenticationMachtigingsDienstService.zaakTypes(authentication)?.let {
172+
zaakTypes.addAll(it)
173+
}*/
174+
175+
if (!authenticationMachtigingsDienstService.isAllowedZaakTypes(authentication, zaakTypes)) {
176+
return emptyList()
177+
}
178+
179+
if (zaakTypes.isNotEmpty()) {
180+
request.ofZaakTypes(zaakTypes.toList())
181+
}
182+
168183
authentication.getVestigingsNummer()?.let {
169184
request.ofVestigingsNummer(it)
170185
}
@@ -346,12 +361,16 @@ class ProductService(
346361
pageSize: Int,
347362
): List<TaakV2> {
348363
val objectSearchParameters =
349-
listOf(
364+
mutableListOf(
350365
ObjectSearchParameter("identificatie__type", Comparator.EQUAL_TO, authentication.userType),
351366
ObjectSearchParameter("identificatie__value", Comparator.EQUAL_TO, authentication.userId),
352367
ObjectSearchParameter("status", Comparator.EQUAL_TO, "open"),
353368
)
354369

370+
authenticationMachtigingsDienstService.taakTypes(authentication)?.let {
371+
objectSearchParameters.add(ObjectSearchParameter("eigenaar", Comparator.IN_LIST, it.joinToString("|")))
372+
}
373+
355374
return getObjectsApiObjectResultPage<TaakObjectV2>(
356375
objectsApiTaskConfig.typeUrlV2,
357376
objectSearchParameters,
@@ -442,4 +461,4 @@ class ProductService(
442461

443462
val logger = KotlinLogging.logger {}
444463
}
445-
}
464+
}

0 commit comments

Comments
 (0)