SecurityUtils { public static Validations getValidations() { return Validations.builder() .optionalPath(SECURITY_PREFIX + "." + RENEW_INTERVAL) .optionalPath(SECURITY_PREFIX + "." + TOKENS_FILE, ConfigValueType.STRING) .optionalPath(SECURITY_PREFIX + "." + TOKENS_CHECK_INTERVAL) .optionalPath(SECURITY_PREFIX + "." + TOKENS_DELETION_DELAY) .optionalPath(SECURITY_PREFIX + "." + TOKENS_RENEW_FACTOR, ConfigValueType.NUMBER) .build(); }  static Token createToken(byte[] rawToken); static Token createToken(byte[] rawToken, int generation); static String getTokenStoreFilePath(Config config, boolean onDriver); static List<Path> getExistingTokenStoreFiles(Config config, Configuration hadoopConf, boolean onDriver); static void deleteTokenStoreFiles(List<Path> files, long delay, Configuration hadoopConf); static Validations getValidations(); static Set<InstantiatedComponent> getAllSecureComponents(InstantiatedComponent component); static final String SECURITY_PREFIX; static final String RENEW_INTERVAL; static final String TOKENS_FILE; static final String TOKENS_CHECK_INTERVAL; static final String TOKENS_RENEW_FACTOR; static final String TOKENS_DELETION_DELAY; }
@Test public void testConfigIsValid() { Config config = ConfigUtils.configFromResource("/security/security_validation_test.conf"); List<ValidationResult> results = Validator.validate(new SecurityValidator() { @Override public Validations getValidations() { return SecurityUtils.getValidations(); } }, config); int count = 0; for (ValidationResult result : results) { if (result.getValidation() instanceof OptionalPathValidation) { ++count; } assertEquals(result.getValidity(), Validity.VALID); } assertEquals(5, count); }