From 8d8451b694f22cebb64781b412fa78c45da0db97 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Tue, 27 Jul 2021 22:53:44 -0400 Subject: [PATCH] Updates jgit to 5.12.0.202106070339-r Also includes org.eclipse.jgit.ssh.jsch artifact. Fixes gh-1881 --- spring-cloud-config-dependencies/pom.xml | 7 ++- spring-cloud-config-server/pom.xml | 4 ++ .../JGitEnvironmentRepositoryTests.java | 53 ++++++++----------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/spring-cloud-config-dependencies/pom.xml b/spring-cloud-config-dependencies/pom.xml index f486a9f8..72dda323 100644 --- a/spring-cloud-config-dependencies/pom.xml +++ b/spring-cloud-config-dependencies/pom.xml @@ -15,7 +15,7 @@ spring-cloud-config-dependencies Spring Cloud Config Dependencies - 5.1.3.201810200350-r + 5.12.0.202106070339-r 2.3.2 2.1.1.RELEASE @@ -66,6 +66,11 @@ org.eclipse.jgit.http.apache ${jgit.version} + + org.eclipse.jgit + org.eclipse.jgit.ssh.jsch + ${jgit.version} + com.jcraft jsch diff --git a/spring-cloud-config-server/pom.xml b/spring-cloud-config-server/pom.xml index 2117add4..2b5bb15e 100644 --- a/spring-cloud-config-server/pom.xml +++ b/spring-cloud-config-server/pom.xml @@ -76,6 +76,10 @@ org.eclipse.jgit org.eclipse.jgit.http.apache + + org.eclipse.jgit + org.eclipse.jgit.ssh.jsch + org.yaml snakeyaml 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 f442739a..a56629d8 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 @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.UUID; import org.apache.commons.logging.Log; import org.assertj.core.api.Assertions; @@ -557,13 +558,8 @@ public class JGitEnvironmentRepositoryTests { FetchCommand fetchCommand = mock(FetchCommand.class); when(git.fetch()).thenReturn(fetchCommand); when(fetchCommand.setRemote(anyString())).thenReturn(fetchCommand); - when(fetchCommand.call()).thenThrow(new InvalidRemoteException("invalid mock remote")); // here - // is - // our - // exception - // we - // are - // testing + // here is our exception we are testing + when(fetchCommand.call()).thenThrow(new InvalidRemoteException("invalid mock remote")); // refresh()->checkout CheckoutCommand checkoutCommand = mock(CheckoutCommand.class); @@ -580,18 +576,13 @@ public class JGitEnvironmentRepositoryTests { // refresh()->merge MergeCommand mergeCommand = mock(MergeCommand.class); when(git.merge()).thenReturn(mergeCommand); - when(mergeCommand.call()).thenThrow(new NotMergedException()); // here - // is - // our - // exception - // we - // are - // testing + // here is our exception we are testing + when(mergeCommand.call()).thenThrow(new NotMergedException()); // refresh()->return // git.getRepository().findRef("HEAD").getObjectId().getName(); Ref headRef = mock(Ref.class); - when(this.database.getRef(anyString())).thenReturn(headRef); + when(this.database.findRef(anyString())).thenReturn(headRef); ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 }); when(headRef.getObjectId()).thenReturn(newObjectId); @@ -604,11 +595,19 @@ public class JGitEnvironmentRepositoryTests { private Repository stubbedRepo() { return spy(new Repository(new BaseRepositoryBuilder()) { + + private String id = UUID.randomUUID().toString(); + @Override public void create(boolean bare) throws IOException { } + @Override + public String getIdentifier() { + return id; + } + @Override public ObjectDatabase getObjectDatabase() { return null; @@ -695,7 +694,7 @@ public class JGitEnvironmentRepositoryTests { // refresh()->return git.getRepository().findRef("HEAD").getObjectId().getName(); Ref headRef = mock(Ref.class); - when(this.database.getRef(anyString())).thenReturn(headRef); + when(this.database.findRef(anyString())).thenReturn(headRef); ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 }); when(headRef.getObjectId()).thenReturn(newObjectId); @@ -804,13 +803,8 @@ public class JGitEnvironmentRepositoryTests { // refresh()->merge MergeCommand mergeCommand = mock(MergeCommand.class); when(git.merge()).thenReturn(mergeCommand); - when(mergeCommand.call()).thenThrow(new NotMergedException()); // here - // is - // our - // exception - // we - // are - // testing + // here is our exception we are testing + when(mergeCommand.call()).thenThrow(new NotMergedException()); // refresh()->hardReset ResetCommand resetCommand = mock(ResetCommand.class); @@ -820,7 +814,7 @@ public class JGitEnvironmentRepositoryTests { // refresh()->return // git.getRepository().findRef("HEAD").getObjectId().getName(); Ref headRef = mock(Ref.class); - when(this.database.getRef(anyString())).thenReturn(headRef); + when(this.database.findRef(anyString())).thenReturn(headRef); ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 }); when(headRef.getObjectId()).thenReturn(newObjectId); @@ -1135,13 +1129,8 @@ public class JGitEnvironmentRepositoryTests { when(git.branchDelete()).thenReturn(deleteBranchCommand); when(deleteBranchCommand.setBranchNames(eq("feature/deletedBranchFromOrigin"))).thenReturn(deleteBranchCommand); when(deleteBranchCommand.setForce(true)).thenReturn(deleteBranchCommand); - when(deleteBranchCommand.call()).thenThrow(new NotMergedException()); // here - // is - // our - // exception - // we - // are - // testing + // here is our exception we are testing + when(deleteBranchCommand.call()).thenThrow(new NotMergedException()); // refresh()->checkout CheckoutCommand checkoutCommand = mock(CheckoutCommand.class); @@ -1167,7 +1156,7 @@ public class JGitEnvironmentRepositoryTests { // refresh()->return // git.getRepository().findRef("HEAD").getObjectId().getName(); Ref headRef = mock(Ref.class); - when(this.database.getRef(anyString())).thenReturn(headRef); + when(this.database.findRef(anyString())).thenReturn(headRef); ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 }); when(headRef.getObjectId()).thenReturn(newObjectId);