Skip to content

Commit da79e61

Browse files
committed
Make NameAwareAttributes#remove Case-insensitive
Closes gh-548
1 parent 2c157ca commit da79e61

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

core/src/main/java/org/springframework/ldap/core/NameAwareAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public Attribute put(Attribute attr) {
9999
@Override
100100
public Attribute remove(String attrID) {
101101
Assert.hasLength(attrID, "Attribute ID must not be empty");
102-
return attributes.remove(attrID);
102+
return attributes.remove(attrID.toLowerCase());
103103
}
104104

105105
@Override
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.springframework.ldap.core;
2+
3+
import org.junit.Test;
4+
5+
import static org.assertj.core.api.Assertions.assertThat;
6+
7+
public class NameAwareAttributesTest {
8+
// gh-548
9+
@Test
10+
public void removeWhenDifferentCaseThenRemoves() {
11+
NameAwareAttributes attributes = new NameAwareAttributes();
12+
attributes.put("myID", "value");
13+
attributes.put("myOtherID", "othervalue");
14+
assertThat(attributes.size()).isEqualTo(2);
15+
assertThat(attributes.get("myid").get()).isEqualTo("value");
16+
assertThat(attributes.get("myID").get()).isEqualTo("value");
17+
18+
attributes.remove("myid");
19+
assertThat(attributes.get("myID")).isNull();
20+
assertThat(attributes.size()).isEqualTo(1);
21+
22+
attributes.remove("myOtherID");
23+
assertThat(attributes.size()).isEqualTo(0);
24+
}
25+
}

0 commit comments

Comments
 (0)