use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshPropertyValidatorTest method preferredAuthenticationsIsValidated.
@Test
public void preferredAuthenticationsIsValidated() throws Exception {
MultipleJGitEnvironmentProperties sshUriProperties = new MultipleJGitEnvironmentProperties();
assertThat(validator.validate(sshUriProperties)).hasSize(0);
sshUriProperties.setPreferredAuthentications("keyboard-interactive, public-key ,kerberos");
assertThat(validator.validate(sshUriProperties)).hasSize(0);
sshUriProperties.setPreferredAuthentications(",,");
assertThat(validator.validate(sshUriProperties)).hasSize(1);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class HostKeyAlgoSupportedValidator method isValid.
@Override
public boolean isValid(MultipleJGitEnvironmentProperties sshUriProperties, ConstraintValidatorContext context) {
context.disableDefaultConstraintViolation();
Set<Boolean> validationResults = new HashSet<>();
List<JGitEnvironmentProperties> extractedProperties = this.sshPropertyValidator.extractRepoProperties(sshUriProperties);
for (JGitEnvironmentProperties extractedProperty : extractedProperties) {
if (sshUriProperties.isIgnoreLocalSshSettings() && isSshUri(extractedProperty.getUri())) {
validationResults.add(isHostKeySpecifiedWhenAlgorithmSet(extractedProperty, context));
}
}
return !validationResults.contains(false);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class HostKeyAndAlgoBothExistValidator method isValid.
@Override
public boolean isValid(MultipleJGitEnvironmentProperties sshUriProperties, ConstraintValidatorContext context) {
Set<Boolean> validationResults = new HashSet<>();
List<JGitEnvironmentProperties> extractedProperties = this.sshPropertyValidator.extractRepoProperties(sshUriProperties);
for (JGitEnvironmentProperties extractedProperty : extractedProperties) {
if (sshUriProperties.isIgnoreLocalSshSettings() && isSshUri(extractedProperty.getUri())) {
validationResults.add(isAlgorithmSpecifiedWhenHostKeySet(extractedProperty, context) && isHostKeySpecifiedWhenAlgorithmSet(extractedProperty, context));
}
}
return !validationResults.contains(false);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class PrivateKeyValidator method isValid.
@Override
public boolean isValid(MultipleJGitEnvironmentProperties sshUriProperties, ConstraintValidatorContext context) {
context.disableDefaultConstraintViolation();
Set<Boolean> validationResults = new HashSet<>();
List<JGitEnvironmentProperties> extractedProperties = this.sshPropertyValidator.extractRepoProperties(sshUriProperties);
for (JGitEnvironmentProperties extractedProperty : extractedProperties) {
if (extractedProperty.isIgnoreLocalSshSettings() && isSshUri(extractedProperty.getUri())) {
validationResults.add(isPrivateKeyPresent(extractedProperty, context) && isPrivateKeyFormatCorrect(extractedProperty, context));
}
}
return !validationResults.contains(false);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshPropertyValidatorTest method missingPrivateKeyFails.
@Test
public void missingPrivateKeyFails() throws Exception {
MultipleJGitEnvironmentProperties missingKey = new MultipleJGitEnvironmentProperties();
missingKey.setUri(SSH_URI);
missingKey.setIgnoreLocalSshSettings(true);
Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(missingKey);
assertThat(constraintViolations).hasSize(1);
}
Aggregations