Skip to content

Commit c712229

Browse files
authored
Merge pull request #208 from 178inaba/identities_only
Add `-o IdentitiesOnly=yes` to test `GIT_SSH_COMMAND`
2 parents b378feb + 0160ffc commit c712229

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

get_git_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func TestGitGetter_sshKey(t *testing.T) {
279279
encodedKey := base64.StdEncoding.EncodeToString([]byte(testGitToken))
280280

281281
// avoid getting locked by a github authenticity validation prompt
282-
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no")
282+
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes")
283283
defer os.Setenv("GIT_SSH_COMMAND", "")
284284

285285
u, err := urlhelper.Parse("ssh://[email protected]/hashicorp/test-private-repo" +
@@ -309,7 +309,7 @@ func TestGitGetter_sshSCPStyle(t *testing.T) {
309309
encodedKey := base64.StdEncoding.EncodeToString([]byte(testGitToken))
310310

311311
// avoid getting locked by a github authenticity validation prompt
312-
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no")
312+
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes")
313313
defer os.Setenv("GIT_SSH_COMMAND", "")
314314

315315
// This test exercises the combination of the git detector and the
@@ -350,7 +350,7 @@ func TestGitGetter_sshExplicitPort(t *testing.T) {
350350
encodedKey := base64.StdEncoding.EncodeToString([]byte(testGitToken))
351351

352352
// avoid getting locked by a github authenticity validation prompt
353-
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no")
353+
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes")
354354
defer os.Setenv("GIT_SSH_COMMAND", "")
355355

356356
// This test exercises the combination of the git detector and the
@@ -391,7 +391,7 @@ func TestGitGetter_sshSCPStyleInvalidScheme(t *testing.T) {
391391
encodedKey := base64.StdEncoding.EncodeToString([]byte(testGitToken))
392392

393393
// avoid getting locked by a github authenticity validation prompt
394-
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no")
394+
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes")
395395
defer os.Setenv("GIT_SSH_COMMAND", "")
396396

397397
// This test exercises the combination of the git detector and the
@@ -499,7 +499,7 @@ func TestGitGetter_setupGitEnvWithExisting_sshKey(t *testing.T) {
499499
}
500500

501501
// start with an existing ssh command configuration
502-
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no")
502+
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes")
503503
defer os.Setenv("GIT_SSH_COMMAND", "")
504504

505505
cmd := exec.Command("/bin/sh", "-c", "echo $GIT_SSH_COMMAND")
@@ -510,7 +510,7 @@ func TestGitGetter_setupGitEnvWithExisting_sshKey(t *testing.T) {
510510
}
511511

512512
actual := strings.TrimSpace(string(out))
513-
if actual != "ssh -o StrictHostKeyChecking=no -i /tmp/foo.pem" {
513+
if actual != "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i /tmp/foo.pem" {
514514
t.Fatalf("unexpected GIT_SSH_COMMAND: %q", actual)
515515
}
516516
}

0 commit comments

Comments
 (0)