@@ -34,7 +34,7 @@ public class LegacyKeyMigrationFilterTest {
3434 private static List <Metadata > apply (LegacyKeyMigrationFilter f , Metadata m ) throws Exception {
3535 List <Metadata > list = new ArrayList <>();
3636 list .add (m );
37- f .filter (list ); // public entry sets the trusted bracket
37+ f .filter (list );
3838 return list ;
3939 }
4040
@@ -59,11 +59,9 @@ public void egressWritesReservedTarget() throws Exception {
5959 var f = new LegacyKeyMigrationFilter (
6060 Map .of ("X-TIKA:Parsed-By" , "tk:parsed-by" ), Direction .V4_TO_V3 );
6161 Metadata m = new Metadata ();
62- // Post-4.0 tk: is reserved too, so seed it the trusted way a parse would (a raw String set
63- // to a reserved key is dropped by the guard); the point of the test is the X-TIKA: target.
64- m .setTrusted (true );
65- m .set ("tk:parsed-by" , "org.apache.tika.parser.DefaultParser" );
66- m .setTrusted (false );
62+ // Post-4.0 tk: is reserved too, so seed it with a trusted write (a plain String set to a
63+ // reserved key is dropped by the guard); the point of the test is the X-TIKA: target.
64+ m .setTrusted ("tk:parsed-by" , "org.apache.tika.parser.DefaultParser" );
6765 apply (f , m );
6866 assertEquals ("org.apache.tika.parser.DefaultParser" , m .get ("X-TIKA:Parsed-By" ));
6967 assertNull (m .get ("tk:parsed-by" ));
@@ -107,9 +105,7 @@ public void loadsBundledTableAndRewritesRealKeys() throws Exception {
107105 // default ctor loads the committed metadata-migration-3x-4x.json; egress (V4_TO_V3).
108106 LegacyKeyMigrationFilter f = new LegacyKeyMigrationFilter ();
109107 Metadata m = new Metadata ();
110- m .setTrusted (true );
111- m .set ("tk:content" , "hello" ); // reserved 4.x key -> X-TIKA:content
112- m .setTrusted (false );
108+ m .setTrusted ("tk:content" , "hello" ); // reserved 4.x key -> X-TIKA:content
113109 m .set ("message:from-email" , "a@b.com" ); // non-reserved 4.x key -> Message:From-Email
114110 apply (f , m );
115111 assertEquals ("hello" , m .get ("X-TIKA:content" ));
@@ -122,11 +118,9 @@ public void digestPrefixRuleEgress() throws Exception {
122118 // digest keys have no declaring field, so not in the flat table -> handled by the prefix rule.
123119 var f = new LegacyKeyMigrationFilter (Map .of (), Direction .V4_TO_V3 );
124120 Metadata m = new Metadata ();
125- m .setTrusted (true );
126- m .set ("tk:digest:SHA-256" , "abc" );
127- m .set ("tk:digest:SHA-256:BASE32" , "def" ); // encoding suffix preserved
128- m .set ("tk:digest:MD5" , "ghi" ); // MD5 unchanged between 3.x/4.x
129- m .setTrusted (false );
121+ m .setTrusted ("tk:digest:SHA-256" , "abc" );
122+ m .setTrusted ("tk:digest:SHA-256:BASE32" , "def" ); // encoding suffix preserved
123+ m .setTrusted ("tk:digest:MD5" , "ghi" ); // MD5 unchanged between 3.x/4.x
130124 apply (f , m );
131125 assertEquals ("abc" , m .get ("X-TIKA:digest:SHA256" ));
132126 assertEquals ("def" , m .get ("X-TIKA:digest:SHA256:BASE32" ));
@@ -138,9 +132,7 @@ public void digestPrefixRuleEgress() throws Exception {
138132 public void digestPrefixRuleIngest () throws Exception {
139133 var f = new LegacyKeyMigrationFilter (Map .of (), Direction .V3_TO_V4 );
140134 Metadata m = new Metadata ();
141- m .setTrusted (true );
142- m .set ("X-TIKA:digest:SHA3_512" , "z" );
143- m .setTrusted (false );
135+ m .setTrusted ("X-TIKA:digest:SHA3_512" , "z" );
144136 apply (f , m );
145137 assertEquals ("z" , m .get ("tk:digest:SHA3-512" ));
146138 assertNull (m .get ("X-TIKA:digest:SHA3_512" ));
0 commit comments