@Test void login() { when(responseUtils.consentCookie(any())).thenReturn(COOKIE); when(paymentService.identifyPayment(anyString(), anyString(), anyBoolean(), anyString(), anyString(), any())).thenReturn(getPaymentWorkflow(PSUIDENTIFIED)); when(xisService.performLoginForConsent(anyString(), anyString(), anyString(), anyString(), any(OpTypeTO.class))).thenReturn(getScaLoginResponse()); when(paymentService.initiatePayment(any(), anyString())).thenReturn(getPaymentWorkflow(PSUIDENTIFIED)); when(xisService.resolvePaymentWorkflow(any())).thenReturn(ResponseEntity.ok(getPaymentAuthorizeResponse(true, true, PSUIDENTIFIED))); ResponseEntity<PaymentAuthorizeResponse> result = controller.login(ENCRYPTED_ID, AUTH_ID, LOGIN, PIN, COOKIE); assertEquals(ResponseEntity.ok(getPaymentAuthorizeResponse(true, true, PSUIDENTIFIED)), result); }
@Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<PaymentAuthorizeResponse> login(String encryptedPaymentId, String authorisationId, String login, String pin, String consentCookieString) { String consentCookie = responseUtils.consentCookie(consentCookieString); PaymentWorkflow workflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.paymentId(), workflow.authId(), OpTypeTO.PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getPaymentResponse().getPayment().getPsuIdDatas()); workflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(workflow.bearerToken()); PaymentWorkflow initiatePaymentWorkflow = paymentService.initiatePayment(workflow, psuId); return xisService.resolvePaymentWorkflow(initiatePaymentWorkflow); }
PISController implements PISApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<PaymentAuthorizeResponse> login(String encryptedPaymentId, String authorisationId, String login, String pin, String consentCookieString) { String consentCookie = responseUtils.consentCookie(consentCookieString); PaymentWorkflow workflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.paymentId(), workflow.authId(), OpTypeTO.PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getPaymentResponse().getPayment().getPsuIdDatas()); workflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(workflow.bearerToken()); PaymentWorkflow initiatePaymentWorkflow = paymentService.initiatePayment(workflow, psuId); return xisService.resolvePaymentWorkflow(initiatePaymentWorkflow); } }
PISController implements PISApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<PaymentAuthorizeResponse> login(String encryptedPaymentId, String authorisationId, String login, String pin, String consentCookieString) { String consentCookie = responseUtils.consentCookie(consentCookieString); PaymentWorkflow workflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.paymentId(), workflow.authId(), OpTypeTO.PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getPaymentResponse().getPayment().getPsuIdDatas()); workflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(workflow.bearerToken()); PaymentWorkflow initiatePaymentWorkflow = paymentService.initiatePayment(workflow, psuId); return xisService.resolvePaymentWorkflow(initiatePaymentWorkflow); }  }
PISController implements PISApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<PaymentAuthorizeResponse> login(String encryptedPaymentId, String authorisationId, String login, String pin, String consentCookieString) { String consentCookie = responseUtils.consentCookie(consentCookieString); PaymentWorkflow workflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.paymentId(), workflow.authId(), OpTypeTO.PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getPaymentResponse().getPayment().getPsuIdDatas()); workflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(workflow.bearerToken()); PaymentWorkflow initiatePaymentWorkflow = paymentService.initiatePayment(workflow, psuId); return xisService.resolvePaymentWorkflow(initiatePaymentWorkflow); }  @Override ResponseEntity<AuthorizeResponse> pisAuth(String redirectId, String encryptedPaymentId, String token); @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") ResponseEntity<PaymentAuthorizeResponse> login(String encryptedPaymentId, String authorisationId, String login, String pin, String consentCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> initiatePayment(
        String encryptedPaymentId, String authorisationId, String consentAndaccessTokenCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> selectMethod(String encryptedPaymentId, String authorisationId,
                                                                 String scaMethodId, String consentAndaccessTokenCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> authrizedPayment(
        String encryptedPaymentId,
        String authorisationId,
        String consentAndaccessTokenCookieString, String authCode); @Override ResponseEntity<PaymentAuthorizeResponse> failPaymentAuthorisation(String encryptedPaymentId, String authorisationId, String cookieString); @Override ResponseEntity<PaymentAuthorizeResponse> pisDone(String encryptedPaymentId, String authorisationId,
                                                            String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String authConfirmationCode); }
PISController implements PISApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<PaymentAuthorizeResponse> login(String encryptedPaymentId, String authorisationId, String login, String pin, String consentCookieString) { String consentCookie = responseUtils.consentCookie(consentCookieString); PaymentWorkflow workflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.paymentId(), workflow.authId(), OpTypeTO.PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getPaymentResponse().getPayment().getPsuIdDatas()); workflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(workflow.bearerToken()); PaymentWorkflow initiatePaymentWorkflow = paymentService.initiatePayment(workflow, psuId); return xisService.resolvePaymentWorkflow(initiatePaymentWorkflow); }  @Override ResponseEntity<AuthorizeResponse> pisAuth(String redirectId, String encryptedPaymentId, String token); @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") ResponseEntity<PaymentAuthorizeResponse> login(String encryptedPaymentId, String authorisationId, String login, String pin, String consentCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> initiatePayment(
        String encryptedPaymentId, String authorisationId, String consentAndaccessTokenCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> selectMethod(String encryptedPaymentId, String authorisationId,
                                                                 String scaMethodId, String consentAndaccessTokenCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> authrizedPayment(
        String encryptedPaymentId,
        String authorisationId,
        String consentAndaccessTokenCookieString, String authCode); @Override ResponseEntity<PaymentAuthorizeResponse> failPaymentAuthorisation(String encryptedPaymentId, String authorisationId, String cookieString); @Override ResponseEntity<PaymentAuthorizeResponse> pisDone(String encryptedPaymentId, String authorisationId,
                                                            String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String authConfirmationCode);  }