@Test void login() { when(ledgersUserMgmt.authorise(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any())).thenReturn(getLoginResponse(PSUIDENTIFIED)); ResponseEntity<AuthorizeResponse> result = controller.login(LOGIN, PIN); assertEquals(getExpectedAuthResponse(PSUIDENTIFIED, Collections.emptyList()), result); }
@Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<AuthorizeResponse> login(String login, String pin) { SCALoginResponseTO loginResponse = ledgersUserMgmt.authorise(login, pin, UserRoleTO.CUSTOMER).getBody(); AuthorizeResponse authResponse = new AuthorizeResponse(); ScaStatusTO scaStatus = prepareAuthResponse(authResponse, Objects.requireNonNull(loginResponse)); BearerTokenTO bearerToken = loginResponse.getBearerToken(); switch (scaStatus) { case PSUIDENTIFIED: authResponse.setScaMethods(loginResponse.getScaMethods()); case FINALISED: case EXEMPTED: case PSUAUTHENTICATED: case SCAMETHODSELECTED: responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); case STARTED: case FAILED: default: responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }
SCAController implements SCAApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<AuthorizeResponse> login(String login, String pin) { SCALoginResponseTO loginResponse = ledgersUserMgmt.authorise(login, pin, UserRoleTO.CUSTOMER).getBody(); AuthorizeResponse authResponse = new AuthorizeResponse(); ScaStatusTO scaStatus = prepareAuthResponse(authResponse, Objects.requireNonNull(loginResponse)); BearerTokenTO bearerToken = loginResponse.getBearerToken(); switch (scaStatus) { case PSUIDENTIFIED: authResponse.setScaMethods(loginResponse.getScaMethods()); case FINALISED: case EXEMPTED: case PSUAUTHENTICATED: case SCAMETHODSELECTED: responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); case STARTED: case FAILED: default: responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } } }
SCAController implements SCAApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<AuthorizeResponse> login(String login, String pin) { SCALoginResponseTO loginResponse = ledgersUserMgmt.authorise(login, pin, UserRoleTO.CUSTOMER).getBody(); AuthorizeResponse authResponse = new AuthorizeResponse(); ScaStatusTO scaStatus = prepareAuthResponse(authResponse, Objects.requireNonNull(loginResponse)); BearerTokenTO bearerToken = loginResponse.getBearerToken(); switch (scaStatus) { case PSUIDENTIFIED: authResponse.setScaMethods(loginResponse.getScaMethods()); case FINALISED: case EXEMPTED: case PSUAUTHENTICATED: case SCAMETHODSELECTED: responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); case STARTED: case FAILED: default: responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }  }
SCAController implements SCAApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<AuthorizeResponse> login(String login, String pin) { SCALoginResponseTO loginResponse = ledgersUserMgmt.authorise(login, pin, UserRoleTO.CUSTOMER).getBody(); AuthorizeResponse authResponse = new AuthorizeResponse(); ScaStatusTO scaStatus = prepareAuthResponse(authResponse, Objects.requireNonNull(loginResponse)); BearerTokenTO bearerToken = loginResponse.getBearerToken(); switch (scaStatus) { case PSUIDENTIFIED: authResponse.setScaMethods(loginResponse.getScaMethods()); case FINALISED: case EXEMPTED: case PSUAUTHENTICATED: case SCAMETHODSELECTED: responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); case STARTED: case FAILED: default: responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }  @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") ResponseEntity<AuthorizeResponse> login(String login, String pin); @Override ResponseEntity<AuthorizeResponse> selectMethod(String scaId, String authorisationId, String methodId, String cookies); @Override ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies); }
SCAController implements SCAApi { @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") public ResponseEntity<AuthorizeResponse> login(String login, String pin) { SCALoginResponseTO loginResponse = ledgersUserMgmt.authorise(login, pin, UserRoleTO.CUSTOMER).getBody(); AuthorizeResponse authResponse = new AuthorizeResponse(); ScaStatusTO scaStatus = prepareAuthResponse(authResponse, Objects.requireNonNull(loginResponse)); BearerTokenTO bearerToken = loginResponse.getBearerToken(); switch (scaStatus) { case PSUIDENTIFIED: authResponse.setScaMethods(loginResponse.getScaMethods()); case FINALISED: case EXEMPTED: case PSUAUTHENTICATED: case SCAMETHODSELECTED: responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); case STARTED: case FAILED: default: responseUtils.removeCookies(response); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }  @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") ResponseEntity<AuthorizeResponse> login(String login, String pin); @Override ResponseEntity<AuthorizeResponse> selectMethod(String scaId, String authorisationId, String methodId, String cookies); @Override ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies);  }