diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java index ad25467..0ba872f 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java +++ b/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java @@ -80,7 +80,7 @@ public class GoogleSearchTest extends LocalProperties { } catch (ModuleException e) { // Avoid displaying api keys in CI logs. if ("true".equals(System.getenv("CI"))) { - throw new ModuleException(e.getDebugMessage(), e.getSanitizedMessage()); + throw new ModuleException(e.getDebugMessage(), e.getSanitizedMessage(apiKey, cseKey)); } else { throw e; } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.java index a2faff9..46199c9 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.java +++ b/src/test/java/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.java @@ -53,14 +53,13 @@ public class ModuleExceptionTest { @DataProvider(name = "dp") Object[][] createData(final Method m) { - return new Object[][]{new Object[]{new ModuleException(debugMessage, message, - new IOException("Secret URL http://foo.com?apiKey=sec&userID=me"))}, - new Object[]{new ModuleException(debugMessage, message, - new IOException("URL http://foobar.com"))}, - new Object[]{new ModuleException(debugMessage, message, - new IOException("URL http://foobar.com?"))}, - new Object[]{new ModuleException(debugMessage, message)} - }; + return new Object[][]{new Object[]{new ModuleException(debugMessage, + message, + new IOException("URL http://foobar.com"))}, + new Object[]{new ModuleException(debugMessage, + message, + new IOException("URL http://foobar.com?"))}, + new Object[]{new ModuleException(debugMessage, message)}}; } @Test(dataProvider = "dp") @@ -73,16 +72,13 @@ public class ModuleExceptionTest { assertThat(e.getMessage()).as("get message").isEqualTo(message); } - @Test(dataProvider = "dp") - final void testGetSanitizedMessage(final ModuleException e) { - if (e.hasCause()) { - if (e.getSanitizedMessage().contains("Secret")) { - assertThat(e.getSanitizedMessage()).as("get sanitized url") - .contains("http://foo.com?apiKey=[3]&userID=[2]"); - } else { - assertThat(e.getSanitizedMessage()).as("get sanitized url") - .contains("http://foobar.com"); - } - } + @Test + final void testGetSanitizedMessage() { + final String apiKey = "1234567890"; + final ModuleException e = new ModuleException(debugMessage, + message, + new IOException( + "URL http://foo.com?apiKey=" + apiKey + "&userID=me")); + assertThat(e.getSanitizedMessage(apiKey)).as("sanitized url").contains("xxxxxxxxxx").doesNotContain(apiKey); } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java index 77de00b..f1e60c0 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java +++ b/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java @@ -75,7 +75,7 @@ public class StockQuoteTest extends LocalProperties { } catch (ModuleException e) { // Avoid displaying api keys in CI logs. if ("true".equals(System.getenv("CI"))) { - throw new ModuleException(e.getDebugMessage(), e.getSanitizedMessage()); + throw new ModuleException(e.getDebugMessage(), e.getSanitizedMessage(apiKey)); } else { throw e; }