Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions authentication/authentication-childauthfilter-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<parent>
<groupId>io.mosip.authentication</groupId>
<artifactId>authentication-ref-impl-parent</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
</parent>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
<artifactId>authentication-childauthfilter-impl</artifactId>
<name>authentication-childauthfilter-impl</name>
<description>ID Authentication Filter reference Implementation to check allowed auth types for child</description>
Expand Down
2 changes: 1 addition & 1 deletion authentication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.mosip.authentication</groupId>
<artifactId>authentication-ref-impl-parent</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
<packaging>pom</packaging>

<name>id-authentication Reference Impl Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion cache-provider-hazelcast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.mosip.cacheprovider</groupId>
<artifactId>cache-provider-hazelcast</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>

<properties>
<!-- maven -->
Expand Down
2 changes: 1 addition & 1 deletion cache-provider-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.mosip.cacheprovider</groupId>
<artifactId>cache-provider-redis</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>

<properties>
<!-- maven -->
Expand Down
4 changes: 2 additions & 2 deletions kernel/kernel-ref-idobjectvalidator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-ref-parent</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
</parent>

<name>kernel-ref-idobjectvalidator</name>
<artifactId>kernel-ref-idobjectvalidator</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>

<properties>
<kernel-core.version>1.2.0.1</kernel-core.version>
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel-smsserviceprovider-msg91/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<name>kernel-smsserviceprovider-msg91</name>
<description>kernel-smsserviceprovider-msg91</description>
<url>https://github.com/mosip/commons</url>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -1,114 +1,119 @@
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.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 = { 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");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions kernel/kernel-virusscanner-clamav/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-ref-parent</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
</parent>

<artifactId>kernel-virusscanner-clamav</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
<properties>
<kernel.core.version>1.2.0.1</kernel.core.version>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion kernel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-ref-parent</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>kernel</name>
<description>Parent project of MOSIP Kernel Referernce Implementation components</description>
Expand Down
2 changes: 1 addition & 1 deletion pre-registration-booking-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>io.mosip.preregistration</groupId>
<artifactId>pre-registration-booking-service</artifactId>
<version>1.2.0.2</version>
<version>1.2.0.3-SNAPSHOT</version>
<name>pre-registration-booking-service</name>
<description>Booking service of MOSIP Pre-registration</description>
<url>https://github.com/mosip/mosip-ref-impl</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
<version>1.2.0.1</version>
</parent>
<artifactId>registration-processor-external-integration-service</artifactId>
<version>1.2.0.2</version>
<name>registration-processor-external-integration-service</name>
<version>1.2.0.3-SNAPSHOT</version>
<url>https://github.com/mosip/mosip-ref-impl</url>
<description>Registration Processor External Integration Service</description>

<licenses>
<license>
<name>MPL 2.0</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
</parent>

<artifactId>registration-processor-external-stage</artifactId>
<version>1.2.0.2</version>
<name>registration-processor-external-stage</name>
<version>1.2.0.3-SNAPSHOT</version>
<url>https://github.com/mosip/mosip-ref-impl</url>
<description>Registration Processor External Stage</description>

<licenses>
<license>
<name>MPL 2.0</name>
Expand Down
Loading