Skip to content

Commit

Permalink
resolved review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Rana <[email protected]>
  • Loading branch information
sacrana0 committed Dec 11, 2024
1 parent 81f6a93 commit 030ba76
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import com.networknt.schema.ValidationMessage;
import io.mosip.esignet.core.exception.EsignetException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;

Expand All @@ -23,13 +24,16 @@
public class ClientAdditionalConfigValidator implements
ConstraintValidator<ClientAdditionalConfig, Map<String, Object>> {

private String schemaUrl = "classpath:additional_config_request_schema.json";
@Value("${mosip.esignet.additional-config.schema.url}")
private String schemaUrl;

private volatile JsonSchema cachedSchema;

private ObjectMapper objectMapper = new ObjectMapper();
@Autowired
private ObjectMapper objectMapper;

private ResourceLoader resourceLoader = new DefaultResourceLoader();
@Autowired
private ResourceLoader resourceLoader;

@Override
public void initialize(ClientAdditionalConfig constraintAnnotation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,13 +794,18 @@ public void test_ClaimSchemaValidator_withInvalidValue_thenFail() throws IOExcep

@Test
public void test_ClientAdditionalConfigValidator_withValidValue_thenPass() {
ReflectionTestUtils.setField(clientAdditionalConfigValidator, "resourceLoader", resourceLoader);
ReflectionTestUtils.setField(clientAdditionalConfigValidator, "objectMapper", mapper);
ReflectionTestUtils.setField(clientAdditionalConfigValidator, "schemaUrl", "classpath:additional_config_request_schema.json");
Map<String, Object> validAdditionalConfig = ClientAdditionalConfigValidatorTestData.getValidAdditionalConfig();
Assert.assertTrue(clientAdditionalConfigValidator.isValid(validAdditionalConfig, null));
}

@Test
public void test_ClientAdditionalConfigValidator_withInvalidValue_thenFail() {

ReflectionTestUtils.setField(clientAdditionalConfigValidator, "resourceLoader", resourceLoader);
ReflectionTestUtils.setField(clientAdditionalConfigValidator, "objectMapper", mapper);
ReflectionTestUtils.setField(clientAdditionalConfigValidator, "schemaUrl", "classpath:additional_config_request_schema.json");
for (Map<String, Object> additionalConfig : ClientAdditionalConfigValidatorTestData.getInvalidAdditionalConfigs()) {
Assert.assertFalse(clientAdditionalConfigValidator.isValid(additionalConfig, null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mosip.esignet.signup-id-token-expire-seconds=1800
mosip.esignet.signup-id-token-audience=mosip-signup-oauth-client

mosip.esignet.claims.schema.url=classpath:/verified_claims_request_schema.json
mosip.esignet.additional-config.schema.url=classpath:additional_config_request_schema.json

## ------------------------------------------ e-Signet binding ---------------------------------------------------------
mosip.esignet.binding.salt-length=16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ mosip.esignet.signup-id-token-audience=mosip-signup-oauth-client

mosip.esignet.host=localhost
mosip.esignet.claims.schema.url=classpath:/verified_claims_request_schema.json
mosip.esignet.additional-config.schema.url=classpath:additional_config_request_schema.json


## ------------------------------------------ e-Signet binding ---------------------------------------------------------
mosip.esignet.binding.salt-length=16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mosip.esignet.signup-id-token-audience=mosip-signup-client


mosip.esignet.claims.schema.url=classpath:/verified_claims_request_schema_test.json
mosip.esignet.additional-config.schema.url=classpath:additional_config_request_schema.json

## ------------------------------------------ e-Signet binding ---------------------------------------------------------

Expand Down

0 comments on commit 030ba76

Please sign in to comment.