Skip to content

Commit

Permalink
ES-789 (#79)
Browse files Browse the repository at this point in the history
* add local in request header

Signed-off-by: mengleang-ngoun <[email protected]>
Signed-off-by: Mengleang <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>

* update wording

Signed-off-by: mengleang-ngoun <[email protected]>
Signed-off-by: Mengleang <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>

* resolve conflict

Signed-off-by: mengleang-0090 <[email protected]>

* update test case

Signed-off-by: mengleang-ngoun <[email protected]>
Signed-off-by: Mengleang <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>

* move locale into registration request

Signed-off-by: Mengleang <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>

* front end move locale into request body

Signed-off-by: Mengleang <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>

* Issues with cached methods found during redis integration fixed (#68)

Signed-off-by: ase-101 <[email protected]>

* move locale to req body in Reset password endpoint

Signed-off-by: mengleang-0090 <[email protected]>

* handle locale registerRequest and resetPasswordRequest null

Signed-off-by: mengleang-0090 <[email protected]>

* convert 2 to 3 langCode

Signed-off-by: mengleang-0090 <[email protected]>

* remove locale from header

Signed-off-by: mengleang-0090 <[email protected]>

---------

Signed-off-by: mengleang-ngoun <[email protected]>
Signed-off-by: Mengleang <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>
Signed-off-by: mengleang-0090 <[email protected]>
Signed-off-by: ase-101 <[email protected]>
Co-authored-by: Mengleang <[email protected]>
Co-authored-by: ase-101 <[email protected]>
  • Loading branch information
3 people authored Mar 28, 2024
1 parent 427be63 commit 9dbfed9
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.signup.dto;

import io.mosip.signup.util.ErrorConstants;
import io.mosip.signup.validator.Language;
import io.mosip.signup.validator.Password;
import io.mosip.signup.validator.Username;
import lombok.Data;
Expand All @@ -25,4 +26,7 @@ public class RegisterRequest {

@NotNull(message = ErrorConstants.INVALID_USERINFO)
private @Valid UserInfoMap userInfo;

@Language(required = false)
private String locale;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.signup.dto;

import io.mosip.signup.validator.Identifier;
import io.mosip.signup.validator.Language;
import io.mosip.signup.validator.Password;
import lombok.Data;

Expand All @@ -12,4 +13,7 @@ public class ResetPasswordRequest {

@Password
private String password;

@Language(required = false)
private String locale;
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ public RegisterResponse register(RegisterRequest registerRequest, String transac
transaction.setRegistrationStatus(RegistrationStatus.PENDING);
cacheUtilService.setStatusCheckTransaction(transactionId, transaction);

notificationHelper.sendSMSNotificationAsync(registerRequest.getUserInfo().getPhone(), transaction.getLocale(),
String locale = registerRequest.getLocale() == null ? transaction.getLocale() : registerRequest.getLocale();

notificationHelper.sendSMSNotificationAsync(registerRequest.getUserInfo().getPhone(), locale,
REGISTRATION_SMS_NOTIFICATION_TEMPLATE_KEY, null)
.thenAccept(notificationResponseRestResponseWrapper ->
log.debug(notificationLogging, notificationResponseRestResponseWrapper)
Expand Down Expand Up @@ -324,7 +326,9 @@ public RegistrationStatusResponse updatePassword(ResetPasswordRequest resetPassw
transaction.setRegistrationStatus(RegistrationStatus.PENDING);
cacheUtilService.setStatusCheckTransaction(transactionId, transaction);

notificationHelper.sendSMSNotificationAsync(resetPasswordRequest.getIdentifier(), transaction.getLocale(),
String locale = resetPasswordRequest.getLocale() == null ? transaction.getLocale() : resetPasswordRequest.getLocale();

notificationHelper.sendSMSNotificationAsync(resetPasswordRequest.getIdentifier(), locale,
FORGOT_PASSWORD_SMS_NOTIFICATION_TEMPLATE_KEY, null)
.thenAccept(notificationResponseRestResponseWrapper ->
log.debug(notificationLogging, notificationResponseRestResponseWrapper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.util.List;

import static io.mosip.esignet.core.constants.Constants.UTC_DATETIME_PATTERN;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
Expand Down Expand Up @@ -65,6 +67,8 @@ public class RegistrationControllerTest {
private RequestWrapper verifyRequestWrapper;
private RequestWrapper wrapper;

private String locale;

@Before
public void init() {
generateChallengeRequest = new GenerateChallengeRequest();
Expand Down Expand Up @@ -646,7 +650,7 @@ public void register_thenPass() throws Exception{

RegisterResponse registerResponse = new RegisterResponse();
registerResponse.setStatus(ActionStatus.PENDING);
when(registrationService.register(registerRequest, mockTransactionID)).thenReturn(registerResponse);
when(registrationService.register(eq(registerRequest), eq(mockTransactionID))).thenReturn(registerResponse);

mockMvc.perform(post("/registration/register")
.content(objectMapper.writeValueAsString(wrapper))
Expand Down Expand Up @@ -1012,6 +1016,7 @@ public void register_withInValidFullNameInKhm_returnErrorResponse() throws Excep
registerRequest.setUsername("+85512345678");
registerRequest.setPassword("Password@2023");
registerRequest.setConsent("AGREE");
registerRequest.setLocale(locale);

RequestWrapper<RegisterRequest> wrapper = new RequestWrapper<RegisterRequest>();
wrapper.setRequestTime(IdentityProviderUtil.getUTCDateTime());
Expand Down Expand Up @@ -1057,7 +1062,7 @@ public void register_withValidFullName_returnSuccessResponse() throws Exception{

RegisterResponse registerResponse = new RegisterResponse();
registerResponse.setStatus(ActionStatus.PENDING);
when(registrationService.register(registerRequest, mockTransactionID)).thenReturn(registerResponse);
when(registrationService.register(eq(registerRequest), eq(mockTransactionID))).thenReturn(registerResponse);

mockMvc.perform(post("/registration/register")
.content(objectMapper.writeValueAsString(wrapper))
Expand All @@ -1082,6 +1087,7 @@ public void register_withInvalidPassword_returnErrorResponse() throws Exception{
registerRequest.setUsername("+85512345678");
registerRequest.setPassword("12345678");
registerRequest.setConsent("AGREE");
registerRequest.setLocale(locale);

RequestWrapper<RegisterRequest> wrapper = new RequestWrapper<RegisterRequest>();
wrapper.setRequestTime(IdentityProviderUtil.getUTCDateTime());
Expand Down Expand Up @@ -1119,6 +1125,7 @@ public void register_withBlankPassword_returnErrorResponse() throws Exception{
registerRequest.setUsername("+85512345678");
registerRequest.setConsent("AGREE");
registerRequest.setPassword("");
registerRequest.setLocale(locale);


RequestWrapper<RegisterRequest> wrapper = new RequestWrapper<RegisterRequest>();
Expand Down Expand Up @@ -1156,6 +1163,7 @@ public void register_withNullPassword_returnErrorResponse() throws Exception{
registerRequest.setUserInfo(userInfo);
registerRequest.setUsername("+85512345678");
registerRequest.setConsent("AGREE");
registerRequest.setLocale(locale);


RequestWrapper<RegisterRequest> wrapper = new RequestWrapper<RegisterRequest>();
Expand Down Expand Up @@ -1194,6 +1202,7 @@ public void register_withBlankUsername_returnErrorResponse() throws Exception{
registerRequest.setConsent("AGREE");
registerRequest.setPassword("Password@2023");
registerRequest.setUsername("");
registerRequest.setLocale(locale);

RequestWrapper<RegisterRequest> wrapper = new RequestWrapper<RegisterRequest>();
wrapper.setRequestTime(IdentityProviderUtil.getUTCDateTime());
Expand Down Expand Up @@ -1229,6 +1238,7 @@ public void register_withNullUsername_returnErrorResponse() throws Exception{
registerRequest.setUserInfo(userInfo);
registerRequest.setConsent("AGREE");
registerRequest.setPassword("Password@2023");
registerRequest.setLocale(locale);

RequestWrapper<RegisterRequest> wrapper = new RequestWrapper<RegisterRequest>();
wrapper.setRequestTime(IdentityProviderUtil.getUTCDateTime());
Expand Down Expand Up @@ -1266,6 +1276,7 @@ public void register_withNotMatchUsernameRegex_returnErrorResponse() throws Exce
registerRequest.setConsent("AGREE");
registerRequest.setUsername("+85512345678");
registerRequest.setPassword("Password@2023");
registerRequest.setLocale(locale);

RequestWrapper<RegisterRequest> wrapper = new RequestWrapper<RegisterRequest>();
wrapper.setRequestTime(IdentityProviderUtil.getUTCDateTime());
Expand Down
Loading

0 comments on commit 9dbfed9

Please sign in to comment.