Last active
September 26, 2017 17:07
-
-
Save ishults/43b7e14d4deb60f5bb5cecfc872aee7b to your computer and use it in GitHub Desktop.
Tests for the main class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogMaskingConverterSpec extends Specification { | |
@Shared | |
LogMaskingConverter converter | |
void setup() { | |
converter = new LogMaskingConverter() | |
} | |
@Unroll | |
void 'format() should mask sensitive data'() { | |
setup: | |
SimpleMessage message = new SimpleMessage(input) | |
LogEvent logEvent = new Log4jLogEvent('LogMaskingConverterSpecLogger', new MarkerManager.Log4jMarker(LoggingMarkers.JSON.name), null, null, message, null) | |
StringBuilder builder = new StringBuilder() | |
when: | |
converter.format(logEvent, builder) | |
then: | |
assert builder.toString() == expectedOutput | |
where: | |
input | expectedOutput | |
'{"noMask": "foo"}' | '{"noMask": "foo"}' | |
'{"ssn": "1234567890", "id": "ABC-123", "private": "someKey"}' | '{"ssn": "****", "id": "ABC-123", "private": "****"}' | |
'invalidJson' | 'invalidJson' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment