Skip to content

Commit

Permalink
feat: [P4PU-459] added parsing on fiscal code to remove prefix TINIT- (
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksiybozhykntt authored Sep 11, 2024
1 parent 3d92c96 commit 30d6bd7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/it/gov/pagopa/arc/dto/IamUserInfoDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static IamUserInfoDTO map2IamUserInfoDTO(Map<String, Object> attributes)
}

private static String getStringFromMap(Map<String, Object> map, String key) {
return map.containsKey(key) ? map.get(key).toString() : null;
String value = map.containsKey(key) ? map.get(key).toString() : null;
return key.equals("fiscalNumber") && value != null ? value.replaceFirst("TINIT-", "") : value;
}

}
8 changes: 4 additions & 4 deletions src/test/java/it/gov/pagopa/arc/dto/IamUserInfoDTOTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
class IamUserInfoDTOTest {

@Test
public void testMap2IamUserInfoDTO() {
void testMap2IamUserInfoDTO() {
Map<String, Object> attributes = Map.of(
"sub", "123456",
"fiscalNumber", "789012",
"fiscalNumber", "TINIT-PPPPPP01P30P736P",
"familyName", "Polo",
"name", "Marco",
"email", "marco.polo@example.com",
Expand All @@ -21,15 +21,15 @@ public void testMap2IamUserInfoDTO() {
IamUserInfoDTO userInfo = IamUserInfoDTO.map2IamUserInfoDTO(attributes);

assertEquals("123456", userInfo.getUserId());
assertEquals("789012", userInfo.getFiscalCode());
assertEquals("PPPPPP01P30P736P", userInfo.getFiscalCode());
assertEquals("Polo", userInfo.getFamilyName());
assertEquals("Marco", userInfo.getName());
assertEquals("marco.polo@example.com", userInfo.getEmail());
assertEquals("issuer", userInfo.getIssuer());
}

@Test
public void testMap2IamUserInfoDTOWithMissingAttributes() {
void testMap2IamUserInfoDTOWithMissingAttributes() {
Map<String, Object> attributes = Map.of(
"sub", "123456"
);
Expand Down

0 comments on commit 30d6bd7

Please sign in to comment.