Commit 3132310c authored by Siiri Tann's avatar Siiri Tann
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Siiri Tann

See merge request teis/admin-service!62
parents 6aeeca3d deae1303
# Changelog
## [1.19.0] - 2021-09-27
* TEIS-2385: added drivers inspections feature flag (set to false for prelive and live, true for local, dev, integtest,
test)
* TEIS-2412: added GetParameterByCode to ParameterMsListener and to ParameterGwListener for testing
* TEIS-2212: added new accidents parameters
* TEIS-2188: added allowed file extension parameter for drivers inspection
## [1.18.3] - 2021-09-13
* TEIS-2427: enable inspection-topics-visible feature flag.
......
theGroup=ee.sm.ti.teis
theVersion=1.18.3
theVersion=1.19.0
pluginVersion=1.3.0
commonsVersion=1.26.0
commonApiGatewayVersion=1.26.0
commonsVersion=1.27.0
commonApiGatewayVersion=1.27.0
......@@ -2,7 +2,9 @@ package ee.sm.ti.teis.adminservice.parameter.listener;
import ee.sm.ti.teis.AdminAppTestBase;
import ee.sm.ti.teis.commongateway.parameter.dto.ParameterDto;
import ee.sm.ti.teis.commongateway.parameter.request.GetParameterByCodeTestRequest;
import ee.sm.ti.teis.commongateway.parameter.request.ParametersRequest;
import ee.sm.ti.teis.commongateway.parameter.response.GetParameterByCodeTestResponse;
import ee.sm.ti.teis.commongateway.parameter.response.ParametersResponse;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
......@@ -10,6 +12,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
......@@ -25,11 +28,16 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ParameterGwListenerTest extends AdminAppTestBase {
private static final String PARAMETER_CODE_TEHIK = "X-TEST-TEHIK_URL";
public static final String PARAMETER_CODE_TEHIK_NAME = "TEHIK homepage URL";
public static final String PARAMETER_CODE_TEHIK_VALUE = "https://www.tehik.ee/?id={regCode}&test";
private static final String PARAMETER_CODE_NETI = "X-TEST-NETI_URL";
private static final String PARAMETER_CODE_TEATMIK = "LEGAL_PERSON_TEATMIK_WEB_LINK";
private static final String PARAMETER_CODE_GOOGLE = "X-TEST-GOOGLE_URL";
private static final String PARAMETER_CODE_ITI = "LEGAL_PERSON_ITI_WEB_LINK";
private static final String PARAMETER_CODE_TRIPLEDEV = "X-TEST-TRIPLEDEV_URL";
public static final String PARAMETER_CODE_REG_CODE = "X-TEST-TRIPLEDEV_REG_CODE";
public static final String PARAMETER_CODE_REG_CODE_NAME = "Tripledev registration number";
public static final String PARAMETER_CODE_REG_CODE_VALUE = "12055727";
ParametersRequest request;
RequestMetaDTO requestMetaDTO;
......@@ -107,4 +115,30 @@ public class ParameterGwListenerTest extends AdminAppTestBase {
assertBadRequest(response.getError());
}
@Test
void getParameterByCodeTest_hasScopes_success() {
GetParameterByCodeTestRequest request = new GetParameterByCodeTestRequest();
request.setPayload(PARAMETER_CODE_TEHIK, requestMetaDTO);
GetParameterByCodeTestResponse response = listener.getParameterByCodeTest(request);
ParameterDto dto = response.getPayload();
assertThat(dto.getCode()).isEqualTo(PARAMETER_CODE_TEHIK);
assertThat(dto.getValue()).isEqualTo(PARAMETER_CODE_TEHIK_VALUE);
assertThat(dto.getName()).isEqualTo(PARAMETER_CODE_TEHIK_NAME);
assertThat(dto.getScopes()).containsAll(List.of(COMMON, OFFICE));
}
@Test
void getParameterByCodeTest_noScopes_success() {
GetParameterByCodeTestRequest request = new GetParameterByCodeTestRequest();
request.setPayload(PARAMETER_CODE_REG_CODE, requestMetaDTO);
GetParameterByCodeTestResponse response = listener.getParameterByCodeTest(request);
ParameterDto dto = response.getPayload();
assertThat(dto.getCode()).isEqualTo(PARAMETER_CODE_REG_CODE);
assertThat(dto.getValue()).isEqualTo(PARAMETER_CODE_REG_CODE_VALUE);
assertThat(dto.getName()).isEqualTo(PARAMETER_CODE_REG_CODE_NAME);
assertThat(dto.getScopes()).isEmpty();
}
}
package ee.sm.ti.teis.adminservice.parameter.listener;
import ee.sm.ti.teis.AdminAppTestBase;
import ee.sm.ti.teis.adminservice.config.AdminQueueConfig.ParameterByCodeMsRequest;
import ee.sm.ti.teis.adminservice.config.AdminQueueConfig.ParameterByCodeMsResponse;
import ee.sm.ti.teis.adminservice.config.AdminQueueConfig.ParametersMsRequest;
import ee.sm.ti.teis.adminservice.config.AdminQueueConfig.ParametersMsResponse;
import ee.sm.ti.teis.domain.parameter.GetParameterByCode;
import ee.sm.ti.teis.domain.parameter.GetParameters;
import ee.sm.ti.teis.domain.parameter.Parameter;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.types.enums.ScopeType.ADMIN;
import static ee.sm.ti.teis.types.enums.ScopeType.*;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static java.util.Collections.emptyList;
import static java.util.UUID.randomUUID;
......@@ -20,10 +25,15 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ParameterMsListenerTest extends AdminAppTestBase {
public static final String PARAMETER_CODE = "X-TEST-TEHIK_URL";
public static final String PARAMETER_CODE_1 = "X-TEST-TEHIK_URL";
public static final String PARAMETER_NAME_1 = "TEHIK homepage URL";
public static final String PARAMETER_VALUE_1 = "https://www.tehik.ee/?id={regCode}&test";
public static final String PARAMETER_CODE_2 = "X-TEST-TRIPLEDEV_REG_CODE";
public static final String PARAMETER_NAME_2 = "Tripledev registration number";
public static final String PARAMETER_VALUE_2 = "12055727";
@Autowired
private ParameterMsListener listener;
private ParametersMsRequest request;
private RequestMetaDTO requestMetaDTO;
......@@ -45,7 +55,7 @@ public class ParameterMsListenerTest extends AdminAppTestBase {
ParametersMsResponse response = listener.getParameters(request);
assertThat(response.getPayload().size()).isGreaterThanOrEqualTo(5);
assertThat(response.getPayload()).extracting("code").contains(PARAMETER_CODE,
assertThat(response.getPayload()).extracting("code").contains(PARAMETER_CODE_1,
"LEGAL_PERSON_TEATMIK_WEB_LINK", "LEGAL_PERSON_ITI_WEB_LINK", "X-TEST-NETI_URL", "X-TEST-GOOGLE_URL");
}
......@@ -56,8 +66,38 @@ public class ParameterMsListenerTest extends AdminAppTestBase {
ParametersMsResponse response = listener.getParameters(request);
assertThat(response.getPayload().size()).isGreaterThanOrEqualTo(5);
assertThat(response.getPayload()).extracting("code").contains(PARAMETER_CODE,
assertThat(response.getPayload()).extracting("code").contains(PARAMETER_CODE_1,
"LEGAL_PERSON_TEATMIK_WEB_LINK", "LEGAL_PERSON_ITI_WEB_LINK", "X-TEST-NETI_URL", "X-TEST-GOOGLE_URL");
}
@Test
void getParameterByCode_hasScopes_success() {
GetParameterByCode dto = GetParameterByCode.builder().code(PARAMETER_CODE_1).build();
ParameterByCodeMsRequest parametersByCodeMsRequest = new ParameterByCodeMsRequest();
parametersByCodeMsRequest.setPayload(dto, requestMetaDTO);
ParameterByCodeMsResponse response = listener.getParameterByCode(parametersByCodeMsRequest);
Parameter parameter = response.getPayload();
assertThat(parameter.getCode()).isEqualTo(PARAMETER_CODE_1);
assertThat(parameter.getValue()).isEqualTo(PARAMETER_VALUE_1);
assertThat(parameter.getName()).isEqualTo(PARAMETER_NAME_1);
assertThat(parameter.getScopes()).containsAll(List.of(COMMON, OFFICE));
}
@Test
void getParameterByCode_noScopes_success() {
GetParameterByCode dto = GetParameterByCode.builder().code(PARAMETER_CODE_2).build();
ParameterByCodeMsRequest parametersByCodeMsRequest = new ParameterByCodeMsRequest();
parametersByCodeMsRequest.setPayload(dto, requestMetaDTO);
ParameterByCodeMsResponse response = listener.getParameterByCode(parametersByCodeMsRequest);
Parameter parameter = response.getPayload();
assertThat(parameter.getCode()).isEqualTo(PARAMETER_CODE_2);
assertThat(parameter.getName()).isEqualTo(PARAMETER_NAME_2);
assertThat(parameter.getValue()).isEqualTo(PARAMETER_VALUE_2);
assertThat(parameter.getScopes()).isEmpty();
}
}
......@@ -5,11 +5,13 @@ import ee.sm.ti.teis.commongateway.admin.CalculateDeadlineGwRequest;
import ee.sm.ti.teis.commongateway.admin.FeatureFlagRequest;
import ee.sm.ti.teis.commongateway.admin.GetPathRequest;
import ee.sm.ti.teis.commongateway.parameter.request.AdminParametersRequest;
import ee.sm.ti.teis.commongateway.parameter.request.GetParameterByCodeTestRequest;
import ee.sm.ti.teis.commongateway.parameter.request.ParametersRequest;
import ee.sm.ti.teis.commongateway.parameter.request.UpdateParameterValueRequest;
import ee.sm.ti.teis.configuration.QueueList;
import ee.sm.ti.teis.configuration.TeisQueue;
import ee.sm.ti.teis.domain.admin.*;
import ee.sm.ti.teis.domain.parameter.GetParameterByCode;
import ee.sm.ti.teis.domain.parameter.GetParameters;
import ee.sm.ti.teis.domain.parameter.Parameter;
import ee.sm.ti.teis.domainrequest.DomainQueryResponseDto;
......@@ -24,11 +26,13 @@ public class AdminQueueConfig implements QueueList {
public static final String MS_CALCULATE_DEADLINE_QUEUE = "admin-service.ms.calculateDeadlineRequests";
public static final String MS_PARAMETERS_QUEUE = "admin-service.ms.parameterRequests";
public static final String MS_PARAMETER_BY_CODE_QUEUE = "admin-service.ms.parameterByCodeRequests";
public static final String MS_GET_PATH_QUEUE = "admin-service.ms.getPathRequests";
public static final String MS_FEATURE_FLAG_QUEUE = "admin-service.ms.getFeatureFlagRequests";
public static final String GW_CALCULATE_DEADLINE_QUEUE = "admin-service.gw.calculateDeadlineRequests";
public static final String GW_PARAMETERS_QUEUE = "admin-service.gw.parametersRequests";
public static final String GW_PARAMETER_BY_CODE_TEST_QUEUE = "admin-service.gw.parameterByCodeTestRequests";
public static final String GW_UPDATE_PARAMETER_VALUE_QUEUE = "admin-service.gw.updateParameterValueRequests";
public static final String GW_ADMIN_PARAMETERS_QUEUE = "admin-service.gw.adminParametersRequests";
public static final String GW_GET_PATH_QUEUE = "admin-service.gw.getPathRequests";
......@@ -41,11 +45,13 @@ public class AdminQueueConfig implements QueueList {
addMsQueue(queues, "msCalculateDeadlineQueue", new CalculateDeadlineRequest().routingKey(), MS_CALCULATE_DEADLINE_QUEUE);
addMsQueue(queues, "msParametersQueue", new ParametersMsRequest().routingKey(), MS_PARAMETERS_QUEUE);
addMsQueue(queues, "msParameterByCodeQueue", new ParameterByCodeMsRequest().routingKey(), MS_PARAMETER_BY_CODE_QUEUE);
addMsQueue(queues, "msGetPathQueue", new GetPathMsRequest().routingKey(), MS_GET_PATH_QUEUE);
addMsQueue(queues, "msFeatureFlagQueue", new FeatureFlagMsRequest().routingKey(), MS_FEATURE_FLAG_QUEUE);
addGwQueue(queues, "gwCalculateDeadlineQueue", CalculateDeadlineGwRequest.ROUTING_KEY, GW_CALCULATE_DEADLINE_QUEUE);
addGwQueue(queues, "gwParametersQueue", ParametersRequest.ROUTING_KEY, GW_PARAMETERS_QUEUE);
addGwQueue(queues, "gwParameterByCodeTestQueue", GetParameterByCodeTestRequest.ROUTING_KEY, GW_PARAMETER_BY_CODE_TEST_QUEUE);
addGwQueue(queues, "gwUpdateParameterValueQueue", UpdateParameterValueRequest.ROUTING_KEY, GW_UPDATE_PARAMETER_VALUE_QUEUE);
addGwQueue(queues, "gwAdminParametersQueue", AdminParametersRequest.ROUTING_KEY, GW_ADMIN_PARAMETERS_QUEUE);
addGwQueue(queues, "gwGetPathQueue", GetPathRequest.ROUTING_KEY, GW_GET_PATH_QUEUE);
......@@ -64,6 +70,12 @@ public class AdminQueueConfig implements QueueList {
public static class ParametersMsResponse extends DomainQueryResponseDto<List<Parameter>, ErrorDTO> {
}
public static class ParameterByCodeMsRequest extends DomainRequestDTO<GetParameterByCode, ErrorDTO> {
}
public static class ParameterByCodeMsResponse extends DomainResponseDTO<Parameter, ErrorDTO> {
}
public static class GetPathMsRequest extends DomainRequestDTO<GetUrlPath, ErrorDTO> {
}
......
......@@ -13,11 +13,16 @@ import java.util.Set;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
@Component
public interface ParameterMapper {
ParameterDto toDto(Parameter parameter);
Set<ParameterDto> toDtoList(Set<ParameterEntity> parameters);
List<Parameter> toDomainList(Set<ParameterEntity> parameters);
Parameter toDomain(ParameterEntity parameters);
Set<AdminParameterDto> toAdminDtoList(Set<ParameterEntity> parameters);
List<Parameter> toDomainList(Set<ParameterEntity> parameters);
AdminParameterDto toAdminDto(ParameterEntity parameter);
Set<AdminParameterDto> toAdminDtoList(Set<ParameterEntity> parameters);
}
......@@ -5,9 +5,11 @@ import ee.sm.ti.teis.commongateway.parameter.dto.AdminParameterDto;
import ee.sm.ti.teis.commongateway.parameter.dto.ParameterDto;
import ee.sm.ti.teis.commongateway.parameter.dto.UpdateParameterValueDto;
import ee.sm.ti.teis.commongateway.parameter.request.AdminParametersRequest;
import ee.sm.ti.teis.commongateway.parameter.request.GetParameterByCodeTestRequest;
import ee.sm.ti.teis.commongateway.parameter.request.ParametersRequest;
import ee.sm.ti.teis.commongateway.parameter.request.UpdateParameterValueRequest;
import ee.sm.ti.teis.commongateway.parameter.response.AdminParametersResponse;
import ee.sm.ti.teis.commongateway.parameter.response.GetParameterByCodeTestResponse;
import ee.sm.ti.teis.commongateway.parameter.response.ParametersResponse;
import ee.sm.ti.teis.commongateway.parameter.response.UpdateParameterValueResponse;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -60,4 +62,14 @@ public class ParameterGwListener {
return response;
}
@RabbitListener(queues = {GW_PARAMETER_BY_CODE_TEST_QUEUE})
public GetParameterByCodeTestResponse getParameterByCodeTest(GetParameterByCodeTestRequest request) {
RequestMetaDTO requestMetaDTO = request.getRequestMetaDTO();
ParameterDto dto = service.getParameterByCode(request.getPayload());
GetParameterByCodeTestResponse response = new GetParameterByCodeTestResponse();
response.setPayload(dto, requestMetaDTO);
return response;
}
}
......@@ -26,4 +26,14 @@ public class ParameterMsListener {
response.setPayload(domainList, requestMetaDTO);
return response;
}
@RabbitListener(queues = {MS_PARAMETER_BY_CODE_QUEUE})
public ParameterByCodeMsResponse getParameterByCode(ParameterByCodeMsRequest request) {
RequestMetaDTO requestMetaDTO = request.getRequestMetaDTO();
Parameter domain = service.getParameterByCode(request.getPayload().getCode());
ParameterByCodeMsResponse response = new ParameterByCodeMsResponse();
response.setPayload(domain, requestMetaDTO);
return response;
}
}
......@@ -17,10 +17,18 @@ public class ParameterComposeService {
private final ParameterMapper mapper;
public ParameterDto composeDto(Parameter parameter) {
return mapper.toDto(parameter);
}
public Set<ParameterDto> composeDtoList(Set<ParameterEntity> parameters) {
return mapper.toDtoList(parameters);
}
public Parameter composeDomain(ParameterEntity parameter) {
return mapper.toDomain(parameter);
}
public List<Parameter> composeDomainList(Set<ParameterEntity> parameters) {
return mapper.toDomainList(parameters);
}
......
......@@ -3,6 +3,7 @@ package ee.sm.ti.teis.adminservice.parameter.service;
import ee.sm.ti.teis.adminservice.parameter.ParameterEntity;
import ee.sm.ti.teis.commongateway.parameter.dto.AdminParameterDto;
import ee.sm.ti.teis.commongateway.parameter.dto.ParameterDto;
import ee.sm.ti.teis.domain.parameter.Parameter;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.ScopeType;
import lombok.RequiredArgsConstructor;
......@@ -24,6 +25,7 @@ public class ParameterGwBusinessService {
private final ParameterDataService dataService;
private final ParameterComposeService composeService;
private final ParameterNotifyService notifyService;
private final ParameterMsBusinessService msBusinessService;
public Set<ParameterDto> getParameters(@NotNull ScopeType scope) {
Set<ParameterEntity> parameters = dataService.getParametersByScope(scope);
......@@ -49,4 +51,9 @@ public class ParameterGwBusinessService {
return composeService.composeAdminDto(parameter);
}
public ParameterDto getParameterByCode(@NotBlank String code) {
Parameter parameter = msBusinessService.getParameterByCode(code);
return composeService.composeDto(parameter);
}
}
......@@ -6,6 +6,7 @@ import ee.sm.ti.teis.types.enums.ScopeType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Set;
......@@ -20,4 +21,9 @@ public class ParameterMsBusinessService {
Set<ParameterEntity> parameters = dataService.getParametersByScope(scope);
return composeService.composeDomainList(parameters);
}
public Parameter getParameterByCode(@NotBlank String code) {
ParameterEntity parameter = dataService.getByCode(code);
return composeService.composeDomain(parameter);
}
}
......@@ -42,3 +42,10 @@ values ('FILE_UPLOAD_MAX_SIZE', 'OFFICE'),
--changeset enriko:2020-12-02.increase-file-upload-max-size
update parameter set value = '52428800' where code = 'FILE_UPLOAD_MAX_SIZE';
--changeset kristel:2021-06-17.TEIS-2188.drivers-inspections-file-parameters
insert into parameter (code, name, value)
values ('FILE_UPLOAD_ALLOWED_DRIVERS_INSPECTION_EXTENSIONS', 'Süsteemi gateway-st lubatud üles laetava sõidukijuhtide järelevalve kõrvalekallete faili laiendid',
'xml');
insert into parameter_scope(parameter_code, scope)
values ('FILE_UPLOAD_ALLOWED_DRIVERS_INSPECTION_EXTENSIONS', 'OFFICE');
--liquibase formatted sql
--changeset siiri:2021-08-23.TEIS-2212.accidents-parameters
insert into parameter(code, value, name, mandatory, data_type, frequently_changed)
values ('ACCIDENT_VIEW_INTERVAL', 180, 'Periood, mille jooksul TI ametnik võib menetluse väliselt tegeleda tööõnnetuse andmetega nii, et ei pea uuesti sisestama põhjendust. Esitatakse minutites.', true, 'INT', false),
('DURATION_EMPLOYMENT_CONTRACT', 365, 'Kasutatakse tööõnnetuste teenuses töötajaga seotud tööandjate päringus TÖR-st. Periood päevades (= startDate), kui sisendis on startDate, siis toot_algus = startDate.TÖR päringuga saadakse 365 päeva ulatuses töötajaga seotud tööandjad (sh mitteaktiivsed).', true, 'INT', false);
--liquibase formatted sql
--changeset kristel:2021-08-26.TEIS-2385.add-drivers-inspections-feature-flag
insert into feature_flag (id, description, enabled, created_at)
values ('drivers-inspections-visible', 'Muutuja, mis määrab, kas sõidukijuhtide kontrolli funktsionaalsuse kasutamine on lubatud või mitte. true - funktsionaalsuse kasutamine on lubatud; false - funktsionaalsuse kasutamine ei ole lubatud', false, now());
......@@ -31,3 +31,4 @@ values ('X-TEST-1', 'Test Feature flag', false, now()),
('files-virus-scan-unchecked-download', 'Muutuja, mis lubab alla laadida faile, mida ei ole viirusetõrjete poolt skänneeritud', false, now());
update feature_flag set enabled = true where id in ('riskassessments-menu-item-visible', 'riskassessments-tool-visible', 'authorities-visible', 'riskassessments-files-visible', 'riskassessments');
update feature_flag set enabled = true where id in ('drivers-inspections-visible');
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment