Skip to content

Commit 19b6e5b

Browse files
committed
Added ssh-key generation per test user.
1 parent 55315da commit 19b6e5b

3 files changed

Lines changed: 45 additions & 19 deletions

File tree

client/deis.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ def _newname(template="Thread-{}"):
196196

197197

198198
FRAMES = {
199-
'arrow': ['^', '>', 'v', '<'],
199+
'arrow': ['^', '>', 'v', '<'],
200200
'dots': ['...', 'o..', '.o.', '..o'],
201201
'ligatures': ['bq', 'dp', 'qb', 'pd'],
202202
'lines': [' ', '-', '=', '#', '=', '-'],
203-
'slash': ['-', '\\', '|', '/'],
203+
'slash': ['-', '\\', '|', '/'],
204204
}
205205

206206

@@ -1730,13 +1730,13 @@ def providers_discover(self, args): # noqa
17301730
for provider, name, field in provider_data:
17311731
creds = get_provider_creds(provider)
17321732
if creds:
1733-
print ("Found {} credentials: {}".format(name, creds[field]))
1734-
inp = raw_input('Import these credentials? (y/n) : ')
1733+
print ("Discovered {} credentials: {}".format(name, creds[field]))
1734+
inp = raw_input("Import {} credentials? (y/n) : ".format(name))
17351735
if inp.lower().strip('\n') != 'y':
17361736
print('Aborting.')
17371737
else:
17381738
body = {'creds': json.dumps(creds)}
1739-
sys.stdout.write("Uploading {} credentials... ".format(provider))
1739+
sys.stdout.write("Uploading {} credentials... ".format(name))
17401740
sys.stdout.flush()
17411741
endpoint = "/api/providers/{}".format(provider)
17421742
response = self._dispatch('patch', endpoint, json.dumps(body))
@@ -1745,7 +1745,7 @@ def providers_discover(self, args): # noqa
17451745
else:
17461746
raise ResponseError(response)
17471747
else:
1748-
print("No {} credentials discovered.".format(provider))
1748+
print("No {} credentials discovered.".format(name))
17491749

17501750
# Check for locally booted Deis Controller VM
17511751
try:
@@ -1759,7 +1759,7 @@ def providers_discover(self, args): # noqa
17591759
# resides, eg; my-deis-code-folder_default_1383326629
17601760
deis_codebase_folder = self._session.git_root().split('/')[-1]
17611761
if deis_codebase_folder in running_vms:
1762-
print("Detected locally running Deis Controller VM")
1762+
print("Discovered locally running Deis Controller VM")
17631763
# In order for the Controller to be able to boot Vagrant VMs it needs to run commands
17641764
# on the host machine. It does this via an SSH server. In order to access that server
17651765
# we need to send the current user's name and host.
@@ -1792,7 +1792,7 @@ def providers_discover(self, args): # noqa
17921792
else:
17931793
raise ResponseError(response)
17941794
else:
1795-
print("No Vagrant VMs detected")
1795+
print("No Vagrant VMs discovered.")
17961796

17971797
def providers_info(self, args):
17981798
"""

client/tests/test_apps.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def tearDownClass(cls):
4040
# delete the formation
4141
child = pexpect.spawn("{} formations:destroy {} --confirm={}".format(
4242
DEIS, cls.formation, cls.formation))
43-
child.expect('done in ', timeout=5*60)
43+
child.expect('done in ', timeout=5 * 60)
4444
child.expect(pexpect.EOF)
4545
teardown(cls.username, cls.password, cls.repo_dir)
4646

@@ -49,7 +49,7 @@ def test_create(self):
4949
self.assertIsNotNone(self.formation)
5050
child = pexpect.spawn("{} create --formation={}".format(
5151
DEIS, self.formation))
52-
child.expect('done, created (?P<name>[-_\w]+)')
52+
child.expect('done, created (?P<name>[-_\w]+)', timeout=5 * 60)
5353
app = child.match.group('name')
5454
child.expect('Git remote deis added')
5555
child.expect(pexpect.EOF)
@@ -60,7 +60,8 @@ def test_create(self):
6060
apps = re.findall(r'([-_\w]+) {\w?}', child.before)
6161
self.assertIn(app, apps)
6262
# destroy the app
63-
child = pexpect.spawn("{} apps:destroy --confirm={}".format(DEIS, app))
63+
child = pexpect.spawn("{} apps:destroy --confirm={}".format(DEIS, app),
64+
timeout=5 * 60)
6465
child.expect('Git remote deis removed')
6566
child.expect(pexpect.EOF)
6667

@@ -69,7 +70,7 @@ def test_destroy(self):
6970
self.assertIsNotNone(self.formation)
7071
child = pexpect.spawn("{} apps:create --formation={}".format(
7172
DEIS, self.formation))
72-
child.expect('done, created ([-_\w]+)')
73+
child.expect('done, created ([-_\w]+)', timeout=5 * 60)
7374
app = child.match.group(1)
7475
child.expect(pexpect.EOF)
7576
# check that it's in the list of apps
@@ -108,7 +109,7 @@ def test_list(self):
108109
# delete the app
109110
child = pexpect.spawn("{} apps:destroy --app={} --confirm={}".format(
110111
DEIS, app, app))
111-
child.expect('done in ', timeout=5*60)
112+
child.expect('done in ', timeout=5 * 60)
112113
child.expect(pexpect.EOF)
113114
# list apps and get their names
114115
child = pexpect.spawn("{} apps:list".format(DEIS))
@@ -142,7 +143,7 @@ def test_info(self):
142143
# delete the app
143144
child = pexpect.spawn("{} apps:destroy --app={} --confirm={}".format(
144145
DEIS, app, app))
145-
child.expect('done in ', timeout=5*60)
146+
child.expect('done in ', timeout=5 * 60)
146147
child.expect(pexpect.EOF)
147148

148149
# def test_calculate(self):

client/tests/utils.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import os.path
88
import random
9+
import re
910
import shutil
1011
import tempfile
1112
from uuid import uuid4
@@ -22,14 +23,14 @@
2223
print 'Error: env var DEIS_SERVER must point to a Deis controller URL.'
2324
DEIS_TEST_FLAVOR = os.environ.get('DEIS_TEST_FLAVOR', 'ec2-us-west-2')
2425
REPOSITORIES = {
25-
'Clojure': 'https://github.com/opdemand/example-clojure-ring.git',
26+
# 'Clojure': 'https://github.com/opdemand/example-clojure-ring.git',
2627
# 'Python': 'https://github.com/opdemand/example-python-django.git',
2728
'Python': 'https://github.com/opdemand/example-python-flask.git',
2829
'Java': 'https://github.com/opdemand/example-java-jetty.git',
2930
'Go': 'https://github.com/opdemand/example-go.git',
3031
'Node.js': 'https://github.com/opdemand/example-nodejs-express.git',
3132
# 'Ruby/Rails': 'https://github.com/opdemand/example-rails-helloworld.git',
32-
'Ruby/Rails': 'https://github.com/opdemand/example-rails-todo.git',
33+
# 'Ruby/Rails': 'https://github.com/opdemand/example-rails-todo.git',
3334
'Ruby/Rack': 'https://github.com/opdemand/example-ruby-sinatra.git',
3435
}
3536

@@ -44,12 +45,21 @@ def purge(username, password):
4445
child.expect('\? \(y/n\) ')
4546
child.sendline('y')
4647
child.expect(pexpect.EOF)
48+
ssh_path = os.path.expanduser('~/.ssh')
49+
child = pexpect.spawn(os.path.expanduser(
50+
"rm -f {}/{}*".format(ssh_path, username)))
51+
child.expect(pexpect.EOF)
4752

4853

4954
def register():
5055
"""Register a new Deis user from the command line."""
5156
username = "autotester-{}".format(uuid4().hex[:4])
5257
password = 'password'
58+
ssh_path = os.path.expanduser('~/.ssh')
59+
child = pexpect.spawn("ssh-keygen -f /{}/{} -t rsa -N '' -C {}".format(
60+
ssh_path, username, username))
61+
child.expect("Your public key has been saved")
62+
child.expect(pexpect.EOF)
5363
child = pexpect.spawn("{} register {}".format(DEIS, DEIS_SERVER))
5464
child.expect('username: ')
5565
child.sendline(username)
@@ -60,9 +70,24 @@ def register():
6070
child.expect('email: ')
6171
child.sendline('autotest@opdemand.com')
6272
child.expect('Which would you like to use with Deis')
63-
child.sendline('1')
64-
child.expect('Import these credentials\? \(y/n\) :')
65-
child.sendline('y')
73+
for index, key in re.findall('(\d)\) ([ \S]+)', child.before):
74+
# TODO: can't use our generated key--gitosis error!
75+
# if username in key:
76+
if 'id_rsa' in key:
77+
child.sendline(index)
78+
break
79+
opt = child.expect(['Import EC2 credentials\? \(y/n\) :',
80+
'No EC2 credentials discovered.'])
81+
if opt == 0:
82+
child.sendline('y')
83+
opt = child.expect(['Import Rackspace credentials\? \(y/n\) :',
84+
'No Rackspace credentials discovered.'])
85+
if opt == 0:
86+
child.sendline('y')
87+
opt = child.expect(['Import DigitalOcean credentials\? \(y/n\) :',
88+
'No DigitalOcean credentials discovered.'])
89+
if opt == 0:
90+
child.sendline('y')
6691
child.expect(pexpect.EOF)
6792
return username, password
6893

0 commit comments

Comments
 (0)