From 7151a3cb00c3c882819dc0d0550c73cca3c8d7a9 Mon Sep 17 00:00:00 2001 From: kameshsr <47484458+kameshsr@users.noreply.github.com> Date: Tue, 21 Jan 2025 12:15:42 +0530 Subject: [PATCH 1/4] MOSIP-37024 Fixed notification issue (#1027) Signed-off-by: kameshsr Signed-off-by: ase-101 --- .../msg91/impl/SMSServiceProviderImpl.java | 13 +- .../msg91/test/SmsServiceProviderTest.java | 232 +++++++++--------- .../src/test/resources/application.properties | 2 + 3 files changed, 128 insertions(+), 119 deletions(-) diff --git a/kernel/kernel-smsserviceprovider-msg91/src/main/java/io/mosip/kernel/smsserviceprovider/msg91/impl/SMSServiceProviderImpl.java b/kernel/kernel-smsserviceprovider-msg91/src/main/java/io/mosip/kernel/smsserviceprovider/msg91/impl/SMSServiceProviderImpl.java index eda398cb61..83bee9147d 100644 --- a/kernel/kernel-smsserviceprovider-msg91/src/main/java/io/mosip/kernel/smsserviceprovider/msg91/impl/SMSServiceProviderImpl.java +++ b/kernel/kernel-smsserviceprovider-msg91/src/main/java/io/mosip/kernel/smsserviceprovider/msg91/impl/SMSServiceProviderImpl.java @@ -60,6 +60,9 @@ public class SMSServiceProviderImpl implements SMSServiceProvider { @Value("${mosip.kernel.sms.unicode:1}") String unicode; + @Value("${mosip.id.validation.identity.phone}") + private String phoneRegex; + @Override public SMSResponseDto sendSms(String contactNumber, String message) { SMSResponseDto smsResponseDTO = new SMSResponseDto(); @@ -85,16 +88,14 @@ public SMSResponseDto sendSms(String contactNumber, String message) { } private void validateInput(String contactNumber) { - if (!StringUtils.isNumeric(contactNumber) || (!inRange(contactNumber.length(), numberMinLength, - numberMaxLength))) { + if (!phoneValidator(contactNumber)) { throw new InvalidNumberException(SmsExceptionConstant.SMS_INVALID_CONTACT_NUMBER.getErrorCode(), - SmsExceptionConstant.SMS_INVALID_CONTACT_NUMBER.getErrorMessage() + numberMinLength + "-" - + numberMaxLength + SmsPropertyConstant.SUFFIX_MESSAGE.getProperty()); + SmsExceptionConstant.SMS_INVALID_CONTACT_NUMBER.getErrorMessage()); } } - private boolean inRange(int value, int min, int max) { - return (value >= min) && (value <= max); + public boolean phoneValidator(String phone) { + return phone.matches(phoneRegex); } } \ No newline at end of file diff --git a/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java b/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java index a4f769e141..38fd7e5fc2 100644 --- a/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java +++ b/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java @@ -1,114 +1,120 @@ -package io.mosip.kernel.smsserviceprovider.msg91.test; - -import static org.mockito.Mockito.when; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.core.io.ClassPathResource; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import io.mosip.kernel.core.notification.exception.InvalidNumberException; -import io.mosip.kernel.core.notification.model.SMSResponseDto; -import io.mosip.kernel.smsserviceprovider.msg91.constant.SmsPropertyConstant; -import io.mosip.kernel.smsserviceprovider.msg91.dto.SmsServerResponseDto; -import io.mosip.kernel.smsserviceprovider.msg91.impl.SMSServiceProviderImpl; - -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = { ConfigFileApplicationContextInitializer.class, SmsServiceProviderTest.config.class, - SMSServiceProviderImpl.class }) -public class SmsServiceProviderTest { - - @Configuration - static class config { - - @Bean - public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer(); - propertySourcesPlaceholderConfigurer.setLocations(new ClassPathResource("application.properties")); - return propertySourcesPlaceholderConfigurer; - } - } - - @Autowired - SMSServiceProviderImpl service; - - @MockBean - RestTemplate restTemplate; - - @Value("${mosip.kernel.sms.api}") - String api; - - @Value("${mosip.kernel.sms.authkey}") - String authkey; - - @Value("${mosip.kernel.sms.country.code}") - String countryCode; - - @Value("${mosip.kernel.sms.sender}") - String senderId; - - @Value("${mosip.kernel.sms.route}") - String route; - - @Test - public void sendSmsTest() { - - UriComponentsBuilder sms = UriComponentsBuilder.fromHttpUrl(api) - .queryParam(SmsPropertyConstant.AUTH_KEY.getProperty(), authkey) - .queryParam(SmsPropertyConstant.SMS_MESSAGE.getProperty(), "your otp is 4646") - .queryParam(SmsPropertyConstant.ROUTE.getProperty(), route) - .queryParam(SmsPropertyConstant.SENDER_ID.getProperty(), senderId) - .queryParam(SmsPropertyConstant.RECIPIENT_NUMBER.getProperty(), "8987876473") - .queryParam(SmsPropertyConstant.COUNTRY_CODE.getProperty(), countryCode); - - SmsServerResponseDto serverResponse = new SmsServerResponseDto(); - serverResponse.setType("success"); - SMSResponseDto dto = new SMSResponseDto(); - dto.setStatus(serverResponse.getType()); - dto.setMessage("Sms Request Sent"); - - when(restTemplate.getForEntity(sms.toUriString(), String.class)) - .thenReturn(new ResponseEntity<>(serverResponse.toString(), HttpStatus.OK)); - - when(restTemplate.postForEntity(Mockito.anyString(), Mockito.eq(Mockito.any()), Object.class)) - .thenReturn(new ResponseEntity<>(serverResponse, HttpStatus.OK)); - - // assertThat(service.sendSms("8987876473", "your otp is 4646"), - // is(dto)); - - } - - @Test(expected = InvalidNumberException.class) - public void invalidContactNumberTest() { - service.sendSms("jsbchb", "hello your otp is 45373"); - } - - @Test(expected = InvalidNumberException.class) - public void contactNumberMinimumThresholdTest() { - service.sendSms("78978976", "hello your otp is 45373"); - } - - @Test(expected = InvalidNumberException.class) - public void contactNumberMaximumThresholdTest() { - service.sendSms("7897897458673484376", "hello your otp is 45373"); - } - - @Test - public void validGateWayTest() { - service.sendSms("1234567890", "hello your otp is 45373"); - } - +package io.mosip.kernel.smsserviceprovider.msg91.test; + +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import io.mosip.kernel.core.notification.exception.InvalidNumberException; +import io.mosip.kernel.core.notification.model.SMSResponseDto; +import io.mosip.kernel.smsserviceprovider.msg91.constant.SmsPropertyConstant; +import io.mosip.kernel.smsserviceprovider.msg91.dto.SmsServerResponseDto; +import io.mosip.kernel.smsserviceprovider.msg91.impl.SMSServiceProviderImpl; + +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = { ConfigDataApplicationContextInitializer.class, SmsServiceProviderTest.config.class, + SMSServiceProviderImpl.class }) +public class SmsServiceProviderTest { + + @Configuration + static class config { + + @Bean + public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer(); + propertySourcesPlaceholderConfigurer.setLocations(new ClassPathResource("application.properties")); + return propertySourcesPlaceholderConfigurer; + } + } + + @Autowired + SMSServiceProviderImpl service; + + @MockBean + RestTemplate restTemplate; + + @Value("${mosip.kernel.sms.api}") + String api; + + @Value("${mosip.kernel.sms.authkey}") + String authkey; + + @Value("${mosip.kernel.sms.country.code}") + String countryCode; + + @Value("${mosip.kernel.sms.sender}") + String senderId; + + @Value("${mosip.kernel.sms.route}") + String route; + + @Value("${mosip.id.validation.identity.phone}") + private String phoneRegex; + + @Value("${phone}") + private String phone; + + @Test + public void sendSmsTest() { + + UriComponentsBuilder sms = UriComponentsBuilder.fromHttpUrl(api) + .queryParam(SmsPropertyConstant.AUTH_KEY.getProperty(), authkey) + .queryParam(SmsPropertyConstant.SMS_MESSAGE.getProperty(), "your otp is 4646") + .queryParam(SmsPropertyConstant.ROUTE.getProperty(), route) + .queryParam(SmsPropertyConstant.SENDER_ID.getProperty(), senderId) + .queryParam(SmsPropertyConstant.RECIPIENT_NUMBER.getProperty(), "8987876473") + .queryParam(SmsPropertyConstant.COUNTRY_CODE.getProperty(), countryCode); + + SmsServerResponseDto serverResponse = new SmsServerResponseDto(); + serverResponse.setType("success"); + SMSResponseDto dto = new SMSResponseDto(); + dto.setStatus(serverResponse.getType()); + dto.setMessage("Sms Request Sent"); + + when(restTemplate.getForEntity(sms.toUriString(), String.class)) + .thenReturn(new ResponseEntity<>(serverResponse.toString(), HttpStatus.OK)); + + when(restTemplate.postForEntity(Mockito.anyString(), Mockito.eq(Mockito.any()), Object.class)) + .thenReturn(new ResponseEntity<>(serverResponse, HttpStatus.OK)); + + // assertThat(service.sendSms("8987876473", "your otp is 4646"), + // is(dto)); + + } + + @Test(expected = InvalidNumberException.class) + public void invalidContactNumberTest() { + service.sendSms("jsbchb", "hello your otp is 45373"); + } + + @Test(expected = InvalidNumberException.class) + public void contactNumberMinimumThresholdTest() { + service.sendSms("78978976", "hello your otp is 45373"); + } + + @Test(expected = InvalidNumberException.class) + public void contactNumberMaximumThresholdTest() { + service.sendSms("7897897458673484376", "hello your otp is 45373"); + } + + @Test + public void validGateWayTest() { + service.sendSms(phone, "hello your otp is 45373"); + } + } \ No newline at end of file diff --git a/kernel/kernel-smsserviceprovider-msg91/src/test/resources/application.properties b/kernel/kernel-smsserviceprovider-msg91/src/test/resources/application.properties index e1a06d081c..19f0378b32 100644 --- a/kernel/kernel-smsserviceprovider-msg91/src/test/resources/application.properties +++ b/kernel/kernel-smsserviceprovider-msg91/src/test/resources/application.properties @@ -18,3 +18,5 @@ auth.server.validate.url=https://dev.mosip.io/authmanager/v1.0/authorize/validat logging.level.org.springframework=OFF logging.level.root=OFF spring.main.banner-mode=off +mosip.id.validation.identity.phone=^[+]*([0-9]{1})([0-9]{9})$ +phone=1234567890 \ No newline at end of file From da0941547da873381566d7f705b5a5ec46900f77 Mon Sep 17 00:00:00 2001 From: ase-101 Date: Fri, 25 Jul 2025 14:12:32 +0530 Subject: [PATCH 2/4] MOSIP-42452 Signed-off-by: ase-101 --- authentication/authentication-childauthfilter-impl/pom.xml | 4 ++-- authentication/pom.xml | 2 +- cache-provider-hazelcast/pom.xml | 2 +- cache-provider-redis/pom.xml | 2 +- kernel/kernel-ref-idobjectvalidator/pom.xml | 4 ++-- kernel/kernel-smsserviceprovider-msg91/pom.xml | 2 +- .../smsserviceprovider/msg91/test/SmsServiceProviderTest.java | 3 +-- kernel/kernel-virusscanner-clamav/pom.xml | 4 ++-- kernel/pom.xml | 2 +- pre-registration-booking-service/pom.xml | 2 +- .../pom.xml | 2 +- .../registration-processor-external-stage/pom.xml | 2 +- 12 files changed, 15 insertions(+), 16 deletions(-) diff --git a/authentication/authentication-childauthfilter-impl/pom.xml b/authentication/authentication-childauthfilter-impl/pom.xml index 4f5db2ef63..b1025167b1 100644 --- a/authentication/authentication-childauthfilter-impl/pom.xml +++ b/authentication/authentication-childauthfilter-impl/pom.xml @@ -4,9 +4,9 @@ io.mosip.authentication authentication-ref-impl-parent - 1.2.0.2 + 1.2.0.3-SNAPSHOT - 1.2.0.2 + 1.2.0.3-SNAPSHOT authentication-childauthfilter-impl authentication-childauthfilter-impl ID Authentication Filter reference Implementation to check allowed auth types for child diff --git a/authentication/pom.xml b/authentication/pom.xml index c8c8a7d4d2..897bccb9db 100644 --- a/authentication/pom.xml +++ b/authentication/pom.xml @@ -5,7 +5,7 @@ io.mosip.authentication authentication-ref-impl-parent - 1.2.0.2 + 1.2.0.3-SNAPSHOT pom id-authentication Reference Impl Parent diff --git a/cache-provider-hazelcast/pom.xml b/cache-provider-hazelcast/pom.xml index 8cbf3dbe9a..ec0fbeb67b 100644 --- a/cache-provider-hazelcast/pom.xml +++ b/cache-provider-hazelcast/pom.xml @@ -6,7 +6,7 @@ io.mosip.cacheprovider cache-provider-hazelcast - 1.2.0.2 + 1.2.0.3-SNAPSHOT diff --git a/cache-provider-redis/pom.xml b/cache-provider-redis/pom.xml index 933761f4ea..812cb912f8 100644 --- a/cache-provider-redis/pom.xml +++ b/cache-provider-redis/pom.xml @@ -6,7 +6,7 @@ io.mosip.cacheprovider cache-provider-redis - 1.2.0.2 + 1.2.0.3-SNAPSHOT diff --git a/kernel/kernel-ref-idobjectvalidator/pom.xml b/kernel/kernel-ref-idobjectvalidator/pom.xml index 64500c80e9..3af7b1e534 100644 --- a/kernel/kernel-ref-idobjectvalidator/pom.xml +++ b/kernel/kernel-ref-idobjectvalidator/pom.xml @@ -4,12 +4,12 @@ io.mosip.kernel kernel-ref-parent - 1.2.0.2 + 1.2.0.3-SNAPSHOT kernel-ref-idobjectvalidator kernel-ref-idobjectvalidator - 1.2.0.2 + 1.2.0.3-SNAPSHOT 1.2.0.1 diff --git a/kernel/kernel-smsserviceprovider-msg91/pom.xml b/kernel/kernel-smsserviceprovider-msg91/pom.xml index 01be00b709..35bca25389 100644 --- a/kernel/kernel-smsserviceprovider-msg91/pom.xml +++ b/kernel/kernel-smsserviceprovider-msg91/pom.xml @@ -7,7 +7,7 @@ kernel-smsserviceprovider-msg91 kernel-smsserviceprovider-msg91 https://github.com/mosip/commons - 1.2.0.2 + 1.2.0.3-SNAPSHOT UTF-8 diff --git a/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java b/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java index 38fd7e5fc2..b9f86a8428 100644 --- a/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java +++ b/kernel/kernel-smsserviceprovider-msg91/src/test/java/io/mosip/kernel/smsserviceprovider/msg91/test/SmsServiceProviderTest.java @@ -7,7 +7,6 @@ import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -27,7 +26,7 @@ import io.mosip.kernel.smsserviceprovider.msg91.impl.SMSServiceProviderImpl; @RunWith(SpringRunner.class) -@ContextConfiguration(classes = { ConfigDataApplicationContextInitializer.class, SmsServiceProviderTest.config.class, +@ContextConfiguration(classes = { SmsServiceProviderTest.config.class, SMSServiceProviderImpl.class }) public class SmsServiceProviderTest { diff --git a/kernel/kernel-virusscanner-clamav/pom.xml b/kernel/kernel-virusscanner-clamav/pom.xml index 6ae0369ce6..d11b8019b1 100644 --- a/kernel/kernel-virusscanner-clamav/pom.xml +++ b/kernel/kernel-virusscanner-clamav/pom.xml @@ -6,11 +6,11 @@ io.mosip.kernel kernel-ref-parent - 1.2.0.2 + 1.2.0.3-SNAPSHOT kernel-virusscanner-clamav - 1.2.0.2 + 1.2.0.3-SNAPSHOT 1.2.0.1 11 diff --git a/kernel/pom.xml b/kernel/pom.xml index 38ae020ce5..ad56f506a6 100644 --- a/kernel/pom.xml +++ b/kernel/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.mosip.kernel kernel-ref-parent - 1.2.0.2 + 1.2.0.3-SNAPSHOT pom kernel Parent project of MOSIP Kernel Referernce Implementation components diff --git a/pre-registration-booking-service/pom.xml b/pre-registration-booking-service/pom.xml index 67a71c729f..9c04b3fd1e 100644 --- a/pre-registration-booking-service/pom.xml +++ b/pre-registration-booking-service/pom.xml @@ -12,7 +12,7 @@ io.mosip.preregistration pre-registration-booking-service - 1.2.0.2 + 1.2.0.3-SNAPSHOT pre-registration-booking-service Booking service of MOSIP Pre-registration https://github.com/mosip/mosip-ref-impl diff --git a/registration-processor/registration-processor-external-integration-service/pom.xml b/registration-processor/registration-processor-external-integration-service/pom.xml index 79e266953e..9e41de12fc 100644 --- a/registration-processor/registration-processor-external-integration-service/pom.xml +++ b/registration-processor/registration-processor-external-integration-service/pom.xml @@ -8,7 +8,7 @@ 1.2.0.1 registration-processor-external-integration-service - 1.2.0.2 + 1.2.0.3-SNAPSHOT MPL 2.0 diff --git a/registration-processor/registration-processor-external-stage/pom.xml b/registration-processor/registration-processor-external-stage/pom.xml index 099757e6b5..e381050dff 100644 --- a/registration-processor/registration-processor-external-stage/pom.xml +++ b/registration-processor/registration-processor-external-stage/pom.xml @@ -9,7 +9,7 @@ registration-processor-external-stage - 1.2.0.2 + 1.2.0.3-SNAPSHOT MPL 2.0 From 369abedd598784abb79495ecaaab67bfa69d1b69 Mon Sep 17 00:00:00 2001 From: ase-101 Date: Fri, 25 Jul 2025 14:16:17 +0530 Subject: [PATCH 3/4] Added name tag Signed-off-by: ase-101 --- .../registration-processor-external-integration-service/pom.xml | 1 + .../registration-processor-external-stage/pom.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/registration-processor/registration-processor-external-integration-service/pom.xml b/registration-processor/registration-processor-external-integration-service/pom.xml index 9e41de12fc..40369d66c2 100644 --- a/registration-processor/registration-processor-external-integration-service/pom.xml +++ b/registration-processor/registration-processor-external-integration-service/pom.xml @@ -8,6 +8,7 @@ 1.2.0.1 registration-processor-external-integration-service + registration-processor-external-integration-service 1.2.0.3-SNAPSHOT diff --git a/registration-processor/registration-processor-external-stage/pom.xml b/registration-processor/registration-processor-external-stage/pom.xml index e381050dff..6f2f40e9bf 100644 --- a/registration-processor/registration-processor-external-stage/pom.xml +++ b/registration-processor/registration-processor-external-stage/pom.xml @@ -9,6 +9,7 @@ registration-processor-external-stage + registration-processor-external-stage 1.2.0.3-SNAPSHOT From ba0c9003564c6c0c0f0e60de844dcfa15823a42f Mon Sep 17 00:00:00 2001 From: ase-101 Date: Fri, 25 Jul 2025 14:19:05 +0530 Subject: [PATCH 4/4] Added url & description tag Signed-off-by: ase-101 --- .../pom.xml | 3 +++ .../registration-processor-external-stage/pom.xml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/registration-processor/registration-processor-external-integration-service/pom.xml b/registration-processor/registration-processor-external-integration-service/pom.xml index 40369d66c2..aaf2e20f31 100644 --- a/registration-processor/registration-processor-external-integration-service/pom.xml +++ b/registration-processor/registration-processor-external-integration-service/pom.xml @@ -10,6 +10,9 @@ registration-processor-external-integration-service registration-processor-external-integration-service 1.2.0.3-SNAPSHOT + https://github.com/mosip/mosip-ref-impl + Registration Processor External Integration Service + MPL 2.0 diff --git a/registration-processor/registration-processor-external-stage/pom.xml b/registration-processor/registration-processor-external-stage/pom.xml index 6f2f40e9bf..40625a16e5 100644 --- a/registration-processor/registration-processor-external-stage/pom.xml +++ b/registration-processor/registration-processor-external-stage/pom.xml @@ -11,6 +11,9 @@ registration-processor-external-stage registration-processor-external-stage 1.2.0.3-SNAPSHOT + https://github.com/mosip/mosip-ref-impl + Registration Processor External Stage + MPL 2.0