Search in sources :

Example 6 with MultipleJGitEnvironmentProperties

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

Example 7 with MultipleJGitEnvironmentProperties

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

Example 8 with MultipleJGitEnvironmentProperties

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

Example 9 with MultipleJGitEnvironmentProperties

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

Example 10 with MultipleJGitEnvironmentProperties

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);
}
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