@Test public void hashicorpViolationIfPrivateIdAndSecretNameOnly() { keyPair.setHashicorpVaultPrivateKeyId("privId"); keyPair.setHashicorpVaultSecretName("secretName"); validator.isValid(keyPair, context); verify(context).buildConstraintViolationWithTemplate("{UnsupportedKeyPair.allHashicorpKeyDataRequired.message}"); }
@Override public boolean isValid(UnsupportedKeyPair keyPair, ConstraintValidatorContext context) { if (isIncompleteDirectKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothDirectKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteInlineKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothInlineKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteAzureVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAzureKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteHashicorpVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.allHashicorpKeyDataRequired.message}") .addConstraintViolation(); } else if (isIncompleteAWSVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAWSKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteFilesystemKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothFilesystemKeysRequired.message}") .addConstraintViolation(); } return false; }
UnsupportedKeyPairValidator implements ConstraintValidator<ValidUnsupportedKeyPair, UnsupportedKeyPair> { @Override public boolean isValid(UnsupportedKeyPair keyPair, ConstraintValidatorContext context) { if (isIncompleteDirectKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothDirectKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteInlineKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothInlineKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteAzureVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAzureKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteHashicorpVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.allHashicorpKeyDataRequired.message}") .addConstraintViolation(); } else if (isIncompleteAWSVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAWSKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteFilesystemKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothFilesystemKeysRequired.message}") .addConstraintViolation(); } return false; } }
UnsupportedKeyPairValidator implements ConstraintValidator<ValidUnsupportedKeyPair, UnsupportedKeyPair> { @Override public boolean isValid(UnsupportedKeyPair keyPair, ConstraintValidatorContext context) { if (isIncompleteDirectKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothDirectKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteInlineKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothInlineKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteAzureVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAzureKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteHashicorpVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.allHashicorpKeyDataRequired.message}") .addConstraintViolation(); } else if (isIncompleteAWSVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAWSKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteFilesystemKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothFilesystemKeysRequired.message}") .addConstraintViolation(); } return false; }  }
UnsupportedKeyPairValidator implements ConstraintValidator<ValidUnsupportedKeyPair, UnsupportedKeyPair> { @Override public boolean isValid(UnsupportedKeyPair keyPair, ConstraintValidatorContext context) { if (isIncompleteDirectKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothDirectKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteInlineKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothInlineKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteAzureVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAzureKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteHashicorpVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.allHashicorpKeyDataRequired.message}") .addConstraintViolation(); } else if (isIncompleteAWSVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAWSKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteFilesystemKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothFilesystemKeysRequired.message}") .addConstraintViolation(); } return false; }  @Override boolean isValid(UnsupportedKeyPair keyPair, ConstraintValidatorContext context); }
UnsupportedKeyPairValidator implements ConstraintValidator<ValidUnsupportedKeyPair, UnsupportedKeyPair> { @Override public boolean isValid(UnsupportedKeyPair keyPair, ConstraintValidatorContext context) { if (isIncompleteDirectKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothDirectKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteInlineKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothInlineKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteAzureVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAzureKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteHashicorpVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.allHashicorpKeyDataRequired.message}") .addConstraintViolation(); } else if (isIncompleteAWSVaultKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothAWSKeysRequired.message}") .addConstraintViolation(); } else if (isIncompleteFilesystemKeyPair(keyPair)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothFilesystemKeysRequired.message}") .addConstraintViolation(); } return false; }  @Override boolean isValid(UnsupportedKeyPair keyPair, ConstraintValidatorContext context);  }