Skip to content

Commit

Permalink
modified resumeHaltedTransaction method and end enp-point name from '…
Browse files Browse the repository at this point in the history
…/resume' to '/complete'

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>
  • Loading branch information
Mohd Kaif Siddique committed Sep 20, 2024
1 parent d8ef317 commit 124995d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ public class Constants {

public static final String SERVER_NONCE_SEPARATOR = "~###~";
public static final String RESUMED = "RESUMED";
public static final String RESUME_NOT_APPLICABLE = "RESUME_NOT_APPLICABLE";
public static final String VERIFIED_CLAIMS = "verified_claims";
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ public class ErrorConstants {
public static final String INVALID_VERIFICATION = "invalid_verification";
public static final String INVALID_VERIFIED_CLAIMS = "invalid_verified_claims";
public static final String INVALID_PURPOSE="invalid_purpose";

public static final String RESUME_NOT_APPLICABLE = "resume_not_applicable";
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public ResponseWrapper<SignupRedirectResponse> prepareSignupRedirect(@Valid @Req
return responseWrapper;
}

@PostMapping("/resume")
@PostMapping("/complete")
public ResponseWrapper<ResumeResponse> resumeHaltedTransaction(@Valid @RequestBody RequestWrapper<ResumeRequest> requestWrapper) {
ResponseWrapper<ResumeResponse> responseWrapper = new ResponseWrapper<>();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ public void resumeHaltedTransaction_withValidDetails_thenSuccessResponse() throw
resumeResponse.setStatus("status");
when(authorizationService.resumeHaltedTransaction(resumeRequest)).thenReturn(resumeResponse);

mockMvc.perform(post("/authorization/resume")
mockMvc.perform(post("/authorization/complete")
.content(objectMapper.writeValueAsString(wrapper))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
Expand All @@ -1550,7 +1550,7 @@ public void resumeHaltedTransaction_OnException_thenErrorResponse() throws Excep

when(authorizationService.resumeHaltedTransaction(Mockito.any())).thenThrow(new InvalidTransactionException());

mockMvc.perform(post("/authorization/resume")
mockMvc.perform(post("/authorization/complete")
.content(objectMapper.writeValueAsString(wrapper))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,8 @@ public ResumeResponse resumeHaltedTransaction(ResumeRequest resumeRequest) {
oidcTransaction), null);
return resumeResponse;
}

cacheUtilService.removeHaltedTransaction(resumeRequest.getTransactionId());
resumeResponse.setStatus(Constants.RESUME_NOT_APPLICABLE);
return resumeResponse;
throw new EsignetException(ErrorConstants.RESUME_NOT_APPLICABLE);
}

//As pathFragment is included in the response header, we should sanitize the input to mitigate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1314,16 +1314,19 @@ public void resumeHaltedTransaction_withInvalidTransactionId_thenFail() {
}

@Test
public void resumeHaltedTransaction_withResumeNotApplicable_thenPass() {
public void resumeHaltedTransaction_withStatusAsNotCompleted_thenFail() {
String transactionId = "transactionId";
ResumeRequest resumeRequest = new ResumeRequest();
resumeRequest.setTransactionId(transactionId);
resumeRequest.setWithError(true);
OIDCTransaction oidcTransaction = new OIDCTransaction();
when(cacheUtilService.getHaltedTransaction(transactionId)).thenReturn(oidcTransaction);
when(cacheUtilService.getSharedIDVResult(transactionId)).thenReturn(null);
ResumeResponse result = authorizationServiceImpl.resumeHaltedTransaction(resumeRequest);
Assert.assertEquals(Constants.RESUME_NOT_APPLICABLE, result.getStatus());
when(cacheUtilService.getSharedIDVResult(transactionId)).thenReturn("FAILED");
try{
authorizationServiceImpl.resumeHaltedTransaction(resumeRequest);
}catch (EsignetException ex){
Assert.assertEquals(ErrorConstants.RESUME_NOT_APPLICABLE,ex.getErrorCode());
}
}

@Test
Expand Down

0 comments on commit 124995d

Please sign in to comment.