use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshUriPropertyProcessorTest method testSameHostnameDifferentKeysFirstOneWins.
@Test
public void testSameHostnameDifferentKeysFirstOneWins() {
MultipleJGitEnvironmentProperties sshUriProperties = mainRepoPropertiesFixture();
MultipleJGitEnvironmentProperties.PatternMatchingJGitEnvironmentProperties nestedSshUriProperties;
nestedSshUriProperties = new MultipleJGitEnvironmentProperties.PatternMatchingJGitEnvironmentProperties();
nestedSshUriProperties.setUri(URI1);
nestedSshUriProperties.setPrivateKey(PRIVATE_KEY1);
nestedSshUriProperties.setHostKey(HOST_KEY1);
nestedSshUriProperties.setHostKeyAlgorithm(ALGO1);
addRepoProperties(sshUriProperties, nestedSshUriProperties, "repo2");
SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(sshUriProperties);
Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname();
assertThat(sshKeysByHostname.values()).hasSize(1);
JGitEnvironmentProperties sshKey = sshKeysByHostname.get(HOST1);
assertMainRepo(sshKey);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshPropertyValidatorTest method hostKeyWithMissingAlgoFails.
@Test
public void hostKeyWithMissingAlgoFails() throws Exception {
MultipleJGitEnvironmentProperties missingAlgo = new MultipleJGitEnvironmentProperties();
missingAlgo.setUri(SSH_URI);
missingAlgo.setIgnoreLocalSshSettings(true);
missingAlgo.setPrivateKey(VALID_PRIVATE_KEY);
missingAlgo.setHostKey("some_host");
Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(missingAlgo);
assertThat(constraintViolations).hasSize(1);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshPropertyValidatorTest method validatorNotRunIfIgnoreLocalSettingsFalse.
@Test
public void validatorNotRunIfIgnoreLocalSettingsFalse() throws Exception {
MultipleJGitEnvironmentProperties useLocal = new MultipleJGitEnvironmentProperties();
useLocal.setUri(SSH_URI);
useLocal.setIgnoreLocalSshSettings(false);
useLocal.setPrivateKey("invalid_key");
Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(useLocal);
assertThat(constraintViolations).hasSize(0);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshPropertyValidatorTest method supportedParametersSuccesful.
@Test
public void supportedParametersSuccesful() throws Exception {
MultipleJGitEnvironmentProperties validSettings = new MultipleJGitEnvironmentProperties();
validSettings.setUri(SSH_URI);
validSettings.setIgnoreLocalSshSettings(true);
validSettings.setPrivateKey(VALID_PRIVATE_KEY);
validSettings.setHostKey(VALID_HOST_KEY);
validSettings.setHostKeyAlgorithm("ssh-rsa");
Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(validSettings);
assertThat(constraintViolations).hasSize(0);
}
use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshPropertyValidatorTest method unsupportedAlgoFails.
@Test
public void unsupportedAlgoFails() throws Exception {
MultipleJGitEnvironmentProperties unsupportedAlgo = new MultipleJGitEnvironmentProperties();
unsupportedAlgo.setUri(SSH_URI);
unsupportedAlgo.setIgnoreLocalSshSettings(true);
unsupportedAlgo.setPrivateKey(VALID_PRIVATE_KEY);
unsupportedAlgo.setHostKey("some_host_key");
unsupportedAlgo.setHostKeyAlgorithm("unsupported");
Set<ConstraintViolation<MultipleJGitEnvironmentProperties>> constraintViolations = validator.validate(unsupportedAlgo);
assertThat(constraintViolations).hasSize(1);
}
Aggregations