diff --git a/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java b/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java index 4e0fb34db..844d026b7 100644 --- a/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java +++ b/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java @@ -201,7 +201,7 @@ public io.mosip.esignet.core.dto.ClientDetail getClientDetails(String clientId) @CacheEvict(value = Constants.CLIENT_DETAIL_CACHE, key = "#clientDetailCreateRequestV2.getClientId()") @Override - public ClientDetailResponse createOauthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException { + public ClientDetailResponse createOAuthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException { Optional result = clientDetailRepository.findById(clientDetailCreateRequestV2.getClientId()); if (result.isPresent()) { log.error("Duplicate Client Id : {}", ErrorConstants.DUPLICATE_CLIENT_ID); @@ -224,14 +224,14 @@ public ClientDetailResponse createOauthClient(ClientDetailCreateRequestV2 client } auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OIDC_CLIENT_CREATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientDetailCreateRequestV2.getClientId()), null); + Action.OAUTH_CLIENT_CREATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientDetailCreateRequestV2.getClientId()), null); return getClientDetailResponse(clientDetail); } @CacheEvict(value = Constants.CLIENT_DETAIL_CACHE, key = "#clientId") @Override - public ClientDetailResponse updateOauthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException { + public ClientDetailResponse updateOAuthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException { Optional result = clientDetailRepository.findById(clientId); if (!result.isPresent()) { log.error("Invalid Client Id : {}", ErrorConstants.INVALID_CLIENT_ID); @@ -249,7 +249,7 @@ public ClientDetailResponse updateOauthClient(String clientId, ClientDetailUpdat clientDetail = clientDetailRepository.save(clientDetail); auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OIDC_CLIENT_UPDATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientId), null); + Action.OAUTH_CLIENT_UPDATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientId), null); return getClientDetailResponse(clientDetail); } diff --git a/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java b/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java index 343801f8d..1458eeb61 100644 --- a/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java +++ b/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java @@ -116,7 +116,7 @@ public void createClientV2_withValidDetail_thenPass() throws Exception { entity.setId("mock_id_v1"); entity.setStatus("active"); Mockito.when(clientDetailRepository.save(Mockito.any(ClientDetail.class))).thenReturn(entity); - ClientDetailResponse clientDetailResponse = clientManagementService.createOauthClient(clientCreateV2ReqDto); + ClientDetailResponse clientDetailResponse = clientManagementService.createOAuthClient(clientCreateV2ReqDto); Assert.assertNotNull(clientDetailResponse); Assert.assertTrue(clientDetailResponse.getClientId().equals("mock_id_v1")); Assert.assertTrue(clientDetailResponse.getStatus().equals("active")); @@ -128,7 +128,7 @@ public void createClientV2_withExistingClientId_thenFail() { ClientDetailCreateRequestV2 clientCreateV2ReqDto = new ClientDetailCreateRequestV2(); clientCreateV2ReqDto.setClientId("client_id_v1"); try { - clientManagementService.createOauthClient(clientCreateV2ReqDto); + clientManagementService.createOAuthClient(clientCreateV2ReqDto); } catch (EsignetException ex) { Assert.assertEquals(ex.getErrorCode(), ErrorConstants.DUPLICATE_CLIENT_ID); } @@ -180,7 +180,7 @@ public void updateClient_withValidClientId_thenPass() throws EsignetException { public void updateClientV2_withNonExistingClientId_thenFail() { Mockito.when(clientDetailRepository.findById("client_id_v1")).thenReturn(Optional.empty()); try { - clientManagementService.updateOauthClient("client_id_v1", null); + clientManagementService.updateOAuthClient("client_id_v1", null); } catch (EsignetException ex) { Assert.assertEquals(ex.getErrorCode(), ErrorConstants.INVALID_CLIENT_ID); } @@ -213,7 +213,7 @@ public void updateClientV2_withValidClientId_thenPass() throws EsignetException entity.setId("client_id_v1"); entity.setStatus("inactive"); Mockito.when(clientDetailRepository.save(Mockito.any(ClientDetail.class))).thenReturn(entity); - ClientDetailResponse clientDetailResponse = clientManagementService.updateOauthClient("client_id_v1", updateV2Request); + ClientDetailResponse clientDetailResponse = clientManagementService.updateOAuthClient("client_id_v1", updateV2Request); Assert.assertNotNull(clientDetailResponse); Assert.assertTrue(clientDetailResponse.getClientId().equals("client_id_v1")); Assert.assertTrue(clientDetailResponse.getStatus().equals("inactive")); diff --git a/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java b/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java index f8c30f171..caf27ad07 100644 --- a/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java +++ b/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java @@ -45,7 +45,7 @@ public interface ClientManagementService { * @return * @throws EsignetException */ - ClientDetailResponse createOauthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException; + ClientDetailResponse createOAuthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException; /** * API to update registered relying party client version 2 @@ -59,6 +59,6 @@ public interface ClientManagementService { * @return * @throws EsignetException */ - ClientDetailResponse updateOauthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException; + ClientDetailResponse updateOAuthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException; } diff --git a/esignet-integration-api/src/main/java/io/mosip/esignet/api/util/Action.java b/esignet-integration-api/src/main/java/io/mosip/esignet/api/util/Action.java index 3349d15e4..d7a5af645 100644 --- a/esignet-integration-api/src/main/java/io/mosip/esignet/api/util/Action.java +++ b/esignet-integration-api/src/main/java/io/mosip/esignet/api/util/Action.java @@ -3,6 +3,8 @@ public enum Action { OIDC_CLIENT_CREATE, OIDC_CLIENT_UPDATE, + OAUTH_CLIENT_CREATE, + OAUTH_CLIENT_UPDATE, GET_OAUTH_DETAILS, TRANSACTION_STARTED, SEND_OTP, diff --git a/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java b/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java index 514b1c8f7..4b236022e 100644 --- a/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java +++ b/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java @@ -87,13 +87,13 @@ public ResponseWrapper updateClient(@Valid @PathVariable(" } @PostMapping(value = "/client-mgmt/oauth-client", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseWrapper createOauthClient(@Valid @RequestBody RequestWrapper requestWrapper) throws Exception { + public ResponseWrapper createOAuthClient(@Valid @RequestBody RequestWrapper requestWrapper) throws Exception { ResponseWrapper response = new ResponseWrapper(); try { - response.setResponse(clientManagementService.createOauthClient(requestWrapper.getRequest())); + response.setResponse(clientManagementService.createOAuthClient(requestWrapper.getRequest())); } catch (EsignetException ex) { auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OIDC_CLIENT_CREATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(requestWrapper.getRequest().getClientId()), ex); + Action.OAUTH_CLIENT_CREATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(requestWrapper.getRequest().getClientId()), ex); throw ex; } response.setResponseTime(IdentityProviderUtil.getUTCDateTime()); @@ -102,14 +102,14 @@ public ResponseWrapper createOauthClient(@Valid @RequestBo @PutMapping(value = "/client-mgmt/oauth-client/{client_id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseWrapper updateOauthClient(@Valid @PathVariable("client_id") String clientId, + public ResponseWrapper updateOAuthClient(@Valid @PathVariable("client_id") String clientId, @Valid @RequestBody RequestWrapper requestWrapper) throws Exception { ResponseWrapper response = new ResponseWrapper(); try { - response.setResponse(clientManagementService.updateOauthClient(clientId, requestWrapper.getRequest())); + response.setResponse(clientManagementService.updateOAuthClient(clientId, requestWrapper.getRequest())); } catch (EsignetException ex) { auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OIDC_CLIENT_UPDATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(clientId), ex); + Action.OAUTH_CLIENT_UPDATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(clientId), ex); throw ex; } response.setResponseTime(IdentityProviderUtil.getUTCDateTime());