qubesadmin.tests package

Submodules

qubesadmin.tests.app module

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

Bases: qubesadmin.tests.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]
class qubesadmin.tests.app.TC_10_QubesBase(methodName='runTest')[source]

Bases: qubesadmin.tests.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_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]
class qubesadmin.tests.app.TC_20_QubesLocal(methodName='runTest')[source]

Bases: unittest.case.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_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: unittest.case.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_010_run_service()[source]
test_011_run_service_filter_esc()[source]
test_012_run_service_user()[source]
test_013_run_service_default_target()[source]

qubesadmin.tests.devices module

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

Bases: qubesadmin.tests.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]

qubesadmin.tests.errors module

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

Bases: qubesadmin.tests.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: qubesadmin.tests.QubesTestCase

mock_coroutine(mock, *args, **kwargs)[source]
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]
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_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: qubesadmin.tests.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: qubesadmin.tests.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: qubesadmin.tests.QubesTestCase

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

Bases: qubesadmin.tests.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: qubesadmin.tests.QubesTestCase

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

Bases: qubesadmin.tests.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: qubesadmin.tests.QubesTestCase

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

Bases: qubesadmin.tests.QubesTestCase

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

Bases: qubesadmin.tests.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: qubesadmin.tests.QubesTestCase

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

Bases: qubesadmin.tests.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: qubesadmin.tests.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: qubesadmin.firewall.RuleChoice

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

qubesadmin.tests.label module

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

Bases: qubesadmin.tests.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: qubesadmin.tests.QubesTestCase

test_000_list()[source]
test_010_config()[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: qubesadmin.tests.storage.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: qubesadmin.tests.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: qubesadmin.tests.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: qubesadmin.app.QubesBase

actual_calls = None

actual calls made

expected_calls = None

expected calls and saved replies for them

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

Execute Admin API method.

Only one of payload and payload_stream can be specified.

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
Return type:

subprocess.Popen

service_calls = None

rpc service calls

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

Bases: unittest.case.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)[source]

Bases: object

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

Bases: object

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

Bases: dict