def test_get_protocol_keys_attempts_retrival(self, protocol): auth_id = factory.make_name('auth_id') if protocol == KEYS_PROTOCOL_TYPE.LP: mock_get_keys = self.patch(keys_module, 'get_launchpad_ssh_keys') else: mock_get_keys = self.patch(keys_module, 'get_github_ssh_keys') get_protocol_keys(protocol, auth_id) self.assertThat(mock_get_keys, MockCalledOnceWith(auth_id))
def import_keys(self, user): """Save SSH keys.""" # Avoid circular imports. from maasserver.models.sshkey import SSHKey keys = get_protocol_keys(self.protocol, self.auth_id) return [ SSHKey.objects.get_or_create(key=key, user=user, keysource=self)[0] for key in keys]