HardCodedCredentialsCheck extends DoubleDispatchVisitorCheck { @VisibleForTesting void setEncryptedCredentialsToIgnore(String encryptedCredentialsToIgnore) { this.encryptedCredentialsToIgnore = encryptedCredentialsToIgnore; }  @Override void visitProperty(PropertyTree tree); @Override void validateParameters();  }
@Test public void should_not_find_some_hard_coded_credentials_because_values_to_ignore_are_set() { HardCodedCredentialsCheck check = new HardCodedCredentialsCheck(); check.setEncryptedCredentialsToIgnore("^(ENC\\(|OBF:).+$"); JavaPropertiesCheckVerifier.verify(check, CheckTestUtils.getTestFile("hard-coded-credentials/hardCodedCredentialsValuesToIgnore.properties")); }
@Test public void should_throw_an_illegal_state_exception_as_the_encryptedCredentialsToIgnore_parameter_is_not_a_valid_regular_expression() { try { HardCodedCredentialsCheck check = new HardCodedCredentialsCheck(); check.setEncryptedCredentialsToIgnore("("); JavaPropertiesCheckVerifier.issues(check, CheckTestUtils.getTestFile("hard-coded-credentials/hardCodedCredentials.properties")).noMore(); } catch (IllegalStateException e) { assertThat(e.getMessage()).isEqualTo("Check jproperties:S2068 (Credentials should not be hard-coded): " + "encryptedCredentialsToIgnore parameter \"(\" is not a valid regular expression."); } }