-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1071 from LoganathanSekar7627/PSA-171-IDA-allow-a…
…ny-one-channel-fix-release-1.2.0.1-B5 PSA-171 IDA allow any one channel fix release 1.2.0.1 b5
- Loading branch information
Showing
12 changed files
with
181 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
@@ -215,23 +216,19 @@ public void TestgenerateOtp() throws IdAuthenticationBusinessException, RestServ | |
|
||
@SuppressWarnings("rawtypes") | ||
@Test | ||
public void TestPhonenumberisNull() throws IdAuthenticationBusinessException, RestServiceException { | ||
public void TestPhonenumberisNull_Phone_Channel_Alone() throws IdAuthenticationBusinessException, RestServiceException { | ||
OtpRequestDTO otpRequestDto = new OtpRequestDTO(); | ||
otpRequestDto.setId("id"); | ||
otpRequestDto.setRequestTime(new SimpleDateFormat(EnvUtil.getDateTimePattern()).format(new Date())); | ||
otpRequestDto.setTransactionID("1234567890"); | ||
ArrayList<String> channelList = new ArrayList<String>(); | ||
List<String> channelList = List.of("PHONE"); | ||
otpRequestDto.setOtpChannel(channelList); | ||
otpRequestDto.setIndividualId("2345678901234"); | ||
otpRequestDto.setIndividualIdType(IdType.UIN.getType()); | ||
otpRequestDto.setRequestTime("2019-02-18T18:17:48.923+05:30"); | ||
Map<String, Object> valueMap = new HashMap<>(); | ||
Map<String, List<IdentityInfoDTO>> idInfo = new HashMap<>(); | ||
List<IdentityInfoDTO> mailList = new ArrayList<>(); | ||
IdentityInfoDTO identityInfoDTO = new IdentityInfoDTO(); | ||
identityInfoDTO.setValue("[email protected]"); | ||
mailList.add(identityInfoDTO); | ||
idInfo.put("email", mailList); | ||
Map<String, Object> idInfo = new HashMap<>(); | ||
idInfo.put("email", "[email protected]"); | ||
valueMap.put("response", idInfo); | ||
Mockito.when(idAuthService.processIdType(Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anySet())) | ||
.thenReturn(valueMap); | ||
|
@@ -246,41 +243,141 @@ public void TestPhonenumberisNull() throws IdAuthenticationBusinessException, Re | |
map.put("otp", "123456"); | ||
response.setResponse(map); | ||
Mockito.when(restHelper.requestSync(Mockito.any())).thenReturn(response); | ||
Mockito.when(otpManager.sendOtp(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), | ||
Mockito.any())).thenReturn(true); | ||
try { | ||
otpServiceImpl.generateOtp(otpRequestDto, "1234567890", new TestObjectWithMetadata()); | ||
Assert.fail(); | ||
} | ||
catch(IdAuthenticationBusinessException ex) { | ||
assertEquals(IdAuthenticationErrorConstants.OTP_GENERATION_FAILED.getErrorCode(), ex.getErrorCode()); | ||
assertEquals(IdAuthenticationErrorConstants.OTP_GENERATION_FAILED.getErrorMessage(), ex.getErrorText()); | ||
assertEquals(IdAuthenticationErrorConstants.OTP_GENERATION_FAILED.getErrorMessage() + ". Phone Number is not found in identity data.", ex.getErrorText()); | ||
} | ||
} | ||
|
||
@Test(expected = IdAuthenticationBusinessException.class) | ||
public void TestPhoneorEmailisNull() throws IdAuthenticationBusinessException, RestServiceException { | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Test | ||
public void TestPhonenumberisNull_bothChannels() throws IdAuthenticationBusinessException, RestServiceException { | ||
OtpRequestDTO otpRequestDto = new OtpRequestDTO(); | ||
otpRequestDto.setId("id"); | ||
otpRequestDto.setRequestTime(new SimpleDateFormat(EnvUtil.getDateTimePattern()).format(new Date())); | ||
otpRequestDto.setTransactionID("1234567890"); | ||
ArrayList<String> channelList = new ArrayList<String>(); | ||
List<String> channelList = List.of("PHONE", "EMAIL"); | ||
otpRequestDto.setOtpChannel(channelList); | ||
otpRequestDto.setIndividualId("2345678901234"); | ||
otpRequestDto.setIndividualIdType(IdType.UIN.getType()); | ||
otpRequestDto.setRequestTime("2019-02-18T18:17:48.923+05:30"); | ||
Map<String, Object> valueMap = new HashMap<>(); | ||
Map<String, Object> idInfo = new HashMap<>(); | ||
idInfo.put("email", "[email protected]"); | ||
valueMap.put("response", idInfo); | ||
Mockito.when(idAuthService.processIdType(Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anySet())) | ||
.thenReturn(valueMap); | ||
Mockito.when(idAuthService.getToken(Mockito.any())).thenReturn("2345678901234"); | ||
Mockito.when(autntxnrepository.countRequestDTime(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(1); | ||
Mockito.when(uinHashSaltRepo.retrieveSaltById(Mockito.anyInt())).thenReturn("2344"); | ||
Mockito.when(idAuthSecurityManager.getUser()).thenReturn("ida_app_user"); | ||
RestRequestDTO value = getRestDto(); | ||
Mockito.when(restRequestFactory.buildRequest(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(value); | ||
ResponseWrapper<Map> response = new ResponseWrapper<>(); | ||
Map<String, Object> map = new HashMap<>(); | ||
map.put("otp", "123456"); | ||
response.setResponse(map); | ||
Mockito.when(restHelper.requestSync(Mockito.any())).thenReturn(response); | ||
Mockito.when(otpManager.sendOtp(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), | ||
Mockito.any())).thenReturn(true); | ||
otpServiceImpl.generateOtp(otpRequestDto, "1234567890", new TestObjectWithMetadata()); | ||
} | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Test | ||
public void TestEmailIdisNull_Email_Channel_Alone() throws IdAuthenticationBusinessException, RestServiceException { | ||
OtpRequestDTO otpRequestDto = new OtpRequestDTO(); | ||
otpRequestDto.setId("id"); | ||
otpRequestDto.setRequestTime(new SimpleDateFormat(EnvUtil.getDateTimePattern()).format(new Date())); | ||
otpRequestDto.setTransactionID("1234567890"); | ||
List<String> channelList = List.of("EMAIL"); | ||
otpRequestDto.setOtpChannel(channelList); | ||
otpRequestDto.setIndividualId("2345678901234"); | ||
otpRequestDto.setIndividualIdType(IdType.UIN.getType()); | ||
otpRequestDto.setRequestTime("2019-02-18T18:17:48.923+05:30"); | ||
Map<String, Object> valueMap = new HashMap<>(); | ||
Map<String, Object> idInfo = new HashMap<>(); | ||
idInfo.put("phone", "9292292934"); | ||
valueMap.put("response", idInfo); | ||
Mockito.when(idAuthService.processIdType(Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anySet())) | ||
.thenReturn(valueMap); | ||
Mockito.when(idAuthService.getToken(Mockito.any())).thenReturn("2345678901234"); | ||
Mockito.when(autntxnrepository.countRequestDTime(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(1); | ||
Mockito.when(uinHashSaltRepo.retrieveSaltById(Mockito.anyInt())).thenReturn("2344"); | ||
Mockito.when(idAuthSecurityManager.getUser()).thenReturn("ida_app_user"); | ||
RestRequestDTO value = getRestDto(); | ||
Mockito.when(restRequestFactory.buildRequest(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(value); | ||
ResponseWrapper<Map> response = new ResponseWrapper<>(); | ||
Map<String, Object> map = new HashMap<>(); | ||
map.put("otp", "123456"); | ||
response.setResponse(map); | ||
Mockito.when(restHelper.requestSync(Mockito.any())).thenReturn(response); | ||
Mockito.when(otpManager.sendOtp(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), | ||
Mockito.any())).thenReturn(true); | ||
try { | ||
otpServiceImpl.generateOtp(otpRequestDto, "1234567890", new TestObjectWithMetadata()); | ||
Assert.fail(); | ||
} | ||
catch(IdAuthenticationBusinessException ex) { | ||
assertEquals(IdAuthenticationErrorConstants.OTP_GENERATION_FAILED.getErrorCode(), ex.getErrorCode()); | ||
assertEquals(IdAuthenticationErrorConstants.OTP_GENERATION_FAILED.getErrorMessage() + ". Email ID is not found in identity data.", ex.getErrorText()); | ||
} | ||
} | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Test | ||
public void TestEmailIdisNull_bothChannels() throws IdAuthenticationBusinessException, RestServiceException { | ||
OtpRequestDTO otpRequestDto = new OtpRequestDTO(); | ||
otpRequestDto.setId("id"); | ||
otpRequestDto.setRequestTime(new SimpleDateFormat(EnvUtil.getDateTimePattern()).format(new Date())); | ||
otpRequestDto.setTransactionID("1234567890"); | ||
List<String> channelList = List.of("PHONE", "EMAIL"); | ||
otpRequestDto.setOtpChannel(channelList); | ||
otpRequestDto.setIndividualId("2345678901234"); | ||
otpRequestDto.setIndividualIdType(IdType.UIN.getType()); | ||
otpRequestDto.setRequestTime("2019-02-18T18:17:48.923+05:30"); | ||
Map<String, Object> valueMap = new HashMap<>(); | ||
Map<String, Object> idInfo = new HashMap<>(); | ||
idInfo.put("phone", "9384848384"); | ||
valueMap.put("response", idInfo); | ||
Mockito.when(idAuthService.processIdType(Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anySet())) | ||
.thenReturn(valueMap); | ||
Mockito.when(idAuthService.getToken(Mockito.any())).thenReturn("2345678901234"); | ||
Mockito.when(autntxnrepository.countRequestDTime(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(1); | ||
Mockito.when(uinHashSaltRepo.retrieveSaltById(Mockito.anyInt())).thenReturn("2344"); | ||
Mockito.when(idAuthSecurityManager.getUser()).thenReturn("ida_app_user"); | ||
RestRequestDTO value = getRestDto(); | ||
Mockito.when(restRequestFactory.buildRequest(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(value); | ||
ResponseWrapper<Map> response = new ResponseWrapper<>(); | ||
Map<String, Object> map = new HashMap<>(); | ||
map.put("otp", "123456"); | ||
response.setResponse(map); | ||
Mockito.when(restHelper.requestSync(Mockito.any())).thenReturn(response); | ||
Mockito.when(otpManager.sendOtp(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), | ||
Mockito.any())).thenReturn(true); | ||
otpServiceImpl.generateOtp(otpRequestDto, "1234567890", new TestObjectWithMetadata()); | ||
} | ||
|
||
@Test | ||
public void TestPhoneorEmailisNull_both_channels_provided() throws IdAuthenticationBusinessException, RestServiceException { | ||
OtpRequestDTO otpRequestDto = new OtpRequestDTO(); | ||
otpRequestDto.setId("id"); | ||
otpRequestDto.setRequestTime(new SimpleDateFormat(EnvUtil.getDateTimePattern()).format(new Date())); | ||
otpRequestDto.setTransactionID("1234567890"); | ||
List<String> channelList = List.of("PHONE", "EMAIL"); | ||
otpRequestDto.setOtpChannel(channelList); | ||
String individualId = "2345678901234"; | ||
otpRequestDto.setIndividualId(individualId); | ||
otpRequestDto.setIndividualIdType(IdType.UIN.getType()); | ||
otpRequestDto.setRequestTime("2019-02-18T18:17:48.923+05:30"); | ||
Map<String, Object> valueMap = new HashMap<>(); | ||
Map<String, List<IdentityInfoDTO>> idInfo = new HashMap<>(); | ||
List<IdentityInfoDTO> mailList = new ArrayList<>(); | ||
IdentityInfoDTO identityInfoDTO = new IdentityInfoDTO(); | ||
identityInfoDTO.setValue("[email protected]"); | ||
mailList.add(identityInfoDTO); | ||
List<IdentityInfoDTO> phoneList = new ArrayList<>(); | ||
IdentityInfoDTO identityInfoDTO1 = new IdentityInfoDTO(); | ||
identityInfoDTO1.setValue("9876543210"); | ||
phoneList.add(identityInfoDTO1); | ||
idInfo.put("email", mailList); | ||
idInfo.put("mobile", phoneList); | ||
valueMap.put("uin", "426789089018"); | ||
valueMap.put("phone", "426789089018"); | ||
valueMap.put("response", idInfo); | ||
Mockito.when(idAuthService.processIdType(Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anySet())) | ||
.thenReturn(valueMap); | ||
|
@@ -303,7 +400,13 @@ public void TestPhoneorEmailisNull() throws IdAuthenticationBusinessException, R | |
|
||
Mockito.when(restHelper.requestSync(Mockito.any())).thenThrow(new RestServiceException( | ||
IdRepoErrorConstants.CLIENT_ERROR, response.toString(), response)); | ||
otpServiceImpl.generateOtp(otpRequestDto, "1234567890", new TestObjectWithMetadata()); | ||
try { | ||
otpServiceImpl.generateOtp(otpRequestDto, "1234567890", new TestObjectWithMetadata()); | ||
Assert.fail(); | ||
} catch (IdAuthenticationBusinessException ex) { | ||
assertEquals(IdAuthenticationErrorConstants.OTP_GENERATION_FAILED.getErrorCode(), ex.getErrorCode()); | ||
assertEquals(IdAuthenticationErrorConstants.OTP_GENERATION_FAILED.getErrorMessage() + ". Both Phone Number and Email ID are not found in identity data.", ex.getErrorText()); | ||
} | ||
} | ||
|
||
@Test(expected = IdAuthenticationBusinessException.class) | ||
|
@@ -363,7 +466,7 @@ private OtpRequestDTO getOtpRequestDTO() { | |
// otpRequestDto.setRequestTime(new SimpleDateFormat(env.getDateTimePattern()).format(new Date())); | ||
otpRequestDto.setTransactionID("1234567890"); | ||
ArrayList<String> channelList = new ArrayList<String>(); | ||
channelList.add("MOBILE"); | ||
channelList.add("PHONE"); | ||
channelList.add("EMAIL"); | ||
otpRequestDto.setOtpChannel(channelList); | ||
otpRequestDto.setIndividualId("2345678901234"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters