Skip to content
Snippets Groups Projects
Commit 8cee4aba authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-6638 Fix für Registrierung am ZuFi' (#452) from...

Merge pull request 'OZG-6638 Fix für Registrierung am ZuFi' (#452) from OZG-6638-fix-registrierung-zufi into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/vorgang-manager/pulls/452


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 88f10a59 6c255f13
No related branches found
No related tags found
No related merge requests found
Showing
with 185 additions and 77 deletions
......@@ -63,6 +63,8 @@ spec:
value: "/bindings"
- name: spring_profiles_active
value: {{ include "app.envSpringProfiles" . }}
- name: ozgcloud_application_address
value: {{ include "app.ozgcloud_vorgangmanager_address" . }}
- name: ozgcloud_nachrichten-manager_address
value: {{ include "app.ozgcloud_vorgangmanager_address" . }}
{{- if .Values.env.ozgcloudAktenzeichen.enabled }}
......@@ -154,7 +156,11 @@ spec:
- name: ozgcloud_user-manager_url
value: {{ include "app.ozgcloud_migration_user-manager_address" . }}
- name: ozgcloud_zufi-manager_address
value: {{ .Values.zufiManager.address }}
value: {{ ((.Values.ozgcloud).zufiManager).address }}
- name: grpc_client_zufi-manager_address
value: {{ ((.Values.ozgcloud).zufiManager).address }}
- name: grpc_client_zufi-manager_negotiationType
value: {{ ((.Values.ozgcloud).zufiManager).negotiationType }}
{{- if not (.Values.database).useExternal }}
- name: spring_data_mongodb_uri
valueFrom:
......
#
# 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: deployment vorgang manager environment
release:
name: vorgang-manager
namespace: by-helm-test
templates:
- templates/deployment.yaml
set:
ozgcloud:
environment: dev
imagePullSecret: test-image-pull-secret
tests:
- it: check if application address is set
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: ozgcloud_application_address
value: vorgang-manager.by-helm-test:9090
\ No newline at end of file
......@@ -22,15 +22,17 @@
# unter der Lizenz sind dem Lizenztext zu entnehmen.
#
suite: test environments
suite: deployment zufi-manager address environment
release:
name: vorgang-manager
namespace: sh-helm-test
namespace: by-helm-test
templates:
- templates/deployment.yaml
set:
ozgcloud:
environment: dev
zufiManager:
address: zufi-manager.zufi:9090
imagePullSecret: test-image-pull-secret
tests:
- it: check if zufi-manager address is correct
......@@ -39,4 +41,22 @@ tests:
path: spec.template.spec.containers[0].env
content:
name: ozgcloud_zufi-manager_address
value: dns://zufi-manager.zufi:9090
value: zufi-manager.zufi:9090
- it: check if zufi-manager grpc client address is set
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: grpc_client_zufi-manager_address
value: zufi-manager.zufi:9090
- it: check if zufi-manager negotiationType is set
set:
ozgcloud:
zufiManager:
negotiationType: NOT_DEFAULT
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: grpc_client_zufi-manager_negotiationType
value: NOT_DEFAULT
/*
* 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.
*/
package de.ozgcloud.vorgang;
import jakarta.validation.constraints.NotBlank;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Validated
@Configuration
@ConfigurationProperties(prefix = "ozgcloud.application")
public class VorgangManagerProperties {
@NotBlank
private String address;
}
......@@ -2,11 +2,15 @@ package de.ozgcloud.vorgang.common.userconfig;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class UserConfigService {
@Autowired
private UserConfigRemoteService userConfigRemoteService;
private final UserConfigRemoteService userConfigRemoteService;
public List<String> getSupportedOrganisationsEinheiten() {
return userConfigRemoteService.getSupportedOrganisationsEinheiten();
......
......@@ -25,29 +25,34 @@ package de.ozgcloud.vorgang.registry;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.annotation.PostConstruct;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import de.ozgcloud.vorgang.common.userconfig.UserConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
@Profile("!itcase")
@Component
@ConditionalOnProperty(prefix = "ozgcloud.vorgang-manager", name = { "address" })
@ConditionalOnProperty(prefix = "ozgcloud.zufi-manager", name = { "address" })
@Log4j2
@RequiredArgsConstructor
class RegistryScheduler {
@Autowired
private RegistryService registryService;
@Autowired
private UserConfigService userConfigService;
private final RegistryService registryService;
private final UserConfigService userConfigService;
@PostConstruct
void logInitialization() {
LOG.info("Starting ZuFi registry scheduler");
}
@Scheduled(fixedDelayString = "${ozgcloud.vorgang-manager.registry.scheduler.fixedDelay:5}", //
initialDelayString = "${ozgcloud.vorgang-manager.registry.scheduler.initialDelay:5}", //
@Scheduled(fixedDelayString = "${ozgcloud.registry.scheduler.fixedDelayMinutes}",
initialDelayString = "${ozgcloud.registry.scheduler.initialDelayMinutes}",
timeUnit = TimeUnit.MINUTES)
@SchedulerLock(name = "RegistryScheduler")
void register() {
......
package de.ozgcloud.vorgang.registry;
import java.util.List;
import java.util.Optional;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import de.ozgcloud.vorgang.VorgangManagerProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
@Service
@Log4j2
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = "ozgcloud.zufi-manager", name = { "address" })
class RegistryService {
@Value(value = "${ozgcloud.vorgang-manager.address:#{null}}")
private Optional<String> vorgangManagerAddress;
@Autowired
private ZufiRemoteService zufiRemoteService;
private final VorgangManagerProperties vorgangManagerProperties;
private final ZufiRemoteService zufiRemoteService;
public void registerVorgangManager(List<String> supportedOrganisationsEinheiten) {
try {
register(supportedOrganisationsEinheiten);
} catch (Exception e) {
LOG.error("Error registering this VorgangsManager.", e);
if (supportedOrganisationsEinheiten.isEmpty()) {
LOG.warn("Missing organisationseinheitenIds. Skipping registration.");
return;
}
}
private void register(List<String> supportedOrganisationsEinheiten) {
if (CollectionUtils.isNotEmpty(supportedOrganisationsEinheiten)) {
registerAddress(supportedOrganisationsEinheiten, vorgangManagerAddress);
} else {
LOG.warn("No OrganistationsEinheitenIds provided. Not registering this VorgangsManager");
}
}
void registerAddress(List<String> supportedOrganisationsEinheiten, Optional<String> vorgangManagerAddress) {
vorgangManagerAddress.ifPresentOrElse(address -> {
zufiRemoteService.registerVorgangManager(supportedOrganisationsEinheiten, address);
}, () -> LOG.error("Property ozgcloud.vorgang-manager.address not set. Not registering this VorgangsManager"));
zufiRemoteService.registerVorgangManager(supportedOrganisationsEinheiten, vorgangManagerProperties.getAddress());
}
}
......@@ -2,6 +2,7 @@ package de.ozgcloud.vorgang.registry;
import java.util.List;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import de.ozgcloud.vorgang.callcontext.VorgangManagerClientCallContextAttachingInterceptor;
......@@ -13,14 +14,15 @@ import net.devh.boot.grpc.client.inject.GrpcClient;
@Log4j2
@Service
@ConditionalOnProperty(prefix = "ozgcloud.zufi-manager", name = { "address" })
class ZufiRemoteService {
@GrpcClient("zufi-manager")
private VorgangManagerRegistrationServiceBlockingStub serviceStub;
public void registerVorgangManager(@NonNull List<String> organistationsEinheitenIds, String vorgangManagerAddress) {
boolean success = getServiceStub()
.register(buildRequest(organistationsEinheitenIds, vorgangManagerAddress)).getSuccess();
LOG.info("Register success: " + success);
boolean success = getServiceStub().register(buildRequest(organistationsEinheitenIds, vorgangManagerAddress)).getSuccess();
LOG.info("Register success: {}", success);
}
private VorgangManagerRegistrationServiceBlockingStub getServiceStub() {
......
......@@ -62,6 +62,8 @@ ozgcloud:
sync:
enabled: false
aktenzeichen: de.ozgcloud.vorgang.vorgang.AktenzeichenProviderEA
application:
address: http://localhost:9090
notification:
mail-from: ea@ozg-sh.de
redirect:
......@@ -70,7 +72,7 @@ ozgcloud:
url: http://localhost:9092/migration/user
user:
cleanup:
cron: 0 */5 * * * *
cron: "-"
feature:
bescheid:
enable-dummy-document-processor: true
......
......@@ -42,6 +42,8 @@ grpc:
command-manager:
address: self:self
negotiationType: PLAINTEXT
zufi-manager:
negotiationType: TLS
server:
security:
......@@ -77,6 +79,10 @@ ozgcloud:
sync:
delay: 900_000
production: false
registry:
scheduler:
fixedDelayMinutes: 5
initialDelayMinutes: 5
osi:
postfach:
scheduler:
......
package de.ozgcloud.vorgang.registry;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.springframework.test.util.ReflectionTestUtils;
import de.ozgcloud.vorgang.VorgangManagerProperties;
class RegistryServiceTest {
private static final String ORGANISATION_EINHEITEN_ID = "123456";
private static final List<String> ORGANISATION_EINHEITEN_IDS = List.of(ORGANISATION_EINHEITEN_ID);
private static final Optional<String> VORGANG_MANAGER_ADDRESS = Optional.of("address");
private static final String VORGANG_MANAGER_ADDRESS = "vorgang-manager-address";
@Spy
@InjectMocks
......@@ -27,34 +26,24 @@ class RegistryServiceTest {
@Mock
private ZufiRemoteService zufiRemoteService;
@DisplayName("Test registering the VorgangManager")
@Nested
class TestRegistryVorgangManager {
@BeforeEach
void initVorgangManagerAddress() {
ReflectionTestUtils.setField(registryService, "vorgangManagerAddress", VORGANG_MANAGER_ADDRESS);
}
@Mock
private VorgangManagerProperties vorgangManagerProperties;
@Test
void shouldCallZuFiRemoteService() {
when(vorgangManagerProperties.getAddress()).thenReturn(VORGANG_MANAGER_ADDRESS);
registryService.registerVorgangManager(ORGANISATION_EINHEITEN_IDS);
verify(zufiRemoteService).registerVorgangManager(anyList(), any());
verify(zufiRemoteService).registerVorgangManager(ORGANISATION_EINHEITEN_IDS, VORGANG_MANAGER_ADDRESS);
}
@DisplayName("should not call zufi remote service when organisationseinheitenIds is empty")
@Test
void shouldNotCallZuFiRemoteServiceOnEmptyOrganisationsEinheitenIds() {
void shouldNotCallRegisterAddress() {
registryService.registerVorgangManager(Collections.emptyList());
verify(zufiRemoteService, never()).registerVorgangManager(anyList(), any());
Mockito.verifyNoInteractions(zufiRemoteService);
}
@Test
void shouldNotCallServiceStub() {
registryService.registerAddress(ORGANISATION_EINHEITEN_IDS, Optional.empty());
verify(zufiRemoteService, never()).registerVorgangManager(any(), any());
}
}
}
......@@ -14,6 +14,8 @@ ozgcloud:
administration:
sync:
enabled: false
application:
address: localhost
aktenzeichen: de.ozgcloud.vorgang.vorgang.AktenzeichenProviderEA
mongock:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment