-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from test-editor/feature/allow_ssh_to_repo
add ssh transport configuration
- Loading branch information
Showing
6 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,81 @@ package org.testeditor.web.xtext.index.persistence | |
|
||
import java.io.File | ||
import org.eclipse.jgit.api.Git | ||
import org.eclipse.jgit.api.errors.TransportException | ||
import org.eclipse.jgit.lib.Constants | ||
import org.eclipse.jgit.revwalk.RevCommit | ||
import org.eclipse.jgit.transport.URIish | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.ExpectedException | ||
import org.junit.rules.TemporaryFolder | ||
|
||
class GitServiceInitTest extends AbstractGitTest { | ||
|
||
@Rule public TemporaryFolder keyfiles = new TemporaryFolder | ||
@Rule public ExpectedException expectedException = ExpectedException.none | ||
|
||
@Test | ||
def void cloneTriesToUsePrivateKeyIfConfigured() { | ||
// given | ||
val invalidPrivateKey = write(keyfiles.root, 'invalid-private-key-file', 'invalid-private-key-content') | ||
expectedException.expect(TransportException) | ||
expectedException.expectMessage('invalid privatekey') | ||
|
||
// when | ||
gitService.init(localRepoRoot.path, '[email protected]:test-editor/test-editor-examples.git', invalidPrivateKey.absolutePath, null) | ||
|
||
// then (expected exception is thrown) | ||
} | ||
|
||
@Test | ||
def void cloneUsesPrivateKeyIfConfiguredButFailsOnHostThen() { | ||
// given | ||
val dummyButValidPrivateKey = write(keyfiles.root, 'dummy-private-key-file', | ||
''' | ||
-----BEGIN RSA PRIVATE KEY BLOCK----- | ||
lQHYBFo7o+MBBADJg6nDraGCWwCCs4+J+VZP94htAXOgzY3LekOumSH55ywNPluM | ||
gc5FPljiCS+UNEl1yYk+oFshClXhVSevtur/mXgUYck9V8n81fOlJBKPowJ/KiC5 | ||
KdHRJX7SdUEvK0UymNsIEIhAyqGCT/9OcpIZSJy0mJoaY50da4rxaod9KQARAQAB | ||
AAP9FJmqGX/phTWfsrzVIqoOTHR7SjFzdu/XMVhEDQLzOeSLrfrpnvkyHgVb+WzY | ||
+VHzDzXVcEUyVl6uctpNXqWDa66dgbP/Cwwtjs8JT1ws919/9HuXtnC1mCvyTwHv | ||
zi4AA9I9dARvWc/urMzW1ywW+Xhf96qnX0sPvivw1YxwmQUCANluybZP0Wu+srTc | ||
4GFJtyZZwfPZZUWmApeo9CQ+VqQcVxs4OmvlO3BKsh+hVjOJdpTdfV7tzbpcp5DD | ||
TmeduqsCAO1CDFDi1LaW5lnKEHNlOMKv5d94BRJXW+nd9UjXVPm1U8tVZ1tfXZIo | ||
x4VZWIPIPdmvs1X8Xa/FkLqbJ0LsZ3sCAM+4mfcCuuRwUiiqyGPTh1LQ2aWFtWSU | ||
0Svw9y7RqSJhgCsNcJxpgQDUl7cQcQ0LgaGTMlvyzZ825xDHUi07dhek0bQjdGVz | ||
dGVkaXRvciA8dGVzdGVkaXRvckBleGFtcGxlLmNvbT6IuAQTAQIAIgUCWjuj4wIb | ||
AwYLCQgHAwIGFQgCCQo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HZ6kNpO+cMSyey6xPA6zZR2yNY0fgDHdh8mVzgghR6c/o= | ||
=KbQq | ||
-----END RSA PRIVATE KEY BLOCK----- | ||
''') | ||
expectedException.expect(TransportException) | ||
expectedException.expectMessage('unknown host') | ||
|
||
// when | ||
gitService.init(localRepoRoot.path, '[email protected]:test-editor/test-editor-examples.git', dummyButValidPrivateKey.absolutePath, null) | ||
|
||
// then (expected exception is thrown) | ||
} | ||
|
||
|
||
|
||
@Test | ||
def void clonesRemoteRepositoryWhenUninitialized() { | ||
|