def test_is_setup_with_rsa(keys_directory, call_action): """is_setup should work with RSA configuration.""" with patch('plinth.actions.superuser_run', call_action): (keys_directory / 'pki').mkdir() dh_params_file = keys_directory / 'pki' / 'dh.pem' dh_params_file.write_text('some content') assert openvpn.is_setup() os.remove(dh_params_file)
def test_is_setup_with_ecc(keys_directory, call_action): """is_setup should work with RSA configuration.""" with patch('plinth.actions.superuser_run', call_action): (keys_directory / 'pki' / 'ecparams').mkdir(parents=True) ec_params_file = keys_directory / 'pki' / 'ecparams' / 'somecurve.pem' ec_params_file.write_text('some content') assert openvpn.is_setup() os.remove(ec_params_file)
def setup(_): """Start the setup process.""" if not openvpn.is_setup(): actions.superuser_run('openvpn', ['setup'], run_in_background=True) openvpn.app.enable() return redirect('openvpn:index')
def get_context_data(self, *args, **kwargs): """Add additional context data for template.""" context = super().get_context_data(*args, **kwargs) context['status'] = { 'is_setup': openvpn.is_setup(), } context['using_ecc'] = openvpn.is_using_ecc() return context
def get_status(): """Get the current settings from OpenVPN server.""" return { 'is_setup': openvpn.is_setup(), 'setup_running': bool(setup_process), 'enabled': openvpn.service.is_enabled(), 'is_running': openvpn.service.is_running() }
def setup(request): """Start the setup process.""" openvpn.service.notify_enabled(None, True) global setup_process if not openvpn.is_setup() and not setup_process: setup_process = actions.superuser_run('openvpn', ['setup'], async=True) return redirect('openvpn:index')
def get_status(): """Get the current settings from OpenVPN server.""" status = {'is_setup': openvpn.is_setup(), 'setup_running': False, 'enabled': openvpn.is_enabled(), 'is_running': openvpn.is_running()} status['setup_running'] = bool(setup_process) return status
def setup(request): """Start the setup process.""" global setup_process if not openvpn.is_setup() and not setup_process: setup_process = actions.superuser_run('openvpn', ['setup'], run_in_background=True) openvpn.app.enable() return redirect('openvpn:index')
def get_context_data(self, *args, **kwargs): """Add additional context data for template.""" context = super().get_context_data(*args, **kwargs) context['status'] = { 'is_setup': openvpn.is_setup(), 'setup_running': bool(openvpn.setup_process), } context['refresh_page_sec'] = 3 if context['status'][ 'setup_running'] else None return context
def setup(request): """Start the setup process.""" openvpn.service.notify_enabled(None, True) global setup_process if not openvpn.is_setup() and not setup_process: setup_process = actions.superuser_run('openvpn', ['setup'], run_in_background=True) openvpn.add_shortcut() return redirect('openvpn:index')
def get_status(): """Get the current settings from OpenVPN server.""" status = { 'is_setup': openvpn.is_setup(), 'setup_running': False, 'enabled': openvpn.is_enabled(), 'is_running': openvpn.is_running() } status['setup_running'] = bool(setup_process) return status
def ecc(_): """Migrate from RSA to ECC.""" if openvpn.is_setup(): actions.superuser_run('openvpn', ['setup'], run_in_background=True) return redirect('openvpn:index')