Skip to content

Commit

Permalink
Make NameAwareAttributes#remove Case-insensitive
Browse files Browse the repository at this point in the history
Closes gh-548
  • Loading branch information
jzheaux committed Feb 4, 2022
1 parent 3dbfa05 commit 415cf80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Expand Up @@ -99,7 +99,7 @@ public Attribute put(Attribute attr) {
@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
Expand Down
@@ -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);
}
}

0 comments on commit 415cf80

Please sign in to comment.