@Test void login_failure() { when(responseUtils.consentCookie(any())).thenReturn(COOKIE); when(paymentService.identifyPayment(anyString(), anyString(), anyBoolean(), anyString(), anyString(), any())).thenReturn(getPaymentWorkflow(PSUIDENTIFIED, RCVD)); assertThrows(AuthorizationException.class, () -> controller.login(ENCRYPTED_ID, AUTH_ID, LOGIN, PIN, COOKIE)); }
@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 cancellationWorkflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); if (cancellationWorkflow.getPaymentStatus().equals(TransactionStatusTO.RCVD.name())) { throw AuthorizationException.builder() .devMessage(String.format("Cancellation of Payment id: %s is not possible thought OnlineBanking as it's status is RECEIVED, cancellation of this payment is only possible though EMBEDDED route", encryptedPaymentId)) .errorCode(AuthErrorCode.LOGIN_FAILED) .build(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, cancellationWorkflow.paymentId(), cancellationWorkflow.authId(), OpTypeTO.CANCEL_PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, cancellationWorkflow.getPaymentResponse().getPayment().getPsuIdDatas()); cancellationWorkflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(cancellationWorkflow.bearerToken()); PaymentWorkflow initiateCancelPaymentWorkflow = paymentService.initiateCancelPayment(cancellationWorkflow, psuId); return xisService.resolvePaymentWorkflow(initiateCancelPaymentWorkflow); }
PisCancellationController implements PisCancellationApi { @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 cancellationWorkflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); if (cancellationWorkflow.getPaymentStatus().equals(TransactionStatusTO.RCVD.name())) { throw AuthorizationException.builder() .devMessage(String.format("Cancellation of Payment id: %s is not possible thought OnlineBanking as it's status is RECEIVED, cancellation of this payment is only possible though EMBEDDED route", encryptedPaymentId)) .errorCode(AuthErrorCode.LOGIN_FAILED) .build(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, cancellationWorkflow.paymentId(), cancellationWorkflow.authId(), OpTypeTO.CANCEL_PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, cancellationWorkflow.getPaymentResponse().getPayment().getPsuIdDatas()); cancellationWorkflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(cancellationWorkflow.bearerToken()); PaymentWorkflow initiateCancelPaymentWorkflow = paymentService.initiateCancelPayment(cancellationWorkflow, psuId); return xisService.resolvePaymentWorkflow(initiateCancelPaymentWorkflow); } }
PisCancellationController implements PisCancellationApi { @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 cancellationWorkflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); if (cancellationWorkflow.getPaymentStatus().equals(TransactionStatusTO.RCVD.name())) { throw AuthorizationException.builder() .devMessage(String.format("Cancellation of Payment id: %s is not possible thought OnlineBanking as it's status is RECEIVED, cancellation of this payment is only possible though EMBEDDED route", encryptedPaymentId)) .errorCode(AuthErrorCode.LOGIN_FAILED) .build(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, cancellationWorkflow.paymentId(), cancellationWorkflow.authId(), OpTypeTO.CANCEL_PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, cancellationWorkflow.getPaymentResponse().getPayment().getPsuIdDatas()); cancellationWorkflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(cancellationWorkflow.bearerToken()); PaymentWorkflow initiateCancelPaymentWorkflow = paymentService.initiateCancelPayment(cancellationWorkflow, psuId); return xisService.resolvePaymentWorkflow(initiateCancelPaymentWorkflow); }  }
PisCancellationController implements PisCancellationApi { @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 cancellationWorkflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); if (cancellationWorkflow.getPaymentStatus().equals(TransactionStatusTO.RCVD.name())) { throw AuthorizationException.builder() .devMessage(String.format("Cancellation of Payment id: %s is not possible thought OnlineBanking as it's status is RECEIVED, cancellation of this payment is only possible though EMBEDDED route", encryptedPaymentId)) .errorCode(AuthErrorCode.LOGIN_FAILED) .build(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, cancellationWorkflow.paymentId(), cancellationWorkflow.authId(), OpTypeTO.CANCEL_PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, cancellationWorkflow.getPaymentResponse().getPayment().getPsuIdDatas()); cancellationWorkflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(cancellationWorkflow.bearerToken()); PaymentWorkflow initiateCancelPaymentWorkflow = paymentService.initiateCancelPayment(cancellationWorkflow, psuId); return xisService.resolvePaymentWorkflow(initiateCancelPaymentWorkflow); }  @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> selectMethod(String encryptedPaymentId, String authorisationId,
                                                                 String scaMethodId, String consentAndAccessTokenCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> authorisePayment(String encryptedPaymentId, String authorisationId,
                                                                     String consentAndAccessTokenCookieString, String authCode); @Override ResponseEntity<PaymentAuthorizeResponse> pisDone(String encryptedPaymentId, String authorisationId,
                                                            String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String authConfirmationCode); }
PisCancellationController implements PisCancellationApi { @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 cancellationWorkflow = paymentService.identifyPayment(encryptedPaymentId, authorisationId, false, consentCookie, login, null); if (cancellationWorkflow.getPaymentStatus().equals(TransactionStatusTO.RCVD.name())) { throw AuthorizationException.builder() .devMessage(String.format("Cancellation of Payment id: %s is not possible thought OnlineBanking as it's status is RECEIVED, cancellation of this payment is only possible though EMBEDDED route", encryptedPaymentId)) .errorCode(AuthErrorCode.LOGIN_FAILED) .build(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, cancellationWorkflow.paymentId(), cancellationWorkflow.authId(), OpTypeTO.CANCEL_PAYMENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, cancellationWorkflow.getPaymentResponse().getPayment().getPsuIdDatas()); cancellationWorkflow.processSCAResponse(Objects.requireNonNull(loginResult.getBody())); if (!AuthUtils.success(loginResult)) { responseUtils.removeCookies(response); return ResponseEntity.status(UNAUTHORIZED).build(); } String psuId = AuthUtils.psuId(cancellationWorkflow.bearerToken()); PaymentWorkflow initiateCancelPaymentWorkflow = paymentService.initiateCancelPayment(cancellationWorkflow, psuId); return xisService.resolvePaymentWorkflow(initiateCancelPaymentWorkflow); }  @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> selectMethod(String encryptedPaymentId, String authorisationId,
                                                                 String scaMethodId, String consentAndAccessTokenCookieString); @Override ResponseEntity<PaymentAuthorizeResponse> authorisePayment(String encryptedPaymentId, String authorisationId,
                                                                     String consentAndAccessTokenCookieString, String authCode); @Override ResponseEntity<PaymentAuthorizeResponse> pisDone(String encryptedPaymentId, String authorisationId,
                                                            String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String authConfirmationCode);  }