Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-27049 : Sonar Bug Fixes #550

Merged
merged 9 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 All @@ -31,6 +34,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -85,13 +89,13 @@ public class ClientManagementServiceImplTest {
private RestUtil restUtil;

@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 @@ -100,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 @@ -118,11 +122,12 @@ 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);
request.setName("ClientName");
Mockito.doNothing().when(auditUtil).setAuditRequestDto(Mockito.any(ClientServiceAuditEnum.class));
try {
serviceImpl.createOIDCClient(request);
}catch (PartnerServiceException e) {
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
Loading