diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl index 435ffac96d724c9343abceb3c43d4b5c01ee5c5b..b751300901210a527e983c3866a633f31ac9adf1 100644 --- a/src/main/helm/templates/_helpers.tpl +++ b/src/main/helm/templates/_helpers.tpl @@ -125,7 +125,7 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- define "app.bayernidAbsenderName" -}} -{{- quote (required "ozgcloud.bayernid.absender.name must be set if ozgcloud.bayernid is enabled" (((.Values.ozgcloud).bayernid).absender).name) -}} +{{- quote (required "ozgcloud.bayernid.absender.name must be set if ozgcloud.bayernid is enabled" (((.Values.ozgcloud).bayernid).absender).name) -}} {{- end -}} {{- define "app.bayernidAbsenderMandant" -}} @@ -164,6 +164,12 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- end -}} {{- end -}} +{{- define "app.fachstelleHost" -}} +{{- if (.Values.fachstelle).enabled -}} +{{- required "fachstelle.host must be set" .Values.fachstelle.host | quote }} +{{- end -}} +{{- end -}} + {{- define "app.getZufiManagerAddress" -}} {{- required "zufiManager.address must be set" (.Values.zufiManager).address -}} {{- end -}} \ No newline at end of file diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml index a031c30f57aa11bbd4d57dbc13fe78a7d4be56ea..113dce5b90c33074e90747c68bd347c11b073907 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -278,6 +278,8 @@ spec: - name: ozgcloud_alfa_host value: {{ include "app.alfaHost" . }} + - name: ozgcloud_fachstelle_host + value: {{ include "app.fachstelleHost" . }} - name: ozgcloud_vorgangManager_serviceAddress value: {{ include "app.ozgcloud_vorgangmanager_address" . }} diff --git a/src/test/helm/deployment_fachstelle_host_test.yaml b/src/test/helm/deployment_fachstelle_host_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1e7335c3b04425ec5b5582725bd7feb41b932a6f --- /dev/null +++ b/src/test/helm/deployment_fachstelle_host_test.yaml @@ -0,0 +1,61 @@ +# +# Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den +# Ministerpräsidenten des Landes Schleswig-Holstein +# Staatskanzlei +# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung +# +# Lizenziert unter der EUPL, Version 1.2 oder - sobald +# diese von der Europäischen Kommission genehmigt wurden - +# Folgeversionen der EUPL ("Lizenz"); +# Sie dürfen dieses Werk ausschließlich gemäß +# dieser Lizenz nutzen. +# Eine Kopie der Lizenz finden Sie hier: +# +# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 +# +# Sofern nicht durch anwendbare Rechtsvorschriften +# gefordert oder in schriftlicher Form vereinbart, wird +# die unter der Lizenz verbreitete Software "so wie sie +# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - +# ausdrücklich oder stillschweigend - verbreitet. +# Die sprachspezifischen Genehmigungen und Beschränkungen +# unter der Lizenz sind dem Lizenztext zu entnehmen. +# + +suite: test fachstelle host +release: + name: vorgang-manager + namespace: sh-helm-test +templates: + - templates/deployment.yaml +set: + baseUrl: test.sh.ozg-cloud.de + ozgcloud: + environment: dev + bezeichner: helm + imagePullSecret: test-image-pull-secret +tests: + - it: should set fachstelle host + set: + fachstelle: + enabled: true + host: https://hamburg.mein-kreis.de + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: ozgcloud_fachstelle_host + value: https://hamburg.mein-kreis.de + - it: should fail if host url is not set + set: + fachstelle: + enabled: true + asserts: + - failedTemplate: + errorMessage: "fachstelle.host must be set" + - it: should not fail if fachstelle is not enabled and host is not set + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: ozgcloud_fachstelle_host diff --git a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java index 780422562068fdc5a704075b80056084a4d22624..7c3ca7a247abec7da3362c0be354d360ef952f44 100644 --- a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java +++ b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java @@ -33,6 +33,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -54,6 +55,7 @@ import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.gridfs.GridFsTemplate; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.util.ReflectionTestUtils; import com.google.protobuf.ByteString; import com.thedeanda.lorem.LoremIpsum; @@ -64,6 +66,7 @@ import de.ozgcloud.apilib.user.OzgCloudUserProfile; import de.ozgcloud.apilib.user.OzgCloudUserProfileService; import de.ozgcloud.collaboration.CollaborationManagerConfiguration; import de.ozgcloud.collaboration.CollaborationRequest; +import de.ozgcloud.collaboration.CollaborationService; import de.ozgcloud.collaboration.CollaborationServiceGrpc.CollaborationServiceBlockingStub; import de.ozgcloud.collaboration.GrpcGetFileContentRequest; import de.ozgcloud.collaboration.request.CollaborationRequestId; @@ -107,7 +110,7 @@ import net.devh.boot.grpc.client.inject.GrpcClient; }) @DataITCase @WithMockCustomUser -@DirtiesContext +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class CollaborationITCase { private static final String FIELD_COLLABORATION_VORGANG_ID = "collaborationVorgangId"; @@ -117,6 +120,8 @@ class CollaborationITCase { @Autowired private CommandService commandService; + @Autowired + private CollaborationService collaborationService; @Autowired private MongoOperations mongoOperations; @@ -286,45 +291,59 @@ class CollaborationITCase { private static final int COLLABORATION_LEVEL = 4; - @Captor - private ArgumentCaptor<PostfachNachricht> postfachNachrichtCaptor; + @Nested + class TestSuccessfully { + @Captor + private ArgumentCaptor<PostfachNachricht> postfachNachrichtCaptor; + + @BeforeEach + void init() { + when(ozgCloudUserProfile.getId()).thenReturn(OzgCloudUserId.from(CommandTestFactory.CREATED_BY)); + when(collaborationOzgCloudUserProfileService.getById(any())).thenReturn(ozgCloudUserProfile); + } - @BeforeEach - void init() { - when(ozgCloudUserProfile.getId()).thenReturn(OzgCloudUserId.from(CommandTestFactory.CREATED_BY)); - when(collaborationOzgCloudUserProfileService.getById(any())).thenReturn(ozgCloudUserProfile); - } + @Test + void shouldCreateCollaborationRequest() { + var command = commandService.createCommand(buildCreateCollaborationVorgangCommand(vorgangId, COLLABORATION_LEVEL)); - @Test - void shouldCreateCollaborationRequest() { - var command = commandService.createCommand(buildCreateCollaborationVorgangCommand(vorgangId, COLLABORATION_LEVEL)); + waitUntilCommandHasStatus(command.getId(), CommandStatus.FINISHED); - waitUntilCommandHasStatus(command.getId(), CommandStatus.FINISHED); + var collaborationRequests = loadCollaborationRequest(vorgangId); + assertThat(collaborationRequests).hasSize(1).first().extracting(VorgangAttachedItem::getItem, MAP) + .containsEntry(FIELD_COLLABORATION_VORGANG_ID, vorgangId); + } - var collaborationRequests = loadCollaborationRequest(vorgangId); - assertThat(collaborationRequests).hasSize(1).first().extracting(VorgangAttachedItem::getItem, MAP) - .containsEntry(FIELD_COLLABORATION_VORGANG_ID, vorgangId); - } + @Test + void shouldSendPostfachNachricht() { + var command = commandService.createCommand(buildCreateCollaborationVorgangCommand(vorgangId, COLLABORATION_LEVEL)); - @Test - void shouldSendPostfachNachricht() { - var command = commandService.createCommand(buildCreateCollaborationVorgangCommand(vorgangId, COLLABORATION_LEVEL)); + waitUntilCommandHasStatus(command.getId(), CommandStatus.FINISHED); - waitUntilCommandHasStatus(command.getId(), CommandStatus.FINISHED); + verify(postfachRemoteService).sendMessage(postfachNachrichtCaptor.capture()); + assertThat(postfachNachrichtCaptor.getValue().getPostfachAddress()).extracting(PostfachAddress::getIdentifier) + .hasToString(MUK_POSTFACH_ID); + } + + @Test + void shouldDeleteCollaborationRequest() { + doThrow(TechnicalException.class).when(postfachRemoteService).sendMessage(any()); + var command = commandService.createCommand(buildCreateCollaborationVorgangCommand(vorgangId, COLLABORATION_LEVEL)); + + waitUntilCommandHasStatus(command.getId(), CommandStatus.ERROR); - verify(postfachRemoteService).sendMessage(postfachNachrichtCaptor.capture()); - assertThat(postfachNachrichtCaptor.getValue().getPostfachAddress()).extracting(PostfachAddress::getIdentifier) - .hasToString(MUK_POSTFACH_ID); + assertThat(loadCollaborationRequest(vorgangId)).isEmpty(); + } } @Test - void shouldDeleteCollaborationRequest() { - doThrow(TechnicalException.class).when(postfachRemoteService).sendMessage(any()); + void shouldFailOnMissingFachstelle() { + ReflectionTestUtils.setField(collaborationService, "urlProvider", Optional.empty()); var command = commandService.createCommand(buildCreateCollaborationVorgangCommand(vorgangId, COLLABORATION_LEVEL)); waitUntilCommandHasStatus(command.getId(), CommandStatus.ERROR); - assertThat(loadCollaborationRequest(vorgangId)).isEmpty(); + command = mongoOperations.findById(command.getId(), Command.class); + assertThat(command.getErrorMessage()).contains("Fachstelle not configured."); } } diff --git a/vorgang-manager-server/src/test/resources/application-itcase.yml b/vorgang-manager-server/src/test/resources/application-itcase.yml index 2ab5f3470287edaf719a5db27b0cba4480042d0b..13b6b74eaddf93313f798e602ee85be256562816 100644 --- a/vorgang-manager-server/src/test/resources/application-itcase.yml +++ b/vorgang-manager-server/src/test/resources/application-itcase.yml @@ -20,6 +20,10 @@ ozgcloud: notification: scheduling: enabled: false + fachstelle: + host: fachstelle.test.de + vorgang-manager: + serviceAddress: vorgang-manager.by-test-test mongock: enabled: false