mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
actions: Add a decorator for marking superuser actions
Any privileged action (a method) can be marked as such with the new decorator. A call to the method will be serialized into a sudo call (or later into a D-Bus call). The method arguments are turned to JSON and method is called as superuser. Arguments are de-serialized and are verified for type before the actual call as superuser. Return values are serialized and returned where they are de-serialized. Exceptions are also serialized and de-serialized. The method must have be strictly typed and should not have keyword-only arguments. Currently supported types are int, float, str, dict/Dict, list/List and Optional. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
3ec086411b
commit
4fed6921d6
6 files changed
+583
-8
No files matched your search
@@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Test module for module loading mechanism.
|
||||
"""
|
||||
|
||||
from unittest.mock import mock_open, patch
|
||||
|
||||
from plinth import module_loader
|
||||
|
||||
|
||||
@patch('pathlib.Path.open', mock_open(read_data='plinth.modules.apache\n'))
|
||||
def test_get_module_import_path():
|
||||
"""Returning the module import path."""
|
||||
import_path = module_loader.get_module_import_path('apache')
|
||||
assert import_path == 'plinth.modules.apache'
|
||||
Reference in new issue
Block a user