##// 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 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import mock
21 import pytest
22 import pytest
22 from rhodecode.model.db import User, UserIpMap
23 from rhodecode.model.db import User, UserIpMap
23 from rhodecode.model.meta import Session
24 from rhodecode.model.meta import Session
@@ -283,4 +284,17 b' class TestAdminPermissionsController(Tes'
283 dict(csrf_token=self.csrf_token), status=302)
284 dict(csrf_token=self.csrf_token), status=302)
284
285
285 assert_session_flash(
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 c.whitelist_views = whitelist_views
371 c.whitelist_views = whitelist_views
372 return self._get_template_context(c)
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 @LoginRequired()
378 @LoginRequired()
375 @HasPermissionAllDecorator('hg.admin')
379 @HasPermissionAllDecorator('hg.admin')
376 @view_config(
380 @view_config(
@@ -379,6 +383,7 b' class AdminPermissionsView(BaseAppView, '
379 def ssh_keys(self):
383 def ssh_keys(self):
380 c = self.load_default_context()
384 c = self.load_default_context()
381 c.active = 'ssh_keys'
385 c.active = 'ssh_keys'
386 c.ssh_enabled = self.ssh_enabled()
382 return self._get_template_context(c)
387 return self._get_template_context(c)
383
388
384 @LoginRequired()
389 @LoginRequired()
@@ -460,8 +465,7 b' class AdminPermissionsView(BaseAppView, '
460 _ = self.request.translate
465 _ = self.request.translate
461 self.load_default_context()
466 self.load_default_context()
462
467
463 ssh_enabled = self.request.registry.settings.get(
468 ssh_enabled = self.ssh_enabled()
464 'ssh.generate_authorized_keyfile')
465 key_file = self.request.registry.settings.get(
469 key_file = self.request.registry.settings.get(
466 'ssh.authorized_keys_file_path')
470 'ssh.authorized_keys_file_path')
467 if ssh_enabled:
471 if ssh_enabled:
@@ -642,7 +642,7 b' svn.proxy.location_root = /'
642 ## Defines if the authorized_keys file should be written on any change of
642 ## Defines if the authorized_keys file should be written on any change of
643 ## user ssh keys, setting this to false also disables posibility of adding
643 ## user ssh keys, setting this to false also disables posibility of adding
644 ## ssh keys for users from web interface.
644 ## ssh keys for users from web interface.
645 ssh.generate_authorized_keyfile = false
645 ssh.generate_authorized_keyfile = true
646
646
647 ## Options for ssh, default is `no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding`
647 ## Options for ssh, default is `no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding`
648 # ssh.authorized_keys_ssh_opts =
648 # ssh.authorized_keys_ssh_opts =
@@ -650,7 +650,7 b' ssh.generate_authorized_keyfile = false'
650 ## File to generate the authorized keys together with options
650 ## File to generate the authorized keys together with options
651 ## It is possible to have multiple key files specified in `sshd_config` e.g.
651 ## It is possible to have multiple key files specified in `sshd_config` e.g.
652 ## AuthorizedKeysFile %h/.ssh/authorized_keys %h/.ssh/authorized_keys_rhodecode
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 ## Command to execute the SSH wrapper. The binary is available in the
655 ## Command to execute the SSH wrapper. The binary is available in the
656 ## rhodecode installation directory.
656 ## rhodecode installation directory.
General Comments 0
You need to be logged in to leave comments. Login now