qubesadmin.tests package

Subpackages

Submodules

qubesadmin.tests.app module

class qubesadmin.tests.app.TC_00_VMCollection(methodName='runTest')[source]

Bases: QubesTestCase

test_000_list()[source]
test_001_getitem()[source]
test_002_in()[source]
test_003_iter()[source]
test_004_delitem()[source]
test_005_keys()[source]
test_006_values()[source]
test_007_getitem_blind_mode()[source]
test_008_in_blind_mode()[source]
test_009_getitem_cache_class()[source]
test_010_getitem_cache_power_state()[source]
test_011_getitem_non_cache_power_state()[source]
test_012_getitem_cached_object()[source]
class qubesadmin.tests.app.TC_10_QubesBase(methodName='runTest')[source]

Bases: QubesTestCase

clone_setup_common_calls(src, dst)[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

test_010_new_simple()[source]
test_011_new_template()[source]
test_012_new_template_based()[source]
test_013_new_objects_params()[source]
test_014_new_pool()[source]
test_015_new_pools()[source]
test_016_new_template_based_default()[source]
test_020_get_label()[source]
test_021_get_nonexistant_label()[source]
test_030_clone()[source]
test_031_clone_object()[source]
test_032_clone_pool()[source]
test_033_clone_pools()[source]
test_034_clone_class_change()[source]
test_035_clone_fail()[source]
test_036_clone_ignore_errors_prop()[source]
test_037_clone_ignore_errors_feature()[source]
test_038_clone_ignore_errors_tag()[source]
test_039_clone_ignore_errors_firewall()[source]
test_040_clone_ignore_errors_storage()[source]
test_041_clone_fail_storage()[source]
test_042_clone_nondefault_pool()[source]
test_043_clone_devices()[source]
test_044_clone_devices_fail()[source]
test_050_automatic_reset_cache()[source]
class qubesadmin.tests.app.TC_20_QubesLocal(methodName='runTest')[source]

Bases: TestCase

get_request()[source]

Get request sent to “qubesd” mock

listen_and_send(send_data)[source]

Listen on socket and send data in response.

Parameters:

send_data (bytes) – data to send

setUp()[source]

Hook method for setting up the test fixture before exercising it.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

test_000_qubesd_call()[source]
test_001_qubesd_call_none_arg()[source]
test_002_qubesd_call_none_payload()[source]
test_003_qubesd_call_payload_stream()[source]
test_004_qubesd_call_payload_stream_proc()[source]
test_005_qubesd_call_payload_stream_with_prefix()[source]
test_010_run_service()[source]
test_011_run_service_filter_esc()[source]
test_012_run_service_user()[source]
test_013_run_service_default_target()[source]
class qubesadmin.tests.app.TC_30_QubesRemote(methodName='runTest')[source]

Bases: TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

set_proc_stdout(send_data)[source]
tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

test_000_qubesd_call()[source]
test_001_qubesd_call_none_arg()[source]
test_002_qubesd_call_none_payload()[source]
test_003_qubesd_call_payload_stream()[source]
test_004_qubesd_call_payload_stream_with_prefix()[source]
test_010_run_service()[source]
test_011_run_service_filter_esc()[source]
test_012_run_service_user()[source]
test_013_run_service_default_target()[source]
test_014_run_service_no_autostart1()[source]
test_015_run_service_no_autostart2()[source]

qubesadmin.tests.devices module

class qubesadmin.tests.devices.TC_00_DeviceCollection(methodName='runTest')[source]

Bases: QubesTestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_available()[source]
test_001_available_desc()[source]
test_002_available_options()[source]
test_010_getitem()[source]
test_011_getitem_missing()[source]
test_020_attach()[source]
test_021_attach_options()[source]
test_022_attach_persistent()[source]
test_023_attach_persistent_options()[source]
test_030_detach()[source]
test_040_assignments()[source]
test_041_assignments_options()[source]
test_041_assignments_persistent()[source]
test_042_assignments_non_persistent()[source]
test_050_persistent()[source]
test_060_attached()[source]
test_070_update_persistent()[source]
test_071_update_persistent_false()[source]
test_072_list()[source]

qubesadmin.tests.errors module

class qubesadmin.tests.errors.TC_00_Errors(methodName='runTest')[source]

Bases: QubesTestCase

test_000_exception()[source]
test_001_exception_with_fields()[source]
test_002_exception_with_numbers()[source]
test_010_empty()[source]

qubesadmin.tests.events module

class qubesadmin.tests.events.TC_00_Events(methodName='runTest')[source]

Bases: QubesTestCase

async mock_coroutine(mock, *args, **kwargs)[source]
async mock_get_events_reader(stream, cleanup_func, expected_vm, vm=None)[source]
mock_open_unix_connection(expected_path, sock, path)[source]
read_all(sock)[source]
async send_events(stream, events)[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_handler_specific()[source]
test_001_handler_glob()[source]
test_002_handler_glob_partial()[source]
test_003_handler_error()[source]
test_010_listen_for_events()[source]
test_020_get_events_reader_local()[source]
test_021_get_events_reader_local_vm()[source]
test_022_get_events_reader_remote()[source]
test_023_get_events_reader_remote_vm()[source]
test_030_events_device()[source]

qubesadmin.tests.features module

class qubesadmin.tests.features.TC_00_Features(methodName='runTest')[source]

Bases: QubesTestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_list()[source]
test_010_get()[source]
test_011_get_none()[source]
test_012_get_none()[source]
test_013_get_default()[source]
test_020_set()[source]
test_021_set_bool()[source]
test_022_set_bool_false()[source]

qubesadmin.tests.firewall module

Tests for firewall API. This is mostly copy from core-admin

class qubesadmin.tests.firewall.TC_00_RuleChoice(methodName='runTest')[source]

Bases: QubesTestCase

test_000_accept_allowed()[source]
test_001_value_list()[source]
test_010_reject_others()[source]
class qubesadmin.tests.firewall.TC_01_Action(methodName='runTest')[source]

Bases: QubesTestCase

test_000_allowed_values()[source]
test_001_rule()[source]
class qubesadmin.tests.firewall.TC_02_DstHost(methodName='runTest')[source]

Bases: QubesTestCase

test_000_hostname()[source]
test_001_ipv4()[source]
test_002_ipv4_prefixlen()[source]
test_003_ipv4_parse_prefixlen()[source]
test_004_ipv4_invalid_prefix()[source]
test_005_ipv4_reject_shortened()[source]
test_006_ipv4_invalid_addr()[source]
test_007_ipv4_invalid_network()[source]
test_010_ipv6()[source]
test_011_ipv6_prefixlen()[source]
test_012_ipv6_parse_prefixlen()[source]
test_013_ipv6_invalid_prefix()[source]
test_014_ipv6_invalid_addr()[source]
test_015_ipv6_invalid_network()[source]
test_020_invalid_hostname()[source]
class qubesadmin.tests.firewall.TC_02_Proto(methodName='runTest')[source]

Bases: QubesTestCase

test_000_allowed_values()[source]
test_001_rule()[source]
class qubesadmin.tests.firewall.TC_03_DstPorts(methodName='runTest')[source]

Bases: QubesTestCase

test_000_single_str()[source]
test_001_single_int()[source]
test_002_range()[source]
test_003_invalid()[source]
test_004_reversed_range()[source]
test_005_out_of_range()[source]
class qubesadmin.tests.firewall.TC_04_IcmpType(methodName='runTest')[source]

Bases: QubesTestCase

test_000_number()[source]
test_001_str()[source]
test_002_invalid()[source]
class qubesadmin.tests.firewall.TC_05_SpecialTarget(methodName='runTest')[source]

Bases: QubesTestCase

test_000_allowed_values()[source]
test_001_rule()[source]
class qubesadmin.tests.firewall.TC_06_Expire(methodName='runTest')[source]

Bases: QubesTestCase

test_000_number()[source]
test_001_str()[source]
test_002_invalid()[source]
test_003_expired()[source]
class qubesadmin.tests.firewall.TC_07_Comment(methodName='runTest')[source]

Bases: QubesTestCase

test_000_str()[source]
class qubesadmin.tests.firewall.TC_10_Rule(methodName='runTest')[source]

Bases: QubesTestCase

test_000_simple()[source]
test_001_expire()[source]
test_002_dstports()[source]
test_003_reject_invalid()[source]
test_004_proto_change()[source]
test_005_parse_str()[source]
test_006_parse_str_comment()[source]
class qubesadmin.tests.firewall.TC_11_Firewall(methodName='runTest')[source]

Bases: QubesTestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_010_load_rules()[source]
test_020_set_rules()[source]
class qubesadmin.tests.firewall.TestOption(value)[source]

Bases: RuleChoice

another = 'another'
opt1 = 'opt1'
opt2 = 'opt2'

qubesadmin.tests.label module

class qubesadmin.tests.label.TC_00_Label(methodName='runTest')[source]

Bases: QubesTestCase

test_000_list()[source]
test_001_list_names()[source]
test_002_list_keys()[source]
test_003_list_items()[source]
test_010_get()[source]
test_011_get_color()[source]
test_012_get_index()[source]
test_024_get_icon()[source]

qubesadmin.tests.storage module

class qubesadmin.tests.storage.TestPool(methodName='runTest')[source]

Bases: QubesTestCase

test_000_list()[source]
test_010_config()[source]
test_011_usage()[source]
test_012_size_and_usage()[source]
test_020_volumes()[source]
test_030_pool_drivers()[source]
test_040_add()[source]
test_050_remove()[source]
class qubesadmin.tests.storage.TestPoolVolume(methodName='runTest')[source]

Bases: TestVMVolume

expect_info()[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_qubesd_call()[source]
test_001_fetch_info()[source]
test_010_pool()[source]
test_011_vid()[source]
test_021_revisions()[source]
test_022_revisions_empty()[source]
test_030_resize()[source]
test_031_revert()[source]
test_040_import_data()[source]
test_050_clone()[source]
test_050_clone_wrong_volume()[source]
class qubesadmin.tests.storage.TestVMVolume(methodName='runTest')[source]

Bases: QubesTestCase

expect_info()[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_qubesd_call()[source]
test_001_fetch_info()[source]
test_010_pool()[source]
test_011_vid()[source]
test_012_size()[source]
test_013_usage()[source]
test_014_rw()[source]
test_015_snap_on_start()[source]
test_016_save_on_stop()[source]
test_017_source_none()[source]
test_018_source()[source]
test_020_revisions_to_keep()[source]
test_021_revisions()[source]
test_022_revisions_empty()[source]
test_030_resize()[source]
test_031_revert()[source]
test_040_import_data()[source]
test_050_clone()[source]

qubesadmin.tests.tags module

class qubesadmin.tests.tags.TC_00_Tags(methodName='runTest')[source]

Bases: QubesTestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_list()[source]
test_010_get()[source]
test_011_get_missing()[source]
test_020_set()[source]
test_030_update()[source]
test_031_update_from_other()[source]
test_040_remove()[source]
test_040_remove_missing()[source]
test_050_discard()[source]
test_051_discard_missing()[source]

Module contents

class qubesadmin.tests.QubesTest[source]

Bases: QubesBase

actual_calls = None

actual calls made

expected_calls = None

expected Admin API calls and saved replies for them

expected_service_calls = None

expected qrexec service calls and saved replies for them

qubesd_call(dest, method, arg=None, payload=None, payload_stream=None)[source]

Execute Admin API method.

If payload and payload_stream are both specified, they will be sent in that order.

Parameters:
  • dest – Destination VM name

  • method – Full API method name (‘admin…’)

  • arg – Method argument (if any)

  • payload – Payload send to the method

  • payload_stream – file-like object to read payload from

Returns:

Data returned by qubesd (string)

Warning

payload_stream will get closed by this function

run_service(dest, service, **kwargs)[source]

Run qrexec service in a given destination

kwargs are passed verbatim to subprocess.Popen().

Parameters:
  • dest (str) – Destination - may be a VM name or empty string for default (for a given service)

  • service (str) – service name

  • filter_esc (bool) – filter escape sequences to protect terminal emulator

  • user (str) – username to run service as

  • localcmd (str) – Command to connect stdin/stdout to

  • wait (bool) – Wait service run

  • autostart (bool) – Automatically start the target VM

Return type:

subprocess.Popen

service_calls = None

rpc service calls

class qubesadmin.tests.QubesTestCase(methodName='runTest')[source]

Bases: TestCase

assertAllCalled()[source]
assertNotRaises(excClass, callableObj=None, *args, **kwargs)[source]

Fail if an exception of class excClass is raised by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

If called with callableObj omitted or None, will return a context object used like this:

with self.assertRaises(SomeException):
    do_something()

The context manager keeps a reference to the exception as the ‘exception’ attribute. This allows you to inspect the exception after the assertion:

with self.assertRaises(SomeException) as cm:
    do_something()
the_exception = cm.exception
self.assertEqual(the_exception.error_code, 3)
setUp()[source]

Hook method for setting up the test fixture before exercising it.

class qubesadmin.tests.TestProcess(input_callback=None, stdout=None, stderr=None, stdout_data=None)[source]

Bases: object

communicate(input=None)[source]
poll()[source]
store_input()[source]
wait()[source]
class qubesadmin.tests.TestVM(name, **kwargs)[source]

Bases: object

get_power_state()[source]
is_networked()[source]
class qubesadmin.tests.TestVMCollection[source]

Bases: dict

get_blind(key, default=None, /)

Return the value for key if key is in the dictionary, else default.