Test Jackson HashMap in Whitelist

Issue: gh-4889
This commit is contained in:
Rob Winch 2018-01-03 16:07:55 -06:00
parent cf97e16379
commit 803cdcf01e
1 changed files with 9 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import org.junit.Before;
import org.junit.Test;
import java.lang.annotation.*;
import java.util.HashMap;
import static org.assertj.core.api.Assertions.*;
@ -84,6 +85,14 @@ public class SecurityJackson2ModulesTests {
assertThat(mapper.readValue(content, Object.class)).isInstanceOf(NotWhitelisted.class);
}
@Test
public void readValueWhenHashMapThenReadsAsSpecificType() throws Exception {
mapper.addMixIn(NotWhitelisted.class, NotWhitelistedMixin.class);
String content = "{\"@class\":\"java.util.HashMap\"}";
assertThat(mapper.readValue(content, Object.class)).isInstanceOf(HashMap.class);
}
@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented