Search in sources :

Example 11 with MultipleJGitEnvironmentProperties

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);
}
Also used : MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) Test(org.junit.Test)

Example 12 with MultipleJGitEnvironmentProperties

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);
}
Also used : MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) JGitEnvironmentProperties(org.springframework.cloud.config.server.environment.JGitEnvironmentProperties) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 13 with MultipleJGitEnvironmentProperties

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);
}
Also used : JGitEnvironmentProperties(org.springframework.cloud.config.server.environment.JGitEnvironmentProperties) MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) HashSet(java.util.HashSet)

Example 14 with MultipleJGitEnvironmentProperties

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);
}
Also used : MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) JGitEnvironmentProperties(org.springframework.cloud.config.server.environment.JGitEnvironmentProperties) HashSet(java.util.HashSet)

Example 15 with MultipleJGitEnvironmentProperties

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);
}
Also used : ConstraintViolation(jakarta.validation.ConstraintViolation) MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) Test(org.junit.Test)

Aggregations

MultipleJGitEnvironmentProperties (org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties)19 Test (org.junit.Test)15 ConstraintViolation (jakarta.validation.ConstraintViolation)8 JGitEnvironmentProperties (org.springframework.cloud.config.server.environment.JGitEnvironmentProperties)8 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)1