ssh: fixed tests for disabled ssh support
This commit is contained in:
parent
77566e197e
commit
7c571b29bc
3 changed files with 23 additions and 5 deletions
|
|
@ -18,6 +18,7 @@
|
|||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
from rhodecode.model.db import User, UserIpMap
|
||||
from rhodecode.model.meta import Session
|
||||
|
|
@ -283,4 +284,17 @@ class TestAdminPermissionsController(TestController):
|
|||
dict(csrf_token=self.csrf_token), status=302)
|
||||
|
||||
assert_session_flash(
|
||||
response, 'SSH key support is disabled in .ini file')
|
||||
response, 'Updated SSH keys file')
|
||||
|
||||
def test_ssh_keys_update_disabled(self):
|
||||
self.log_user()
|
||||
|
||||
from rhodecode.apps.admin.views.permissions import AdminPermissionsView
|
||||
with mock.patch.object(AdminPermissionsView, 'ssh_enabled',
|
||||
return_value=False):
|
||||
response = self.app.post(
|
||||
route_path('admin_permissions_ssh_keys_update'),
|
||||
dict(csrf_token=self.csrf_token), status=302)
|
||||
|
||||
assert_session_flash(
|
||||
response, 'SSH key support is disabled in .ini file')
|
||||
|
|
@ -371,6 +371,10 @@ class AdminPermissionsView(BaseAppView, DataGridAppView):
|
|||
c.whitelist_views = whitelist_views
|
||||
return self._get_template_context(c)
|
||||
|
||||
def ssh_enabled(self):
|
||||
return self.request.registry.settings.get(
|
||||
'ssh.generate_authorized_keyfile')
|
||||
|
||||
@LoginRequired()
|
||||
@HasPermissionAllDecorator('hg.admin')
|
||||
@view_config(
|
||||
|
|
@ -379,6 +383,7 @@ class AdminPermissionsView(BaseAppView, DataGridAppView):
|
|||
def ssh_keys(self):
|
||||
c = self.load_default_context()
|
||||
c.active = 'ssh_keys'
|
||||
c.ssh_enabled = self.ssh_enabled()
|
||||
return self._get_template_context(c)
|
||||
|
||||
@LoginRequired()
|
||||
|
|
@ -460,8 +465,7 @@ class AdminPermissionsView(BaseAppView, DataGridAppView):
|
|||
_ = self.request.translate
|
||||
self.load_default_context()
|
||||
|
||||
ssh_enabled = self.request.registry.settings.get(
|
||||
'ssh.generate_authorized_keyfile')
|
||||
ssh_enabled = self.ssh_enabled()
|
||||
key_file = self.request.registry.settings.get(
|
||||
'ssh.authorized_keys_file_path')
|
||||
if ssh_enabled:
|
||||
|
|
|
|||
|
|
@ -642,7 +642,7 @@ svn.proxy.location_root = /
|
|||
## Defines if the authorized_keys file should be written on any change of
|
||||
## user ssh keys, setting this to false also disables posibility of adding
|
||||
## ssh keys for users from web interface.
|
||||
ssh.generate_authorized_keyfile = false
|
||||
ssh.generate_authorized_keyfile = true
|
||||
|
||||
## Options for ssh, default is `no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding`
|
||||
# ssh.authorized_keys_ssh_opts =
|
||||
|
|
@ -650,7 +650,7 @@ ssh.generate_authorized_keyfile = false
|
|||
## File to generate the authorized keys together with options
|
||||
## It is possible to have multiple key files specified in `sshd_config` e.g.
|
||||
## AuthorizedKeysFile %h/.ssh/authorized_keys %h/.ssh/authorized_keys_rhodecode
|
||||
ssh.authorized_keys_file_path = ~/.ssh/authorized_keys_rhodecode
|
||||
ssh.authorized_keys_file_path = %(here)s/rc/authorized_keys_rhodecode
|
||||
|
||||
## Command to execute the SSH wrapper. The binary is available in the
|
||||
## rhodecode installation directory.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue