-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a better filter for IMDS.getEntry
Updated InMemoryDirectoryServer.getEntry to use a filter of "(&)" instead of "(objectClass=*)" when searching for the specified entry. This should be logically equivalent in the vast majority of cases, but there may be a difference in a corner case in which the server is configured without schema and you add an entry without the objectClass attribute.
- Loading branch information
Showing
2 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
tests/unit/src/com/unboundid/ldap/listener/InMemoryDirectoryServerAddEmptyEntryTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2023 Ping Identity Corporation | ||
* All Rights Reserved. | ||
*/ | ||
/* | ||
* Copyright 2023 Ping Identity Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/* | ||
* Copyright (C) 2023 Ping Identity Corporation | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License (GPLv2 only) | ||
* or the terms of the GNU Lesser General Public License (LGPLv2.1 only) | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, see <http://www.gnu.org/licenses>. | ||
*/ | ||
package com.unboundid.ldap.listener; | ||
|
||
|
||
|
||
import org.testng.annotations.Test; | ||
|
||
import com.unboundid.ldap.sdk.Entry; | ||
import com.unboundid.ldap.sdk.LDAPResult; | ||
import com.unboundid.ldap.sdk.LDAPSDKTestCase; | ||
import com.unboundid.ldap.sdk.ResultCode; | ||
import com.unboundid.ldap.sdk.SearchResultEntry; | ||
|
||
|
||
|
||
/** | ||
* This class provides a test that examines the behavior of the in-memory | ||
* directory server when an entry with no attributes is added and then | ||
* retrieved. | ||
*/ | ||
public final class InMemoryDirectoryServerAddEmptyEntryTestCase | ||
extends LDAPSDKTestCase | ||
{ | ||
/** | ||
* Tests the behavior when trying to add and retrieve an empty entry. | ||
* | ||
* @throws Exception If an unexpected problem occurs. | ||
*/ | ||
@Test() | ||
public void testAddAndRetrieveEmptyEntry() | ||
throws Exception | ||
{ | ||
// Create an in-memory directory server instance without any schema. | ||
final InMemoryDirectoryServerConfig cfg = | ||
new InMemoryDirectoryServerConfig("dc=example,dc=com"); | ||
cfg.setSchema(null); | ||
|
||
final InMemoryDirectoryServer ds = new InMemoryDirectoryServer(cfg); | ||
|
||
|
||
// Try to add an empty "dc=example,dc=com" entry. | ||
final Entry emptyEntry = new Entry("dc=example,dc=com"); | ||
final LDAPResult addResult = ds.add(emptyEntry); | ||
assertResultCodeEquals(addResult, ResultCode.SUCCESS); | ||
|
||
final SearchResultEntry searchEntry = ds.getEntry("dc=example,dc=com"); | ||
assertNotNull(searchEntry); | ||
assertDNsEqual(searchEntry.getDN(), "dc=example,dc=com"); | ||
} | ||
} |