Make NameAwareAttributes#remove Case-insensitive

Closes gh-548
This commit is contained in:
Josh Cummings
2022-02-03 17:56:17 -07:00
parent 2c157cab4c
commit da79e610ea
2 changed files with 26 additions and 1 deletions

View File

@@ -99,7 +99,7 @@ public final class NameAwareAttributes implements Attributes {
@Override
public Attribute remove(String attrID) {
Assert.hasLength(attrID, "Attribute ID must not be empty");
return attributes.remove(attrID);
return attributes.remove(attrID.toLowerCase());
}
@Override

View File

@@ -0,0 +1,25 @@
package org.springframework.ldap.core;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class NameAwareAttributesTest {
// gh-548
@Test
public void removeWhenDifferentCaseThenRemoves() {
NameAwareAttributes attributes = new NameAwareAttributes();
attributes.put("myID", "value");
attributes.put("myOtherID", "othervalue");
assertThat(attributes.size()).isEqualTo(2);
assertThat(attributes.get("myid").get()).isEqualTo("value");
assertThat(attributes.get("myID").get()).isEqualTo("value");
attributes.remove("myid");
assertThat(attributes.get("myID")).isNull();
assertThat(attributes.size()).isEqualTo(1);
attributes.remove("myOtherID");
assertThat(attributes.size()).isEqualTo(0);
}
}