Skip to content

Commit

Permalink
Skip invalid DN into the VO map file
Browse files Browse the repository at this point in the history
An invalid DN can lead to ignore the succeeding entries
Fix for https://issues.infn.it/jira/browse/STOR-1399
  • Loading branch information
enricovianello committed Dec 9, 2024
1 parent 5a357ab commit 202e5e6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ private CSVParser getParser() {
private boolean isValidCSVRecord(CSVRecord r) {

if (r.size() > 3) {
logger.debug("Invalid CSVRecord: {}. Illegal size: {}", r, r.size());
logger.warn("Invalid CSVRecord: {}. Illegal size: {}", r, r.size());
return false;
}

if (!r.get(0).startsWith("/")) {
logger.debug("Invalid CSVRecord: {}. Subject does not start with / : {}",
logger.warn("Invalid CSVRecord: {}. Subject does not start with / : {}",
r, r.get(0));
return false;
}
Expand Down Expand Up @@ -97,7 +97,8 @@ public Set<String> getVOMembers() {
}

if (!isValidCSVRecord(r)) {
break;
/* Fix https://issues.infn.it/jira/browse/STOR-1399 */
continue;
}

String subject = r.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,28 @@

public class VOMSMapTests {

public static final String MY_SUBJECT = "CN=Andrea Ceccanti,L=CNAF,OU=Personal Certificate,O=INFN,C=IT";
@Test
void VOMapParserTest() {

MapfileVOMembershipSource m = new MapfileVOMembershipSource("testers",
new File("src/test/resources/vomsmap/testers.map"));

Assert.assertEquals("testers",m.getVOName());
Assert.assertTrue(m.getVOMembers().contains(MY_SUBJECT));

Assert.assertFalse(m.getVOMembers().contains("CN=I am not Real, L=CNAF"));

}
public static final String AC_SUBJECT =
"CN=Andrea Ceccanti,L=CNAF,OU=Personal Certificate,O=INFN,C=IT";
public static final String EV_SUBJECT =
"CN=Enrico Vianello,L=CNAF,OU=Personal Certificate,O=INFN,C=IT";
public static final String COMMA_SUBJECT =
"CN=Federica Agostini,L=CNAF,Bologna,OU=Personal Certificate,O=INFN,C=IT";
public static final String RM_SUBJECT =
"CN=Roberta Miccoli,L=CNAF,OU=Personal Certificate,O=INFN,C=IT";

@Test
void VOMapParserTest() {

MapfileVOMembershipSource m = new MapfileVOMembershipSource("testers",
new File("src/test/resources/vomsmap/testers.map"));

Assert.assertEquals("testers", m.getVOName());
Assert.assertTrue(m.getVOMembers().contains(AC_SUBJECT));
Assert.assertTrue(m.getVOMembers().contains(EV_SUBJECT));
Assert.assertFalse(m.getVOMembers().contains(COMMA_SUBJECT));
Assert.assertTrue(m.getVOMembers().contains(RM_SUBJECT));
Assert.assertFalse(m.getVOMembers().contains("CN=I am not Real, L=CNAF"));

}

}
4 changes: 3 additions & 1 deletion src/test/resources/vomsmap/testers.map
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/C=IT/O=INFN/OU=Personal Certificate/L=CNAF/CN=Andrea Ceccanti,/C=IT/O=INFN/CN=INFN CA,[email protected]
/C=IT/O=INFN/OU=Personal Certificate/L=CNAF/CN=Enrico Vianello,/C=IT/O=INFN/CN=INFN CA,[email protected]
/C=IT/O=INFN/OU=Personal Certificate/L=CNAF/CN=Enrico Vianello,/C=IT/O=INFN/CN=INFN CA,[email protected]
/C=IT/O=INFN/OU=Personal Certificate/L=CNAF,Bologna/CN=Federica Agostini,/C=IT/O=INFN/CN=INFN CA,[email protected]
/C=IT/O=INFN/OU=Personal Certificate/L=CNAF/CN=Roberta Miccoli,/C=IT/O=INFN/CN=INFN CA,[email protected]

0 comments on commit 202e5e6

Please sign in to comment.