Skip to content

Commit

Permalink
Add test case covering issue #735
Browse files Browse the repository at this point in the history
issue #735
  • Loading branch information
brenuart committed Aug 26, 2022
1 parent a03c402 commit f7d231a
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package net.logstash.logback.mask;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -40,6 +41,7 @@
import com.fasterxml.jackson.databind.MappingJsonFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;


public class MaskingJsonGeneratorDecoratorTest {
Expand Down Expand Up @@ -276,6 +278,38 @@ public void maskedArray() throws IOException {
"foo/fieldA");
}

@Test
public void masedArrayByIndex() throws IOException {
testMaskByPath(
"{ 'array':[{'foo':'bar' },{'a':'b'}] }",
"{ 'array':[{'foo':'****'},{'a':'b'}] }",
"/array/0/foo"
);

testMaskByPath(
"{ 'array':[{'foo':'bar' },{'a':'b' }] }",
"{ 'array':[{'foo':'bar' },{'a':'****'}] }",
"/array/1/a"
);


// Failed tests - see issue #735

assertThatThrownBy(() ->
testMaskByPath(
"{ 'array':['a','b', 'c'] }",
"{ 'array':['a','****','c'] }",
"/array/1"
)).isInstanceOf(AssertionFailedError.class);

assertThatThrownBy(() ->
testMaskByPath(
"{ 'array':[{'foo':'bar'},{'a':'b'}] }",
"{ 'array':['****' ,{'a':'b'}] }",
"/array/0"
)).isInstanceOf(AssertionFailedError.class);
}

@Test
public void maskedArrayOfObjects() throws IOException {
testMaskByPath(
Expand Down

0 comments on commit f7d231a

Please sign in to comment.