diff --git a/esignet-integration-api/src/test/java/io/mosip/esignet/api/validator/ValidatorTest.java b/esignet-integration-api/src/test/java/io/mosip/esignet/api/validator/ValidatorTest.java index 243d9b372..42289b657 100644 --- a/esignet-integration-api/src/test/java/io/mosip/esignet/api/validator/ValidatorTest.java +++ b/esignet-integration-api/src/test/java/io/mosip/esignet/api/validator/ValidatorTest.java @@ -128,9 +128,9 @@ public void authChallengeFactorFormatValidator_invalidFactoFormat_thenFail() { public void authChallengeFactorFormatValidator_withKBIAuthFactor_thenPass() { ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"objectMapper",new ObjectMapper()); ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"idField","individualId"); - List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","") - ,Map.of("id","fullName","type","","format","","regex","") - , Map.of("id","dateOfBirth","type","date","format","yyyy-MM-dd","regex","")); + List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","^\\d+$") + ,Map.of("id","fullName","type","","format","","regex","^[\\p{L} .'-]+$") + , Map.of("id","dateOfBirth","type","date","format","yyyy-MM-dd","regex","^(\\\\d{4})-(\\\\d{2})-(\\\\d{2})$")); ReflectionTestUtils.setField(authChallengeFactorFormatValidator, "fieldDetailList", fieldDetailList); AuthChallenge authChallenge = new AuthChallenge(); authChallenge.setAuthFactorType("KBI"); @@ -147,9 +147,9 @@ public void authChallengeFactorFormatValidator_withKBIAuthFactor_thenPass() { public void authChallengeFactorFormatValidator_withInvalidKBIChallenge_thenFail() { ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"objectMapper",new ObjectMapper()); ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"idField","individualId"); - List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","") - ,Map.of("id","fullName","type","","format","","regex","") - , Map.of("id","dateOfBirth","type","date","format","yyyy-MM-dd","regex","")); + List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","^\\d+$") + ,Map.of("id","fullName","type","","format","","regex","^[\\p{L} .'-]+$") + , Map.of("id","dateOfBirth","type","date","format","yyyy-MM-dd","regex","^(\\\\d{4})-(\\\\d{2})-(\\\\d{2})$")); ReflectionTestUtils.setField(authChallengeFactorFormatValidator, "fieldDetailList", fieldDetailList); AuthChallenge authChallenge = new AuthChallenge(); authChallenge.setAuthFactorType("KBI"); @@ -166,9 +166,9 @@ public void authChallengeFactorFormatValidator_withInvalidKBIChallenge_thenFail( public void authChallengeFactorFormatValidator_withKBIInvalidRegex_thenFail() { ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"objectMapper",new ObjectMapper()); ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"idField","individualId"); - List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","") - ,Map.of("id","fullName","type","text","format","","regex","") - , Map.of("id","dob","type","text","format","yyyy-MM-dd","regex","")); + List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","^\\d+$") + ,Map.of("id","fullName","type","text","format","","regex","^\\d+$") + , Map.of("id","dob","type","text","format","yyyy-MM-dd","regex","^\\d+$")); ReflectionTestUtils.setField(authChallengeFactorFormatValidator, "fieldDetailList", fieldDetailList); AuthChallenge authChallenge = new AuthChallenge(); authChallenge.setAuthFactorType("KBI"); @@ -185,9 +185,9 @@ public void authChallengeFactorFormatValidator_withKBIInvalidRegex_thenFail() { public void authChallengeFactorFormatValidator_withEmptyName_thenFail() { ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"objectMapper",new ObjectMapper()); ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"idField","individualId"); - List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","") - ,Map.of("id","fullName","type","text","format","","regex","") - , Map.of("id","dob","type","text","format","yyyy-MM-dd","regex","")); + List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","^\\d+$") + ,Map.of("id","fullName","type","text","format","","regex","^[\\p{L} .'-]+$") + , Map.of("id","dob","type","text","format","yyyy-MM-dd","regex","^(\\\\d{4})-(\\\\d{2})-(\\\\d{2})$")); ReflectionTestUtils.setField(authChallengeFactorFormatValidator, "fieldDetailList", fieldDetailList); AuthChallenge authChallenge = new AuthChallenge(); authChallenge.setAuthFactorType("KBI"); @@ -204,9 +204,9 @@ public void authChallengeFactorFormatValidator_withEmptyName_thenFail() { public void authChallengeFactorFormatValidator_withMaximumLength_thenFail1() { ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"objectMapper",new ObjectMapper()); ReflectionTestUtils.setField(authChallengeFactorFormatValidator,"idField","individualId"); - List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","") - ,Map.of("id","fullName","type","text","format","","regex","","maxLength","10") - , Map.of("id","dob","type","text","format","yyyy-MM-dd","regex","")); + List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string","regex","^\\d+$") + ,Map.of("id","fullName","type","text","format","","regex","^[\\p{L} .'-]+$","maxLength","10") + , Map.of("id","dob","type","text","format","yyyy-MM-dd","regex","^(\\\\d{4})-(\\\\d{2})-(\\\\d{2})$")); ReflectionTestUtils.setField(authChallengeFactorFormatValidator, "fieldDetailList", fieldDetailList); AuthChallenge authChallenge = new AuthChallenge(); authChallenge.setAuthFactorType("KBI");