##// END OF EJS Templates
ssh: fixed tests for disabled ssh support
marcink -
r2047:863217cc default
parent child Browse files
Show More
@@ -18,6 +18,7 b''
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 import mock
21 22 import pytest
22 23 from rhodecode.model.db import User, UserIpMap
23 24 from rhodecode.model.meta import Session
@@ -283,4 +284,17 b' class TestAdminPermissionsController(Tes'
283 284 dict(csrf_token=self.csrf_token), status=302)
284 285
285 286 assert_session_flash(
286 response, 'SSH key support is disabled in .ini file')
287 response, 'Updated SSH keys file')
288
289 def test_ssh_keys_update_disabled(self):
290 self.log_user()
291
292 from rhodecode.apps.admin.views.permissions import AdminPermissionsView
293 with mock.patch.object(AdminPermissionsView, 'ssh_enabled',
294 return_value=False):
295 response = self.app.post(
296 route_path('admin_permissions_ssh_keys_update'),
297 dict(csrf_token=self.csrf_token), status=302)
298
299 assert_session_flash(
300 response, 'SSH key support is disabled in .ini file') No newline at end of file
@@ -371,6 +371,10 b' class AdminPermissionsView(BaseAppView, '
371 371 c.whitelist_views = whitelist_views
372 372 return self._get_template_context(c)
373 373
374 def ssh_enabled(self):
375 return self.request.registry.settings.get(
376 'ssh.generate_authorized_keyfile')
377
374 378 @LoginRequired()
375 379 @HasPermissionAllDecorator('hg.admin')
376 380 @view_config(
@@ -379,6 +383,7 b' class AdminPermissionsView(BaseAppView, '
379 383 def ssh_keys(self):
380 384 c = self.load_default_context()
381 385 c.active = 'ssh_keys'
386 c.ssh_enabled = self.ssh_enabled()
382 387 return self._get_template_context(c)
383 388
384 389 @LoginRequired()
@@ -460,8 +465,7 b' class AdminPermissionsView(BaseAppView, '
460 465 _ = self.request.translate
461 466 self.load_default_context()
462 467
463 ssh_enabled = self.request.registry.settings.get(
464 'ssh.generate_authorized_keyfile')
468 ssh_enabled = self.ssh_enabled()
465 469 key_file = self.request.registry.settings.get(
466 470 'ssh.authorized_keys_file_path')
467 471 if ssh_enabled:
@@ -642,7 +642,7 b' svn.proxy.location_root = /'
642 642 ## Defines if the authorized_keys file should be written on any change of
643 643 ## user ssh keys, setting this to false also disables posibility of adding
644 644 ## ssh keys for users from web interface.
645 ssh.generate_authorized_keyfile = false
645 ssh.generate_authorized_keyfile = true
646 646
647 647 ## Options for ssh, default is `no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding`
648 648 # ssh.authorized_keys_ssh_opts =
@@ -650,7 +650,7 b' ssh.generate_authorized_keyfile = false'
650 650 ## File to generate the authorized keys together with options
651 651 ## It is possible to have multiple key files specified in `sshd_config` e.g.
652 652 ## AuthorizedKeysFile %h/.ssh/authorized_keys %h/.ssh/authorized_keys_rhodecode
653 ssh.authorized_keys_file_path = ~/.ssh/authorized_keys_rhodecode
653 ssh.authorized_keys_file_path = %(here)s/rc/authorized_keys_rhodecode
654 654
655 655 ## Command to execute the SSH wrapper. The binary is available in the
656 656 ## rhodecode installation directory.
General Comments 0
You need to be logged in to leave comments. Login now