|
16 | 16 | package net.logstash.logback.mask;
|
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.assertThat;
|
| 19 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
19 | 20 |
|
20 | 21 | import java.io.IOException;
|
21 | 22 | import java.io.InputStream;
|
|
40 | 41 | import com.fasterxml.jackson.databind.MappingJsonFactory;
|
41 | 42 | import com.fasterxml.jackson.databind.node.ObjectNode;
|
42 | 43 | import org.junit.jupiter.api.Test;
|
| 44 | +import org.opentest4j.AssertionFailedError; |
43 | 45 |
|
44 | 46 |
|
45 | 47 | public class MaskingJsonGeneratorDecoratorTest {
|
@@ -276,6 +278,38 @@ public void maskedArray() throws IOException {
|
276 | 278 | "foo/fieldA");
|
277 | 279 | }
|
278 | 280 |
|
| 281 | + @Test |
| 282 | + public void masedArrayByIndex() throws IOException { |
| 283 | + testMaskByPath( |
| 284 | + "{ 'array':[{'foo':'bar' },{'a':'b'}] }", |
| 285 | + "{ 'array':[{'foo':'****'},{'a':'b'}] }", |
| 286 | + "/array/0/foo" |
| 287 | + ); |
| 288 | + |
| 289 | + testMaskByPath( |
| 290 | + "{ 'array':[{'foo':'bar' },{'a':'b' }] }", |
| 291 | + "{ 'array':[{'foo':'bar' },{'a':'****'}] }", |
| 292 | + "/array/1/a" |
| 293 | + ); |
| 294 | + |
| 295 | + |
| 296 | + // Failed tests - see issue #735 |
| 297 | + |
| 298 | + assertThatThrownBy(() -> |
| 299 | + testMaskByPath( |
| 300 | + "{ 'array':['a','b', 'c'] }", |
| 301 | + "{ 'array':['a','****','c'] }", |
| 302 | + "/array/1" |
| 303 | + )).isInstanceOf(AssertionFailedError.class); |
| 304 | + |
| 305 | + assertThatThrownBy(() -> |
| 306 | + testMaskByPath( |
| 307 | + "{ 'array':[{'foo':'bar'},{'a':'b'}] }", |
| 308 | + "{ 'array':['****' ,{'a':'b'}] }", |
| 309 | + "/array/0" |
| 310 | + )).isInstanceOf(AssertionFailedError.class); |
| 311 | + } |
| 312 | + |
279 | 313 | @Test
|
280 | 314 | public void maskedArrayOfObjects() throws IOException {
|
281 | 315 | testMaskByPath(
|
|
0 commit comments