From 5381497bdbb25f3d3b117db275226aa95c8455d1 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 31 Aug 2017 10:38:02 +0900 Subject: [PATCH 1/4] Fix error messages --- .../cloud/config/server/ssh/PrivateKeyValidator.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PrivateKeyValidator.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PrivateKeyValidator.java index a3632538..cd95a705 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PrivateKeyValidator.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PrivateKeyValidator.java @@ -32,7 +32,7 @@ import static org.springframework.cloud.config.server.ssh.SshPropertyValidator.i import static org.springframework.util.StringUtils.hasText; /** - * JSR-303 Cross Field validator that ensures that a {@link SshUriProperties} bean for the constraints: + * JSR-303 Cross Field validator that ensures that an {@link SshUriProperties} bean for the constraints: * - Private key is present and can be correctly parsed using {@link com.jcraft.jsch.KeyPair} * * Beans annotated with {@link PrivateKeyValidator} and {@link Validated} will have the constraints applied. @@ -67,9 +67,9 @@ public class PrivateKeyValidator implements ConstraintValidator Date: Fri, 1 Sep 2017 02:05:34 +0300 Subject: [PATCH 2/4] Added additional options for GIT SSH configuration property configuration (#775) Abilty to specify known_hosts file Added option to specify SSH 'PreferredAuthentications' property to override SSH server priorities for authentication methods. fixes gh-101 --- .../main/asciidoc/spring-cloud-config.adoc | 6 ++ .../server/ssh/KnownHostsFileIsValid.java | 40 +++++++++++ .../server/ssh/KnownHostsFileValidator.java | 54 +++++++++++++++ .../ssh/PropertyBasedSshSessionFactory.java | 10 ++- .../cloud/config/server/ssh/SshUri.java | 69 ++++++++++++++++++- .../config/server/ssh/SshUriProperties.java | 3 +- .../PropertyBasedSshSessionFactoryTest.java | 33 ++++++++- .../server/ssh/SshPropertyValidatorTest.java | 23 ++++++- 8 files changed, 232 insertions(+), 6 deletions(-) create mode 100644 spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileIsValid.java create mode 100644 spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileValidator.java diff --git a/docs/src/main/asciidoc/spring-cloud-config.adoc b/docs/src/main/asciidoc/spring-cloud-config.adoc index f4ab6f8a..f9f19e85 100644 --- a/docs/src/main/asciidoc/spring-cloud-config.adoc +++ b/docs/src/main/asciidoc/spring-cloud-config.adoc @@ -429,6 +429,12 @@ Example: |*strictHostKeyChecking* |`true` or `false`. If false, ignore errors with host key + +|*knownHostsFile* +|Location of custom .known_hosts file + +|*preferredAuthentications* +|Override server authentication method order. This should allow evade login prompts if server has keyboard-interactive authentication before `publickey` method. |=== diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileIsValid.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileIsValid.java new file mode 100644 index 00000000..f11af222 --- /dev/null +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileIsValid.java @@ -0,0 +1,40 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.config.server.ssh; + +import org.springframework.validation.annotation.Validated; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Beans annotated with {@link KnownHostsFileIsValid} and {@link Validated} will have the constraints applied. + * + * @author Edgars Jasmans + **/ +@Constraint(validatedBy = KnownHostsFileValidator.class) +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface KnownHostsFileIsValid { + String message() default "{KnownHostsFileIsValid.message}"; + Class[] groups() default {}; + Class[] payload() default {}; +} diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileValidator.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileValidator.java new file mode 100644 index 00000000..281cf37c --- /dev/null +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/KnownHostsFileValidator.java @@ -0,0 +1,54 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.config.server.ssh; + +import org.springframework.validation.annotation.Validated; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.io.File; + +import static java.lang.String.*; + +/** + * JSR-303 Cross Field validator that ensures that a {@link SshUriProperties} bean for the constraints: + * - Verifies that known hosts file exists + *

+ * Beans annotated with {@link KnownHostsFileIsValid} and {@link Validated} will have the constraints applied. + * + * @author Edgars Jasmans + */ +public class KnownHostsFileValidator implements ConstraintValidator { + + @Override + public void initialize(KnownHostsFileIsValid knownHostsFileIsValid) { + // No initialization required + } + + @Override + public boolean isValid(SshUriProperties sshUriProperties, ConstraintValidatorContext context) { + String knownHostsFile = sshUriProperties.getKnownHostsFile(); + if (knownHostsFile != null && !new File(knownHostsFile).exists()) { + context.disableDefaultConstraintViolation(); + context.buildConstraintViolationWithTemplate( + format("File '%s' specified in property 'spring.cloud.config.server.git.knownHostsFile' could not be located", knownHostsFile)) + .addConstraintViolation(); + return false; + } + return true; + } +} diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java index 0934ccec..0b3d2eb4 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015 - 2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.eclipse.jgit.util.FS; public class PropertyBasedSshSessionFactory extends JschConfigSessionFactory { private static final String STRICT_HOST_KEY_CHECKING = "StrictHostKeyChecking"; + private static final String PREFERRED_AUTHENTICATIONS = "PreferredAuthentications"; private static final String YES_OPTION = "yes"; private static final String NO_OPTION = "no"; private static final String SERVER_HOST_KEY = "server_host_key"; @@ -59,6 +60,10 @@ public class PropertyBasedSshSessionFactory extends JschConfigSessionFactory { } else { session.setConfig(STRICT_HOST_KEY_CHECKING, YES_OPTION); } + String preferredAuthentications = sshProperties.getPreferredAuthentications(); + if (preferredAuthentications != null) { + session.setConfig(PREFERRED_AUTHENTICATIONS, preferredAuthentications); + } } @Override @@ -66,6 +71,9 @@ public class PropertyBasedSshSessionFactory extends JschConfigSessionFactory { if (sshKeysByHostname.containsKey(host)) { SshUri sshUriProperties = sshKeysByHostname.get(host); jSch.addIdentity(host, sshUriProperties.getPrivateKey().getBytes(), null, null); + if (sshUriProperties.getKnownHostsFile() != null) { + jSch.setKnownHosts(sshUriProperties.getKnownHostsFile()); + } if (sshUriProperties.getHostKey() != null) { HostKey hostkey = new HostKey(host, Base64.decode(sshUriProperties.getHostKey())); jSch.getHostKeyRepository().add(hostkey, null); diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUri.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUri.java index 109d6a31..a7211160 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUri.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUri.java @@ -1,7 +1,24 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.config.server.ssh; import org.springframework.cloud.config.server.ssh.SshUriProperties.SshUriNestedRepoProperties; +import javax.validation.constraints.Pattern; import java.util.LinkedHashMap; import java.util.Map; @@ -15,6 +32,9 @@ public abstract class SshUri { private String uri; private String hostKeyAlgorithm; private String hostKey; + private String knownHostsFile; + @Pattern(regexp = "([\\w -]+,)*([\\w -]+)") + private String preferredAuthentications; private boolean ignoreLocalSshSettings; private boolean strictHostKeyChecking = true; @@ -34,6 +54,14 @@ public abstract class SshUri { return this.hostKey; } + public String getKnownHostsFile() { + return this.knownHostsFile; + } + + public String getPreferredAuthentications() { + return this.preferredAuthentications; + } + public String getPrivateKey() { return this.privateKey; } @@ -58,6 +86,14 @@ public abstract class SshUri { this.hostKey = hostKey; } + public void setKnownHostsFile(String knownHostsFile) { + this.knownHostsFile = knownHostsFile; + } + + public void setPreferredAuthentications(String preferredAuthentications) { + this.preferredAuthentications = preferredAuthentications; + } + public void setPrivateKey(String privateKey) { this.privateKey = privateKey; } @@ -71,7 +107,14 @@ public abstract class SshUri { } public String toString() { - return "org.springframework.cloud.config.server.ssh.SshUriProperties(uri=" + this.getUri() + " hostKeyAlgorithm=" + this.getHostKeyAlgorithm() + ", hostKey=" + this.getHostKey() + ", privateKey=" + this.getPrivateKey() + ", ignoreLocalSshSettings=" + this.isIgnoreLocalSshSettings() + ", strictHostKeyChecking=" + this.isStrictHostKeyChecking() + ",)"; + return "org.springframework.cloud.config.server.ssh.SshUriProperties(uri=" + this.getUri() + + " hostKeyAlgorithm=" + this.getHostKeyAlgorithm() + + ", hostKey=" + this.getHostKey() + + ", privateKey=" + this.getPrivateKey() + + ", ignoreLocalSshSettings=" + this.isIgnoreLocalSshSettings() + + ", knownHostsFile=" + this.getKnownHostsFile() + + ", preferredAuthentications=" + this.getPreferredAuthentications() + + ", strictHostKeyChecking=" + this.isStrictHostKeyChecking() + ",)"; } public static class SshUriPropertiesBuilder { @@ -79,6 +122,8 @@ public abstract class SshUri { private String hostKeyAlgorithm; private String hostKey; private String privateKey; + private String knownHostsFile; + private String preferredAuthentications; private boolean ignoreLocalSshSettings; private boolean strictHostKeyChecking = true; private Map repos = new LinkedHashMap<>(); @@ -106,6 +151,16 @@ public abstract class SshUri { return this; } + public SshUri.SshUriPropertiesBuilder knownHostsFile(String knownHostsFile) { + this.knownHostsFile = knownHostsFile; + return this; + } + + public SshUri.SshUriPropertiesBuilder preferredAuthentications(String preferredAuthentications) { + this.preferredAuthentications = preferredAuthentications; + return this; + } + public SshUri.SshUriPropertiesBuilder ignoreLocalSshSettings(boolean ignoreLocalSshSettings) { this.ignoreLocalSshSettings = ignoreLocalSshSettings; return this; @@ -139,12 +194,22 @@ public abstract class SshUri { sshUriNestedRepoProperties.setHostKeyAlgorithm(hostKeyAlgorithm); sshUriNestedRepoProperties.setHostKey(hostKey); sshUriNestedRepoProperties.setPrivateKey(privateKey); + sshUriNestedRepoProperties.setKnownHostsFile(knownHostsFile); + sshUriNestedRepoProperties.setPreferredAuthentications(preferredAuthentications); sshUriNestedRepoProperties.setIgnoreLocalSshSettings(ignoreLocalSshSettings); sshUriNestedRepoProperties.setStrictHostKeyChecking(strictHostKeyChecking); } public String toString() { - return "org.springframework.cloud.config.server.ssh.SshUriProperties.SshUriPropertiesBuilder(uri=" + this.uri + "hostKeyAlgorithm=" + this.hostKeyAlgorithm + ", hostKey=" + this.hostKey + ", privateKey=" + this.privateKey + ", ignoreLocalSshSettings=" + this.ignoreLocalSshSettings + ", strictHostKeyChecking=" + this.strictHostKeyChecking + ", repos=" + this.repos + ")"; + return "org.springframework.cloud.config.server.ssh.SshUriProperties.SshUriPropertiesBuilder(uri=" + this.uri + + "hostKeyAlgorithm=" + this.hostKeyAlgorithm + + ", hostKey=" + this.hostKey + + ", privateKey=" + this.privateKey + + ", knownHostsFile=" + this.knownHostsFile + + ", preferredAuthentications=" + this.preferredAuthentications + + ", ignoreLocalSshSettings=" + this.ignoreLocalSshSettings + + ", strictHostKeyChecking=" + this.strictHostKeyChecking + + ", repos=" + this.repos + ")"; } } } diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUriProperties.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUriProperties.java index c5a25ddb..7aa9879d 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUriProperties.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/SshUriProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015 - 2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.validation.annotation.Validated; @PrivateKeyIsValid @HostKeyAndAlgoBothExist @HostKeyAlgoSupported +@KnownHostsFileIsValid public class SshUriProperties extends SshUri { private Map repos = new LinkedHashMap<>(); diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java index 45fb97ba..ad7280f7 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015 - 2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,6 +138,37 @@ public class PropertyBasedSshSessionFactoryTest { Assert.assertEquals(HOST_KEY, hostKey.getKey()); } + @Test + public void preferredAuthenticationsIsSpecified() { + SshUri sshKey = new SshUriProperties.SshUriPropertiesBuilder() + .uri("ssh://gitlab.example.local:3322/somerepo.git") + .privateKey(PRIVATE_KEY) + .preferredAuthentications("password,keyboard-interactive") + .build(); + setupSessionFactory(sshKey); + + factory.configure(hc, session); + verify(session).setConfig("PreferredAuthentications", "password,keyboard-interactive"); + verify(session).setConfig("StrictHostKeyChecking", "no"); + verifyNoMoreInteractions(session); + } + + @Test + public void customKnownHostsFileIsUsed() throws Exception { + SshUri sshKey = new SshUriProperties.SshUriPropertiesBuilder() + .uri("git@gitlab.example.local:someorg/somerepo.git") + .privateKey(PRIVATE_KEY) + .knownHostsFile("/ssh/known_hosts") + .build(); + setupSessionFactory(sshKey); + + factory.createSession(hc, null, SshUriPropertyProcessor.getHostname(sshKey.getUri()), 22, null); + ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); + + verify(jSch).setKnownHosts(captor.capture()); + Assert.assertEquals("/ssh/known_hosts", captor.getValue()); + } + private void setupSessionFactory(SshUri sshKey) { Map sshKeysByHostname = new HashMap<>(); sshKeysByHostname.put(SshUriPropertyProcessor.getHostname(sshKey.getUri()), sshKey); diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/SshPropertyValidatorTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/SshPropertyValidatorTest.java index 154c139a..942f96ec 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/SshPropertyValidatorTest.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/SshPropertyValidatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015 - 2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,4 +185,25 @@ public class SshPropertyValidatorTest { assertThat(constraintViolations, hasSize(0)); } + + @Test + public void preferredAuthenticationsIsValidated() throws Exception { + SshUriProperties sshUriProperties = new SshUriProperties(); + 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)); + } + + @Test + public void knowHostsFileIsValidated() throws Exception { + SshUriProperties sshUriProperties = new SshUriProperties(); + assertThat(validator.validate(sshUriProperties), hasSize(0)); + + sshUriProperties.setKnownHostsFile("non-existing.file"); + assertThat(validator.validate(sshUriProperties), hasSize(1)); + } } \ No newline at end of file From b555ddfe92df239517e28723c48b390215772ab1 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 11 Sep 2017 15:14:47 -0600 Subject: [PATCH 3/4] Move back to java7 compatible jgit. Fixes gh-780 --- spring-cloud-config-dependencies/pom.xml | 3 ++- .../server/environment/JGitEnvironmentRepository.java | 4 ++-- .../server/environment/JGitEnvironmentRepositoryTests.java | 6 +++--- .../server/ssh/PropertyBasedSshSessionFactoryTest.java | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spring-cloud-config-dependencies/pom.xml b/spring-cloud-config-dependencies/pom.xml index 5f428051..f7fb34b6 100644 --- a/spring-cloud-config-dependencies/pom.xml +++ b/spring-cloud-config-dependencies/pom.xml @@ -38,7 +38,8 @@ org.eclipse.jgit org.eclipse.jgit - 4.6.0.201612231935-r + + 3.6.1.201501031845-r org.tmatesoft.svnkit diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java index 7ad63742..6fb9ff7b 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java @@ -197,7 +197,7 @@ public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository checkout(git, label); } // always return what is currently HEAD as the version - return git.getRepository().findRef("HEAD").getObjectId().getName(); + return git.getRepository().getRef("HEAD").getObjectId().getName(); } catch (RefNotFoundException e) { throw new NoSuchLabelException("No such label: " + label, e); } catch (NoRemoteRepositoryException e) { @@ -311,7 +311,7 @@ public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository private MergeResult merge(Git git, String label) { try { MergeCommand merge = git.merge(); - merge.include(git.getRepository().findRef("origin/" + label)); + merge.include(git.getRepository().getRef("origin/" + label)); MergeResult result = merge.call(); if (!result.getMergeStatus().isSuccessful()) { this.logger.warn("Merged from remote " + label + " with result " + result.getMergeStatus()); diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java index 0d67d4ac..14a97124 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java @@ -379,7 +379,7 @@ public class JGitEnvironmentRepositoryTests { // refresh()->return // git.getRepository().getRef("HEAD").getObjectId().getName(); Ref headRef = mock(Ref.class); - when(repository.findRef(anyString())).thenReturn(headRef); + when(repository.getRef(anyString())).thenReturn(headRef); ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 }); when(headRef.getObjectId()).thenReturn(newObjectId); @@ -435,7 +435,7 @@ public class JGitEnvironmentRepositoryTests { //refresh()->return git.getRepository().getRef("HEAD").getObjectId().getName(); Ref headRef = mock(Ref.class); - when(repository.findRef(anyString())).thenReturn(headRef); + when(repository.getRef(anyString())).thenReturn(headRef); ObjectId newObjectId = ObjectId.fromRaw(new int[]{1,2,3,4,5}); when(headRef.getObjectId()).thenReturn(newObjectId); @@ -503,7 +503,7 @@ public class JGitEnvironmentRepositoryTests { // refresh()->return // git.getRepository().getRef("HEAD").getObjectId().getName(); Ref headRef = mock(Ref.class); - when(repository.findRef(anyString())).thenReturn(headRef); + when(repository.getRef(anyString())).thenReturn(headRef); ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 }); when(headRef.getObjectId()).thenReturn(newObjectId); diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java index cf41ce6d..03e6abd7 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java @@ -19,6 +19,7 @@ package org.springframework.cloud.config.server.ssh; import com.jcraft.jsch.*; import org.eclipse.jgit.transport.OpenSshConfig.Host; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -117,6 +118,7 @@ public class PropertyBasedSshSessionFactoryTest { } @Test + @Ignore public void hostKeyIsUsed() throws Exception { SshUri sshKey = new SshUriProperties.SshUriPropertiesBuilder() .uri("git@gitlab.example.local:someorg/somerepo.git") From f995217841e0139c4886679cde10b3db7715acd6 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 11 Sep 2017 15:15:12 -0600 Subject: [PATCH 4/4] unignore test --- .../config/server/ssh/PropertyBasedSshSessionFactoryTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java index 03e6abd7..318226fb 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java @@ -118,7 +118,6 @@ public class PropertyBasedSshSessionFactoryTest { } @Test - @Ignore public void hostKeyIsUsed() throws Exception { SshUri sshKey = new SshUriProperties.SshUriPropertiesBuilder() .uri("git@gitlab.example.local:someorg/somerepo.git")