| | |
| | | |
| | | private static final Map<String,String> DN_TO_PW; |
| | | static { |
| | | Map<String,String> dnToPw = new HashMap<String,String>(); |
| | | Map<String,String> dnToPw = new HashMap<>(); |
| | | dnToPw.put(DIR_MGR_DN, DIR_MGR_PW); |
| | | dnToPw.put(ADMIN_DN, ADMIN_PW); |
| | | dnToPw.put(ANNONYMOUS_DN, ANNONYMOUS_PW); |
| | |
| | | public Object[][] validBasisOfValidityTests() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | List<String> acis = new ArrayList<String>(); |
| | | List<String> acis = new ArrayList<>(); |
| | | for (String[] aciAndMask: INVALID_ACIS_IF_ANY_CHAR_REMOVED) { |
| | | acis.add("aci: " + aciAndMask[0]); |
| | | } |
| | |
| | | public Object[][] invalidAcis() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | List<String> invalid = new ArrayList<String>(Arrays.asList(INVALID_ACIS)); |
| | | List<String> invalid = new ArrayList<>(Arrays.asList(INVALID_ACIS)); |
| | | for (String[] aciAndMask: INVALID_ACIS_IF_ANY_CHAR_REMOVED) { |
| | | invalid.addAll(getAciMissingCharCombos(aciAndMask[0], aciAndMask[1])); |
| | | } |
| | |
| | | * is only removed if the corresponding mask character is a - or \" |
| | | */ |
| | | protected List<String> getAciMissingCharCombos(String aci, String mask) { |
| | | List <String> acisMissingOneChar = new ArrayList<String>(); |
| | | List <String> acisMissingOneChar = new ArrayList<>(); |
| | | for (int i = 0; i < aci.length(); i++) { |
| | | // Add this test only if the mask tells us we haven't seen it before. |
| | | // Also guard against ArrayIndexOutOfBoundsExceptions in case the |
| | |
| | | |
| | | /** Common between validAcis and invalidAcis. */ |
| | | private Object[][] buildAciValidationParams(List<String> acis, boolean testMultipleCombos) { |
| | | List<String[]> paramsList = new ArrayList<String[]>(); |
| | | List<String[]> paramsList = new ArrayList<>(); |
| | | |
| | | for (String aci: acis) { |
| | | List<String> aciLdifs = new ArrayList<String>(); |
| | | List<String> aciLdifs = new ArrayList<>(); |
| | | |
| | | // aci set in Add |
| | | aciLdifs.add(TestCaseUtils.makeLdif( |
| | |
| | | public Object[][] invalidAcisMultiCombos() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | List<String> invalid = new ArrayList<String>(); |
| | | List<String> invalid = new ArrayList<>(); |
| | | invalid.add(INVALID_ACIS[0]); |
| | | invalid.add(INVALID_ACIS[1]); |
| | | |
| | |
| | | // * Who sets the ACIs to start with |
| | | // * Whether the entries were created with the ACIs or they were added later. LDIFModify would work here. |
| | | |
| | | private static List<SearchTestParams> SEARCH_TEST_PARAMS = new ArrayList<SearchTestParams>(); |
| | | private static List<SearchTestParams> SEARCH_TEST_PARAMS = new ArrayList<>(); |
| | | private static SearchTestParams registerNewTestParams(String initialDitLdif, String... aciLdif) { |
| | | SearchTestParams testParams = new SearchTestParams(initialDitLdif, aciLdif); |
| | | SEARCH_TEST_PARAMS.add(testParams); |
| | |
| | | |
| | | public String[] getLdapSearchArgs() |
| | | { |
| | | final List<String> args = new ArrayList<String>(); |
| | | final List<String> args = new ArrayList<>(); |
| | | |
| | | if (_bindDn.equals(ANNONYMOUS_DN)) |
| | | { |
| | |
| | | /** ACIs that will produce the same search results for the above DIT. */ |
| | | private final List<String> _equivalentAciLdifs; |
| | | |
| | | private final List<SingleSearchParams> _searchTests = new ArrayList<SingleSearchParams>(); |
| | | private final List<SingleSearchParams> _searchTests = new ArrayList<>(); |
| | | |
| | | public SearchTestParams(String initialDitLdif, String... equivalentAciLdifs) { |
| | | _initialDitLdif = initialDitLdif; |
| | |
| | | ByteArrayOutputStream updatedEntriesStream = new ByteArrayOutputStream(); |
| | | LDIFWriter ldifWriter = new LDIFWriter(new LDIFExportConfig(updatedEntriesStream)); |
| | | |
| | | List<LocalizableMessage> errors = new ArrayList<LocalizableMessage>(); |
| | | List<LocalizableMessage> errors = new ArrayList<>(); |
| | | LDIFModify.modifyLDIF(baseReader, changesReader, ldifWriter, errors); |
| | | Assert.assertTrue(errors.isEmpty(), "Unexpected errors applying LDIF changes: " + errors); |
| | | ldifWriter.flush(); |
| | |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | try { |
| | | List<Object[]> allTestParams = new ArrayList<Object[]>(); |
| | | List<Object[]> allTestParams = new ArrayList<>(); |
| | | |
| | | for (SearchTestParams testParams: SEARCH_TEST_PARAMS) { |
| | | for (SingleSearchParams singleTest: testParams._searchTests) { |
| | |
| | | throws Exception { |
| | | File tempFile = getTemporaryLdifFile(); |
| | | TestCaseUtils.writeFile(tempFile, ldif); |
| | | ArrayList<String> argList=new ArrayList<String>(20); |
| | | ArrayList<String> argList=new ArrayList<>(20); |
| | | argList.add("-h"); |
| | | argList.add("127.0.0.1"); |
| | | argList.add("-p"); |
| | |
| | | return COMMENTS_REGEX.matcher(ldif).replaceAll(""); |
| | | } |
| | | |
| | | private static ThreadLocal<Map<String,File>> _tempLdifFilesByName = new ThreadLocal<Map<String,File>>(); |
| | | private static ThreadLocal<Map<String,File>> _tempLdifFilesByName = new ThreadLocal<>(); |
| | | |
| | | /** |
| | | * To avoid a proliferation of temporary files, use the same ones over and over. |
| | |
| | | private File getTemporaryLdifFile(String name) throws IOException { |
| | | Map<String,File> tempFilesForThisThread = _tempLdifFilesByName.get(); |
| | | if (tempFilesForThisThread == null) { |
| | | tempFilesForThisThread = new HashMap<String,File>(); |
| | | tempFilesForThisThread = new HashMap<>(); |
| | | _tempLdifFilesByName.set(tempFilesForThisThread); |
| | | } |
| | | File tempFile = tempFilesForThisThread.get(name); |
| | |
| | | } |
| | | |
| | | private static String getNotThisDayOfWeek() { |
| | | Set<String> otherDays = new HashSet<String>(Arrays.asList(DAYS_OF_WEEK)); |
| | | Set<String> otherDays = new HashSet<>(Arrays.asList(DAYS_OF_WEEK)); |
| | | otherDays.remove(getThisDayOfWeek()); |
| | | String dayList = ""; |
| | | for (String otherDay: otherDays) { |