Browse Source

Fixed one character fd-account support

main
Christian Pape 3 weeks ago
committed by Dustin Frisch
parent
commit
4b4b76543b
No known key found for this signature in database GPG Key ID: B4C3BF012D9B26BE
  1. 4
      src/main/java/de/hsfulda/informatik/LdapSync.java
  2. 14
      src/test/java/de/hsfulda/informatik/LdapSyncTest.java

4
src/main/java/de/hsfulda/informatik/LdapSync.java

@ -25,7 +25,7 @@ import java.util.stream.Collectors;
*/ */
public class LdapSync { public class LdapSync {
private final Properties properties = new Properties(); private final Properties properties = new Properties();
private final static Pattern legacyPattern = Pattern.compile("^fd([a-z][a-z])?([0-9]*?)$");
private final static Pattern legacyPattern = Pattern.compile("^fd([a-z][a-z]?)?([0-9]*?)$");
private final static Pattern newPattern = Pattern.compile("^fd([0-9][0-9][0-9][0-9][0-9][0-9][0-9])$"); private final static Pattern newPattern = Pattern.compile("^fd([0-9][0-9][0-9][0-9][0-9][0-9][0-9])$");
private final static Pattern newGuestPattern = Pattern.compile("^fdg([0-9][0-9][0-9][0-9][0-9])$"); private final static Pattern newGuestPattern = Pattern.compile("^fdg([0-9][0-9][0-9][0-9][0-9])$");
private Map<String, Integer> userDefinedMappings = Collections.emptyMap(); private Map<String, Integer> userDefinedMappings = Collections.emptyMap();
@ -173,8 +173,10 @@ public class LdapSync {
if (m.group(1) != null) { if (m.group(1) != null) {
a = m.group(1).charAt(0) - 96; a = m.group(1).charAt(0) - 96;
if (m.group(1).length()>1) {
b = m.group(1).charAt(1) - 96; b = m.group(1).charAt(1) - 96;
} }
}
final int s = m.group(2).length(); final int s = m.group(2).length();
final int z = Integer.parseInt(m.group(2)); final int z = Integer.parseInt(m.group(2));

14
src/test/java/de/hsfulda/informatik/LdapSyncTest.java

@ -30,6 +30,7 @@ public class LdapSyncTest {
remoteEntries.add(searchResultEntry("dn=fDai1235,dc=remote,dc=de", "FDai1235", "Schuster", "Schuster")); remoteEntries.add(searchResultEntry("dn=fDai1235,dc=remote,dc=de", "FDai1235", "Schuster", "Schuster"));
remoteEntries.add(searchResultEntry("dn=fdaI1236,dc=remote,dc=de", "fdAI1236", "Bunsen", "Bunsen")); remoteEntries.add(searchResultEntry("dn=fdaI1236,dc=remote,dc=de", "fdAI1236", "Bunsen", "Bunsen"));
remoteEntries.add(searchResultEntry("dn=fDeT123,dc=remote,dc=de", "FDET123", "Bauer", "Bauer")); remoteEntries.add(searchResultEntry("dn=fDeT123,dc=remote,dc=de", "FDET123", "Bauer", "Bauer"));
remoteEntries.add(searchResultEntry("dn=fdw9424,dc=remote,dc=de", "fdw9424", "Hein", "Bloed"));
remoteEntries.add(searchResultEntry("dn=fdXx9999,dc=remote,dc=de", "fdxX9999", "Schmidt", "Schmidt")); remoteEntries.add(searchResultEntry("dn=fdXx9999,dc=remote,dc=de", "fdxX9999", "Schmidt", "Schmidt"));
final AccountSource remote = new AccountSource("dc=remote,dc=de", remoteEntries); final AccountSource remote = new AccountSource("dc=remote,dc=de", remoteEntries);
@ -55,7 +56,7 @@ public class LdapSyncTest {
assertTrue(delSet.contains("fdai1237")); assertTrue(delSet.contains("fdai1237"));
assertTrue(delSet.contains("fdai1238")); assertTrue(delSet.contains("fdai1238"));
assertEquals(addList.size(), 4);
assertEquals(5, addList.size());
for (final Entry entry : addList) { for (final Entry entry : addList) {
assertTrue(entry.getDN().endsWith(",dc=local,dc=de")); assertTrue(entry.getDN().endsWith(",dc=local,dc=de"));
@ -116,14 +117,17 @@ public class LdapSyncTest {
mappings = LdapSync.parseUserDefinedMappings("fdg00244:300000244"); mappings = LdapSync.parseUserDefinedMappings("fdg00244:300000244");
assertEquals(300000244, (int) LdapSync.computeUid("fdg00244", mappings)); assertEquals(300000244, (int) LdapSync.computeUid("fdg00244", mappings));
assertEquals(41000, (int) LdapSync.computeUid("fd1000", mappings));
assertEquals(49999, (int) LdapSync.computeUid("fd9999", mappings));
assertEquals(10141000, (int) LdapSync.computeUid("fdaa1000", mappings));
assertEquals(10149999, (int) LdapSync.computeUid("fdaa9999", mappings));
assertEquals( 41000, (int) LdapSync.computeUid("fd1000", mappings));
assertEquals( 49999, (int) LdapSync.computeUid("fd9999", mappings));
assertEquals( 10141000, (int) LdapSync.computeUid("fdaa1000", mappings));
assertEquals(262641000, (int) LdapSync.computeUid("fdzz1000", mappings)); assertEquals(262641000, (int) LdapSync.computeUid("fdzz1000", mappings));
assertEquals( 10041000, (int) LdapSync.computeUid("fda1000", mappings));
assertEquals(260041000, (int) LdapSync.computeUid("fdz1000", mappings));
assertEquals( 10149999, (int) LdapSync.computeUid("fdaa9999", mappings));
assertEquals(262649999, (int) LdapSync.computeUid("fdzz9999", mappings)); assertEquals(262649999, (int) LdapSync.computeUid("fdzz9999", mappings));
assertEquals(300000000, (int) LdapSync.computeUid("fdg00000", mappings)); assertEquals(300000000, (int) LdapSync.computeUid("fdg00000", mappings));
assertEquals(300099999, (int) LdapSync.computeUid("fdg99999", mappings)); assertEquals(300099999, (int) LdapSync.computeUid("fdg99999", mappings));
assertEquals(230049123, (int) LdapSync.computeUid("fdw9123", mappings));
mappings = LdapSync.parseUserDefinedMappings("aaabbb"); mappings = LdapSync.parseUserDefinedMappings("aaabbb");
assertEquals(0, mappings.size()); assertEquals(0, mappings.size());

Loading…
Cancel
Save