Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 63bbba6

Browse files
committed
transport: ssh, travis tests
1 parent fa9dd83 commit 63bbba6

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

.travis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ before_script:
2525
- make build-git
2626

2727
before_install:
28-
- eval "$(ssh-agent -s)"
29-
# we only decrypt the SSH key when we aren't in a pull request
30-
#- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash .travis/install_key.sh; fi'
31-
#- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export SSH_AUTH_SOCK="" ; fi'\
32-
# temporal fix skip of SSH test
33-
- export SSH_AUTH_SOCK=""
3428
- git config --global user.email "[email protected]"
3529
- git config --global user.name "Travis CI"
3630

31+
# we only decrypt the SSH key when we aren't in a pull request
32+
- >
33+
if [ "$TRAVIS_PULL_REQUEST" = "false" ] ; then \
34+
bash .travis/install_key.sh; \
35+
SSH_TEST_PRIVATE_KEY=$HOME/.travis/deploy.pem; \
36+
else \
37+
export SSH_AUTH_SOCK=""; \
38+
fi
39+
3740
install:
3841
- go get -v -t ./...
3942

.travis/install_key.sh

100644100755
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
openssl aes-256-cbc -K $encrypted_1477e58fe67a_key -iv $encrypted_1477e58fe67a_iv -in .travis/deploy.pem.enc -out .travis/deploy.pem -d
1+
#!/bin/bash
2+
export SSH_TEST_PRIVATE_KEY=$PWD/.travis/deploy.pem
3+
4+
openssl aes-256-cbc \
5+
-K $encrypted_1477e58fe67a_key \
6+
-iv $encrypted_1477e58fe67a_iv \
7+
-in .travis/deploy.pem.enc \
8+
-out .travis/deploy.pem -d
9+
210
chmod 600 .travis/deploy.pem
3-
ssh-add .travis/deploy.pem
11+

plumbing/transport/ssh/upload_pack_test.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ type UploadPackSuite struct {
1616
var _ = Suite(&UploadPackSuite{})
1717

1818
func (s *UploadPackSuite) SetUpSuite(c *C) {
19-
if os.Getenv("SSH_AUTH_SOCK") == "" {
20-
c.Skip("SSH_AUTH_SOCK is not set")
21-
}
22-
19+
s.setAuthBuilder(c)
2320
s.UploadPackSuite.Client = DefaultClient
2421

2522
ep, err := transport.NewEndpoint("[email protected]:git-fixtures/basic.git")
@@ -34,3 +31,17 @@ func (s *UploadPackSuite) SetUpSuite(c *C) {
3431
c.Assert(err, IsNil)
3532
s.UploadPackSuite.NonExistentEndpoint = ep
3633
}
34+
35+
func (s *UploadPackSuite) setAuthBuilder(c *C) {
36+
privateKey := os.Getenv("SSH_TEST_PRIVATE_KEY")
37+
if privateKey != "" {
38+
DefaultAuthBuilder = func(user string) (AuthMethod, error) {
39+
return NewPublicKeysFromFile(user, privateKey)
40+
}
41+
}
42+
43+
if privateKey == "" && os.Getenv("SSH_AUTH_SOCK") == "" {
44+
c.Skip("SSH_AUTH_SOCK or SSH_TEST_PRIVATE_KEY are required")
45+
return
46+
}
47+
}

0 commit comments

Comments
 (0)