Search in sources :

Example 16 with MultipleJGitEnvironmentProperties

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.

the class SshPropertyValidatorTest method knowHostsFileIsValidated.

@Test
public void knowHostsFileIsValidated() throws Exception {
    MultipleJGitEnvironmentProperties sshUriProperties = new MultipleJGitEnvironmentProperties();
    assertThat(validator.validate(sshUriProperties)).hasSize(0);
    sshUriProperties.setKnownHostsFile("non-existing.file");
    assertThat(validator.validate(sshUriProperties)).hasSize(1);
}
Also used : MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) Test(org.junit.Test)

Example 17 with MultipleJGitEnvironmentProperties

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.

the class SshPropertyValidatorTest method validatorNotRunIfHttpsUri.

@Test
public void validatorNotRunIfHttpsUri() throws Exception {
    MultipleJGitEnvironmentProperties httpsUri = new MultipleJGitEnvironmentProperties();
    httpsUri.setUri("https://somerepo.com/team/project.git");
    httpsUri.setIgnoreLocalSshSettings(true);
    httpsUri.setPrivateKey("invalid_key");
    Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(httpsUri);
    assertThat(constraintViolations).hasSize(0);
}
Also used : ConstraintViolation(jakarta.validation.ConstraintViolation) MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) Test(org.junit.Test)

Example 18 with MultipleJGitEnvironmentProperties

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.

the class SshPropertyValidatorTest method invalidPrivateKeyFails.

@Test
public void invalidPrivateKeyFails() throws Exception {
    MultipleJGitEnvironmentProperties invalidKey = new MultipleJGitEnvironmentProperties();
    invalidKey.setUri(SSH_URI);
    invalidKey.setIgnoreLocalSshSettings(true);
    invalidKey.setPrivateKey("invalid_key");
    Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(invalidKey);
    assertThat(constraintViolations).hasSize(1);
}
Also used : ConstraintViolation(jakarta.validation.ConstraintViolation) MultipleJGitEnvironmentProperties(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties) Test(org.junit.Test)

Example 19 with MultipleJGitEnvironmentProperties

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.

the class SshPropertyValidatorTest method algoWithMissingHostKeyFails.

@Test
public void algoWithMissingHostKeyFails() throws Exception {
    MultipleJGitEnvironmentProperties missingHostKey = new MultipleJGitEnvironmentProperties();
    missingHostKey.setUri(SSH_URI);
    missingHostKey.setIgnoreLocalSshSettings(true);
    missingHostKey.setPrivateKey(VALID_PRIVATE_KEY);
    missingHostKey.setHostKeyAlgorithm("ssh-rsa");
    Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(missingHostKey);
    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