Skip to content

Commit 1ce443c

Browse files
committed
[JENKINS-68562] Add unit test for HTTPS remote URLs
1 parent aa42d69 commit 1ce443c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/main/java/hudson/plugins/git/GitSCM.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,8 @@ public void checkout(Run<?, ?> build, Launcher launcher, FilePath workspace, Tas
13941394
}
13951395
}
13961396

1397-
private void abortIfSourceIsLocal() throws AbortException {
1397+
/* Package protected for test access */
1398+
void abortIfSourceIsLocal() throws AbortException {
13981399
for (UserRemoteConfig userRemoteConfig: getUserRemoteConfigs()) {
13991400
String remoteUrl = userRemoteConfig.getUrl();
14001401
if (!isRemoteUrlValid(remoteUrl)) {

src/test/java/hudson/plugins/git/GitSCMUnitTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package hudson.plugins.git;
2525

26+
import hudson.AbortException;
2627
import hudson.EnvVars;
2728
import static hudson.plugins.git.GitSCM.createRepoList;
2829
import hudson.plugins.git.browser.GitRepositoryBrowser;
@@ -43,6 +44,8 @@
4344
import org.junit.Test;
4445
import static org.junit.Assert.assertFalse;
4546
import static org.junit.Assert.assertTrue;
47+
import static org.junit.Assert.fail;
48+
import org.jvnet.hudson.test.Issue;
4649
import static org.hamcrest.MatcherAssert.*;
4750
import static org.hamcrest.Matchers.*;
4851

@@ -338,4 +341,17 @@ public void testSetDoGenerateSubmoduleConfigurations() {
338341
/* Confirms the passed value `true` is ignored */
339342
assertFalse(gitSCM.getDoGenerateSubmoduleConfigurations());
340343
}
344+
345+
@Issue("JENKINS-68562")
346+
@Test
347+
public void testAbortIfSourceIsLocal() {
348+
GitSCM gitSCM = new GitSCM(createRepoList(repoURL, null),
349+
Collections.singletonList(new BranchSpec("master")),
350+
null, null, Collections.emptyList());
351+
try {
352+
gitSCM.abortIfSourceIsLocal();
353+
} catch (AbortException e) {
354+
fail("https remote URLs should always be valid");
355+
}
356+
}
341357
}

0 commit comments

Comments
 (0)