Skip to content

Commit

Permalink
MOSIP-27049 : Sonar Bug Fixes (mosip#550)
Browse files Browse the repository at this point in the history
* MOSIP-25622 : Updated OIDC Client Details For Audit Purpose

Signed-off-by: GOKULRAJ136 <[email protected]>

* Remove Commented Codes

Signed-off-by: GOKULRAJ136 <[email protected]>

* Updated EvenID's

Signed-off-by: GOKULRAJ136 <[email protected]>

* Updated the return type in the controller

Signed-off-by: GOKULRAJ136 <[email protected]>

* Removed Set Items

Signed-off-by: GOKULRAJ136 <[email protected]>

* MOSIP-27049 : Sonar Bug Fixes

Signed-off-by: GOKULRAJ136 <[email protected]>

* fixed the test cases

Signed-off-by: GOKULRAJ136 <[email protected]>

* Update ClientManagementServiceImplTest.java

Signed-off-by: GOKULRAJ136 <[email protected]>

---------

Signed-off-by: GOKULRAJ136 <[email protected]>
Signed-off-by: Gokulraj C <[email protected]>
Signed-off-by: kameshsr <[email protected]>
  • Loading branch information
GOKULRAJ136 authored and kameshsr committed Jun 7, 2024
1 parent e53e7e8 commit cc4038f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ClientDetailUpdateRequest {

@NotNull
@NotBlank
@Pattern(regexp = "^(ACTIVE)|(INACTIVE)$", flags = Pattern.Flag.CASE_INSENSITIVE)
@Pattern(regexp = "(ACTIVE)|(INACTIVE)", flags = Pattern.Flag.CASE_INSENSITIVE)
private String status;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class UpdateClientRequestDto {
private List<@NotBlank String> redirectUris;

@NotBlank
@Pattern(regexp = "^(ACTIVE)|(INACTIVE)$")
@Pattern(regexp = "(ACTIVE)|(INACTIVE)")
private String status;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import javax.validation.constraints.NotNull;

@Service
public class ClientManagementServiceImpl implements ClientManagementService {

Expand Down Expand Up @@ -229,8 +231,8 @@ public ClientDetailResponse createOIDCClient(ClientDetailCreateRequest createReq
* @return
* @throws Exception
*/
private static Set<String> getReqAttributeFromPolicyJson(JSONObject policyObject, String parentAttribute,
String childAttribute, String filterAttribute) {
private static Set<String> getReqAttributeFromPolicyJson(@NotNull JSONObject policyObject, String parentAttribute,
String childAttribute, String filterAttribute) {
Set<String> attributes = new HashSet<>();
JSONArray parentAttributeObject = (JSONArray) policyObject.get(parentAttribute);
for (int i = 0; i < parentAttributeObject.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import java.time.ZoneId;
import java.util.*;


import io.mosip.pms.device.util.AuditUtil;
import io.mosip.pms.oidc.client.contant.ClientServiceAuditEnum;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.mosip.pms.common.constant.EventType;
import io.mosip.pms.common.dto.ClientPublishDto;
Expand Down Expand Up @@ -86,13 +89,13 @@ public class ClientManagementServiceImplTest {
private AuditUtil auditUtil;

@Mock
private ObjectMapper objectMapper;
private ObjectMapper objectMapper;

@Mock
private WebSubPublisher webSubPublisher;

Map<String, Object> public_key;

Map<String, Object> public_key;

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Expand All @@ -101,7 +104,7 @@ public void setUp() {
ReflectionTestUtils.setField(serviceImpl, "partnerPolicyRequestRepository", partnerPolicyRequestRepository);
ReflectionTestUtils.setField(serviceImpl, "webSubPublisher", webSubPublisher);
ReflectionTestUtils.setField(serviceImpl, "restUtil", restUtil);

public_key = new HashMap<>();
public_key.put("kty","RSA");
public_key.put("e","AQAB");
Expand All @@ -119,7 +122,7 @@ public void createClientTest() throws Exception {
request.setAuthPartnerId("authPartnerId");
List<String> clientAuthMethods = new ArrayList<String>();
clientAuthMethods.add("ClientAuthMethod");
request.setClientAuthMethods(clientAuthMethods);;
request.setClientAuthMethods(clientAuthMethods);
request.setGrantTypes(clientAuthMethods);
request.setLogoUri("https://testcase.pms.net/browse/OIDCClient.png");
request.setRedirectUris(clientAuthMethods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum SearchErrorCode {
INVALID_VALUES("PMS-MSD-391", "Invalid filter values"),
FAILED_TO_FETCH_CLAIMS("PMS-MSD-393","Failed to fetch claims from mapping file"),
FAILED_TO_FETCH_ACRVALUES("PMS-MSD-394","failed to fetch acr values from mapping file"),
INVALID_VALUE_VALUES("PMS-MSD-392", "Both value and values cannot be present");
INVALID_VALUE_VALUES("PMS-MSD-392", "Both value and values cannot be present"),
FAILED_TO_FETCH_AMR("PMS-MSD-395","Failed to fetch AMR's from mapping file");

/**
* The error code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ private Map<String, List<AuthenticationFactor>> getAllAMRs() {
});
} catch (IOException e) {
logger.error("Failed to load / parse amr mappings", e);
return null;
throw new RequestException(SearchErrorCode.FAILED_TO_FETCH_AMR.getErrorCode(),
SearchErrorCode.FAILED_TO_FETCH_AMR.getErrorMessage());
}
}

Expand Down

0 comments on commit cc4038f

Please sign in to comment.