Skip to content

Commit

Permalink
ssh test suite improvements for running on CentOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mjuric committed Jan 20, 2020
1 parent 9ebf1a5 commit 2f4e846
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
15 changes: 7 additions & 8 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ SSH test setups:
# run this
./fixtures/remote-ssh-home/init-git.sh

# add this to ~/.ssh/config (create the ~/.ssh/localhost identity first)
Host localhost
HostName localhost
User mjuric
IdentityFile ~/.ssh/localhost
# create identities
ssh-keygen -C git-clone-completion -N '' -f ~/.ssh/git-clone-completion

# add this to ~/.ssh/config (create the ~/.ssh/git-clone-completion identity first)
Host test-dummy-*
HostName localhost
User mjuric
IdentityFile ~/.ssh/localhost
IdentitiesOnly yes
IdentityFile ~/.ssh/git-clone-completion

# add this to ~/.ssh/authorized_keys
```
command="~/projects/github.com/mjuric/git-clone-completion/tests/ssh-preflight.sh" ...public-key...
# echo "command=\"~/projects/github.com/mjuric/git-clone-completion/tests/ssh-preflight.sh\" $(cat ~/.ssh/git-clone-completion.pub)" >> ~/.ssh/authorized_keys
command="~/projects/github.com/mjuric/git-clone-completion/tests/ssh-preflight.sh" ...contents of ~/.ssh/git-clone-completion.pub...
```

## Running
Expand Down
18 changes: 9 additions & 9 deletions tests/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
class TestSSH:
def test_basic(self, bash):
for cmdline, expected_result in [
("git clone loc", []), # initially has no autocompletions
("git clone localhost:f", ['oo/']),
("git clone localhost:foo/", ['rep ']),
("git clone lo", ['calhost:']) # should remembe the hostnme after a successful login
("git clone test-dummy-loc", []), # initially has no autocompletions
("git clone test-dummy-localhost:f", ['oo/']),
("git clone test-dummy-localhost:foo/", ['rep ']),
("git clone test-dummy-lo", ['calhost:']) # should remembe the hostnme after a successful login
]:
expected_result.sort()

Expand All @@ -17,10 +17,10 @@ def test_basic(self, bash):

def test_weird(self, bash):
for cmdline, expected_result in [
("git clone localhost:w", [ 'eird/' ]),
("git clone localhost:weird/", [ r'weird/a\ b\ c/', r'weird/x\ \&\ \[\]\ \:\ \$\ xx\ \?/', r'weird/bar/', r'weird/x\ \=\ y/']),
("git clone localhost:weird/x\\ \\", [ r'weird/x\ \&\ \[\]\ \:\ \$\ xx\ \?/', r'weird/x\ \=\ y/']), # test completion on escaped character
(r"git clone localhost:weird/x\ \=\ ", [ r'y/' ]),
("git clone test-dummy-localhost:w", [ 'eird/' ]),
("git clone test-dummy-localhost:weird/", [ r'weird/a\ b\ c/', r'weird/x\ \&\ \[\]\ \:\ \$\ xx\ \?/', r'weird/bar/', r'weird/x\ \=\ y/']),
("git clone test-dummy-localhost:weird/x\\ \\", [ r'weird/x\ \&\ \[\]\ \:\ \$\ xx\ \?/', r'weird/x\ \=\ y/']), # test completion on escaped character
(r"git clone test-dummy-localhost:weird/x\ \=\ ", [ r'y/' ]),
]:
expected_result.sort()

Expand All @@ -46,7 +46,7 @@ def test_cache_expiration(self, bash):

# verify that re-adding localhost won't squeeze test-dummy-0 out of the cache
# and that test-dummy-1 got squeezed out
assert bash.complete("git clone localhost:f") == [ 'oo/' ], f"Unexpected completion for `{cmdline}`"
assert bash.complete("git clone test-dummy-localhost:f") == [ 'oo/' ], f"Unexpected completion for `{cmdline}`"
assert bash.complete("git clone test-dummy-0") == [ ':' ], f"Unexpected completion for `{cmdline}`"
assert bash.complete("git clone test-dummy-1") == [], f"Didn't expire a host from cache"
except:
Expand Down

0 comments on commit 2f4e846

Please sign in to comment.