Skip to content

Commit 6f74162

Browse files
committed
Test Jackson HashMap in Whitelist
Issue: gh-4889
1 parent 99a0baa commit 6f74162

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/test/java/org/springframework/security/jackson2/SecurityJackson2ModulesTests.java

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.junit.Test;
2727

2828
import java.lang.annotation.*;
29+
import java.util.HashMap;
2930

3031
import static org.assertj.core.api.Assertions.assertThat;
3132
import static org.assertj.core.api.Assertions.fail;
@@ -87,6 +88,14 @@ public void readValueWhenMixinProvidedThenReadsAsSpecificType() throws Exception
8788
assertThat(mapper.readValue(content, Object.class)).isInstanceOf(NotWhitelisted.class);
8889
}
8990

91+
@Test
92+
public void readValueWhenHashMapThenReadsAsSpecificType() throws Exception {
93+
mapper.addMixIn(NotWhitelisted.class, NotWhitelistedMixin.class);
94+
String content = "{\"@class\":\"java.util.HashMap\"}";
95+
96+
assertThat(mapper.readValue(content, Object.class)).isInstanceOf(HashMap.class);
97+
}
98+
9099
@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
91100
@Retention(RetentionPolicy.RUNTIME)
92101
@Documented

0 commit comments

Comments
 (0)