Commit c1edacd7 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Testing production servers: working with SSH

We've got a first test using SSH to pass.
This required adaptation of the logic to load SSH keys.

An important new requirement was to remove
the key from the server at the end of the
test session (quite contrary to what we
want to do for speed on development instances), because
it's just not acceptable for a key that *anyone can use*
to stay associated to an user on a production server,
even sandboxed (spam or worse).

A nice side effect is that we will be actually testing the
actual logic behind key registration (see
for a small incident involving that).

branch : stable
parent f613b1a6371a
from .utils.git import LocalRepo as GitLocalRepo
from .utils.hg import LocalRepo
from .utils.project import ProjectAccess
from .utils import suitable
def make_repo(tmpdir, name):
......@@ -39,6 +40,7 @@ def assert_pushed_repo(project, tmpdir, clone_name='clone'):
def test_owner_push_pull(test_project, tmpdir):
repo = make_repo(tmpdir, 'repo1')
ssh_cmd, ssh_url = test_project.owner_ssh_params
......@@ -347,14 +347,20 @@ class Heptapod:
def api_delete(self, **kwargs):
return self.api_request('DELETE', **kwargs)
def load_ssh_keys(self):
def load_ssh_keys(self, key_name_mapping=None):
"""Load client-side information to use SSH keys
Also makes sure the keys are actually usable (perms)
:param key_name_mapping: allow to control the variable part of the
key file name instead of simply using the user name.
if key_name_mapping is None:
key_name_mapping = {}
ssh_dir = Path(__file__).parent.parent / 'data' / 'ssh'
for user in self.users.values():
base_fname = 'id_rsa_heptapod_' +
for name, user in self.users.items():
base_fname = 'id_rsa_heptapod_' + key_name_mapping.get(name, name)
priv = ssh_dir / base_fname
pub = ssh_dir / (base_fname + '.pub')
......@@ -364,7 +370,6 @@ class Heptapod:
def upload_ssh_pub_keys(self):
"""Upload SSH public keys for all users to Heptapod."""
# it's really time to put the actual user object in our `self.users`
for user in self.users.values():
......@@ -520,6 +525,18 @@ class ProductionHeptapod(Heptapod):"All preparations done in %.2f seconds. "
"Proceeding with tests.", time.time() - start)
self.load_ssh_keys(key_name_mapping={ 'root',
def remove_ssh_keys(self):
for user in (self.group_owner, ):
def close(self):
super(ProductionHeptapod, self).close()
class OmnibusHeptapod(Heptapod):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment