glance.tests.unit.common package

Submodules

glance.tests.unit.common.test_client module

class glance.tests.unit.common.test_client.TestClient(*args, **kwargs)[source]

Bases: testtools.testcase.TestCase

setUp()[source]
tearDown()[source]
test_http_encoding_headers()[source]
test_http_encoding_params()[source]
test_make_auth_plugin()[source]

glance.tests.unit.common.test_config module

class glance.tests.unit.common.test_config.TestDefaultConfig(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

setUp()[source]
test_osprofiler_disabled()[source]
class glance.tests.unit.common.test_config.TestPasteApp(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

setUp()[source]
test_get_path_non_exist()[source]
test_load_paste_app()[source]
test_load_paste_app_paste_config_not_found()[source]
test_load_paste_app_with_paste_config_file()[source]
test_load_paste_app_with_paste_flavor()[source]

glance.tests.unit.common.test_exception module

class glance.tests.unit.common.test_exception.GlanceExceptionTestCase(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_default_error_msg()[source]
test_default_error_msg_with_kwargs()[source]
test_non_unicode_error_msg()[source]
test_specified_error_msg()[source]
test_specified_error_msg_with_kwargs()[source]

glance.tests.unit.common.test_location_strategy module

class glance.tests.unit.common.test_location_strategy.TestLocationOrderStrategyModule(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

Test routines in glance.common.location_strategy.location_order

test_get_ordered_locations()[source]
class glance.tests.unit.common.test_location_strategy.TestLocationStrategy(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

Test routines in glance.common.location_strategy

setUp()[source]
test_choose_best_location()[source]
test_choose_best_location_with_none_or_empty_locations()[source]
test_get_ordered_locations()[source]
test_get_ordered_locations_with_none_or_empty_locations()[source]
test_load_strategy_module_with_deduplicating()[source]
test_load_strategy_module_with_init_exception()[source]
test_load_strategy_modules()[source]
test_verify_invalid_location_strategy()[source]
test_verify_valid_location_strategy()[source]
class glance.tests.unit.common.test_location_strategy.TestStoreTypeStrategyModule(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

Test routines in glance.common.location_strategy.store_type

test_get_ordered_locations()[source]
test_get_ordered_locations_with_invalid_store_name()[source]

glance.tests.unit.common.test_property_utils module

class glance.tests.unit.common.test_property_utils.TestPropertyRulesWithPolicies(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

setUp()[source]
tearDown()[source]
test_check_property_rules_create_all_permitted()[source]
test_check_property_rules_create_none_permitted()[source]
test_check_property_rules_create_permitted_specific_policy()[source]
test_check_property_rules_create_unpermitted_policy()[source]
test_check_property_rules_delete_all_permitted()[source]
test_check_property_rules_delete_none()[source]
test_check_property_rules_delete_none_permitted()[source]
test_check_property_rules_delete_permitted_specific_policy()[source]
test_check_property_rules_delete_unpermitted_policy()[source]
test_check_property_rules_read_all_permitted()[source]
test_check_property_rules_read_none()[source]
test_check_property_rules_read_none_permitted()[source]
test_check_property_rules_read_permitted_specific_policy()[source]
test_check_property_rules_read_unpermitted_policy()[source]
test_check_property_rules_update_all_permitted()[source]
test_check_property_rules_update_none()[source]
test_check_property_rules_update_none_permitted()[source]
test_check_property_rules_update_permitted_specific_policy()[source]
test_check_property_rules_update_unpermitted_policy()[source]
test_check_return_first_match()[source]
test_property_protection_with_malformed_rule()[source]
test_property_protection_with_multiple_policies()[source]
class glance.tests.unit.common.test_property_utils.TestPropertyRulesWithRoles(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

setUp()[source]
tearDown()[source]
test_check_case_insensitive_property_rules()[source]
test_check_property_rules_create_all_permitted()[source]
test_check_property_rules_create_none_permitted()[source]
test_check_property_rules_create_permitted_admin_role()[source]
test_check_property_rules_create_permitted_specific_role()[source]
test_check_property_rules_create_unpermitted_role()[source]
test_check_property_rules_delete_all_permitted()[source]
test_check_property_rules_delete_none()[source]
test_check_property_rules_delete_none_permitted()[source]
test_check_property_rules_delete_permitted_admin_role()[source]
test_check_property_rules_delete_permitted_specific_role()[source]
test_check_property_rules_delete_unpermitted_role()[source]
test_check_property_rules_invalid_action()[source]
test_check_property_rules_read_all_permitted()[source]
test_check_property_rules_read_none()[source]
test_check_property_rules_read_none_permitted()[source]
test_check_property_rules_read_permitted_admin_role()[source]
test_check_property_rules_read_permitted_specific_role()[source]
test_check_property_rules_read_unpermitted_role()[source]
test_check_property_rules_update_all_permitted()[source]
test_check_property_rules_update_none()[source]
test_check_property_rules_update_none_permitted()[source]
test_check_property_rules_update_permitted_admin_role()[source]
test_check_property_rules_update_permitted_specific_role()[source]
test_check_property_rules_update_unpermitted_role()[source]
test_check_return_first_match()[source]
test_is_property_protections_enabled_false()[source]
test_is_property_protections_enabled_true()[source]
test_property_config_loaded_in_order()[source]

Verify the order of loaded config sections matches that from the configuration file

test_property_protection_file_doesnt_exist()[source]
test_property_protection_with_malformed_rule()[source]
test_property_protection_with_missing_operation()[source]
test_property_protection_with_misspelt_operation()[source]
test_property_protection_with_mutually_exclusive_rule()[source]
test_property_protection_with_whitespace()[source]
test_property_rules_loaded_in_order()[source]

Verify rules are iterable in the same order as read from the config file

glance.tests.unit.common.test_property_utils.create_context(policy, roles=None)[source]

glance.tests.unit.common.test_rpc module

class glance.tests.unit.common.test_rpc.FakeResource[source]

Bases: object

Fake resource defining some methods that will be called later by the api.

count_images(context, images)[source]
get_all_images(context)[source]
get_images(context, keyword=None)[source]
raise_value_error(context)[source]
raise_weird_error(context)[source]
class glance.tests.unit.common.test_rpc.TestRPCClient(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

fake_request(method, url, body, headers)[source]
setUp()[source]
test_bulk_request()[source]
test_exception_raise()[source]
test_method_proxy()[source]
test_non_str_or_dict_response()[source]
test_rpc_exception()[source]
class glance.tests.unit.common.test_rpc.TestRPCController(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

setUp()[source]
test_register()[source]
test_reigster_excluded()[source]
test_reigster_filtered()[source]
test_reigster_refiner()[source]
test_request()[source]
test_request_exc()[source]
test_rpc_errors()[source]
test_rpc_exception_propagation()[source]
class glance.tests.unit.common.test_rpc.TestRPCJSONDeserializer(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_default_no_body()[source]
test_default_with_body()[source]
test_from_json()[source]
test_from_json_malformed()[source]
test_has_body_has_content_length()[source]
test_has_body_has_transfer_encoding()[source]
test_has_body_no_content_length()[source]
test_has_body_zero_content_length()[source]
test_no_body_no_content_length()[source]
test_to_json_with_date_format_value()[source]
class glance.tests.unit.common.test_rpc.TestRPCJSONSerializer(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_default()[source]
test_to_json()[source]
test_to_json_with_date_format_value()[source]
test_to_json_with_more_deep_format()[source]
glance.tests.unit.common.test_rpc.create_api()[source]

glance.tests.unit.common.test_scripts module

class glance.tests.unit.common.test_scripts.TestScripts(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

setUp()[source]
test_run_task()[source]

glance.tests.unit.common.test_semver module

class glance.tests.unit.common.test_semver.SemVerTestCase(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_label_comparison_as_long()[source]
test_label_comparison_as_string()[source]
test_long_conversion()[source]
test_major_comparison_as_long()[source]
test_minor_comparison_as_long()[source]
test_patch_comparison_as_long()[source]
test_too_large_version()[source]
test_too_long_numeric_segments()[source]

glance.tests.unit.common.test_signature_utils module

class glance.tests.unit.common.test_signature_utils.BadPublicKey[source]

Bases: object

verifier(signature, padding, hash_method)[source]
class glance.tests.unit.common.test_signature_utils.FakeCastellanCertificate(data, cert_format)[source]

Bases: object

format[source]
get_encoded()[source]
class glance.tests.unit.common.test_signature_utils.FakeCryptoCertificate(pub_key=<cryptography.hazmat.backends.openssl.rsa._RSAPublicKey object at 0x7f9eca1e45d0>, not_valid_before=datetime.datetime(2017, 2, 8, 23, 9, 56, 91020), not_valid_after=datetime.datetime(2017, 2, 9, 1, 9, 56, 91044))[source]

Bases: object

not_valid_after[source]
not_valid_before[source]
public_key()[source]
class glance.tests.unit.common.test_signature_utils.FakeKeyManager[source]

Bases: object

get(context, cert_uuid)[source]
class glance.tests.unit.common.test_signature_utils.TestSignatureUtils(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

Test methods of signature_utils

test_get_certificate(*args, **keywargs)[source]
test_get_certificate_invalid_format(*args, **keywargs)[source]
test_get_certificate_key_manager_fail(*args, **keywargs)[source]
test_get_expired_certificate(*args, **keywargs)[source]
test_get_hash_method()[source]
test_get_hash_method_fail()[source]
test_get_not_yet_valid_certificate(*args, **keywargs)[source]
test_get_public_key_dsa(*args, **keywargs)[source]
test_get_public_key_ecc(*args, **keywargs)[source]
test_get_public_key_invalid_key(*args, **keywargs)[source]
test_get_public_key_rsa(*args, **keywargs)[source]
test_get_signature()[source]
test_get_signature_fail()[source]
test_get_signature_key_type_lookup()[source]
test_get_verifier_none(*args, **keywargs)[source]
test_old_should_verify_signature()[source]
test_old_should_verify_signature_fail()[source]
test_old_verify_signature_PSS(*args, **keywargs)[source]
test_old_verify_signature_RSA_bad_mask_gen(*args, **keywargs)[source]
test_old_verify_signature_RSA_no_mask_gen(*args, **keywargs)[source]
test_old_verify_signature_bad_pss_salt(*args, **keywargs)[source]
test_old_verify_signature_bad_sig_key_type(*args, **keywargs)[source]
test_old_verify_signature_bad_signature(*args, **keywargs)[source]
test_old_verify_signature_custom_PSS_salt(*args, **keywargs)[source]
test_old_verify_signature_invalid_image_props(*args, **keywargs)[source]
test_old_verify_signature_unsupported_algorithm(*args, **keywargs)[source]
test_old_verify_signature_verifier_none(*args, **keywargs)[source]
test_should_create_verifier()[source]
test_should_create_verifier_fail()[source]
test_signature_key_type_lookup_fail()[source]
test_verify_signature_DSA(*args, **keywargs)[source]
test_verify_signature_ECC(*args, **keywargs)[source]
test_verify_signature_PSS(*args, **keywargs)[source]
test_verify_signature_bad_sig_key_type(*args, **keywargs)[source]
test_verify_signature_bad_signature(*args, **keywargs)[source]
test_verify_signature_invalid_image_props(*args, **keywargs)[source]
test_verify_signature_unsupported_algorithm(*args, **keywargs)[source]

glance.tests.unit.common.test_swift_store_utils module

class glance.tests.unit.common.test_swift_store_utils.TestSwiftParams(*args, **kwargs)[source]

Bases: glance.tests.unit.base.IsolatedUnitTest

setUp()[source]
tearDown()[source]
test_multiple_swift_account_disabled()[source]
test_multiple_swift_account_enabled()[source]
test_swift_config_file_doesnt_exist()[source]
test_swift_config_uses_default_values_multiple_account_disabled()[source]
test_swift_store_config_validates_for_creds_auth_address()[source]

glance.tests.unit.common.test_timeutils module

class glance.tests.unit.common.test_timeutils.TestIso8601Time(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_compare()[source]
test_compare_micros()[source]
test_east_normalize()[source]
test_east_roundtrip()[source]
test_normalize_aware_to_naive()[source]
test_normalize_naive()[source]
test_normalize_zulu_aware_to_naive()[source]
test_now_roundtrip()[source]
test_offset_east()[source]
test_offset_east_micros()[source]
test_offset_west()[source]
test_offset_west_micros()[source]
test_west_normalize()[source]
test_west_roundtrip()[source]
test_zulu()[source]
test_zulu_micros()[source]
test_zulu_normalize()[source]
test_zulu_roundtrip()[source]
class glance.tests.unit.common.test_timeutils.TimeUtilsTest(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

setUp()[source]
test_delta_seconds()[source]
test_iso8601_from_timestamp()[source]
test_isotime()[source]
test_isotimei_micro_second_precision()[source]
test_parse_isotime()[source]
test_parse_isotime_micro_second_precision()[source]
test_utcnow()[source]

glance.tests.unit.common.test_utils module

class glance.tests.unit.common.test_utils.EvaluateFilterOpTestCase(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_equal_operator()[source]
test_greater_than_equal_operator()[source]
test_greater_than_operator()[source]
test_invalid_operator()[source]
test_less_than_equal_operator()[source]
test_less_than_operator()[source]
test_not_equal_operator()[source]
class glance.tests.unit.common.test_utils.SplitFilterOpTestCase(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_default_operator()[source]
test_equal_operator()[source]
test_greater_than_equal_operator()[source]
test_greater_than_operator()[source]
test_in_operator()[source]
test_less_than_equal_operator()[source]
test_less_than_operator()[source]
test_not_equal_operator()[source]
test_split_filter_value_for_quotes()[source]
test_validate_quotes()[source]
class glance.tests.unit.common.test_utils.TestUtils(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

Test routines in glance.utils

test_cooperative_reader()[source]

Ensure cooperative reader class accesses all bytes of file

test_cooperative_reader_of_iterator()[source]

Ensure cooperative reader supports iterator backends too

test_cooperative_reader_of_iterator_stop_iteration_err()[source]

Ensure cooperative reader supports iterator backends too

test_cooperative_reader_preserves_size_chunk_equals_read()[source]
test_cooperative_reader_preserves_size_chunk_less_then_read()[source]
test_cooperative_reader_preserves_size_chunk_more_then_read()[source]
test_create_mashup_dict_with_different_core_custom_properties()[source]
test_create_mashup_dict_with_same_core_custom_properties()[source]
test_get_meta_from_headers()[source]
test_get_meta_from_headers_bad_headers()[source]
test_get_meta_from_headers_none_virtual_size()[source]
test_image_meta()[source]
test_invalid_digest_algorithm()[source]
test_limiting_reader()[source]

Ensure limiting reader class accesses all bytes of file

test_limiting_reader_fails()[source]

Ensure limiting reader class throws exceptions if limit exceeded

test_mutating()[source]
test_valid_fqdn()[source]
test_valid_fqdn_fail()[source]
test_valid_host_port_string()[source]
test_valid_host_port_string_fail()[source]
test_valid_hostname()[source]
test_valid_hostname_fail()[source]
test_validate_key_cert_cert_cant_read()[source]
test_validate_key_cert_key()[source]
test_validate_key_cert_key_cant_read()[source]
test_validate_key_cert_no_private_key()[source]

glance.tests.unit.common.test_wsgi module

class glance.tests.unit.common.test_wsgi.GetSocketTestCase(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

setUp()[source]
test_correct_configure_socket()[source]
test_get_socket_with_bind_problems()[source]
test_get_socket_with_unexpected_socket_errno()[source]
test_get_socket_without_all_ssl_reqs()[source]
class glance.tests.unit.common.test_wsgi.JSONRequestDeserializerTest(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_default_no_body()[source]
test_default_with_body()[source]
test_from_json()[source]
test_from_json_malformed()[source]
test_get_bind_addr_default_value()[source]
test_has_body_has_content_length()[source]
test_has_body_has_transfer_encoding()[source]
test_has_body_invalid_transfer_encoding()[source]
test_has_body_invalid_transfer_encoding_with_content_length()[source]
test_has_body_multiple_transfer_encoding()[source]
test_has_body_no_content_length()[source]
test_has_body_valid_transfer_encoding_with_content_length()[source]
test_has_body_zero_content_length()[source]
test_no_body_no_content_length()[source]
class glance.tests.unit.common.test_wsgi.JSONResponseSerializerTest(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_default()[source]
test_to_json()[source]
test_to_json_with_date_format_value()[source]
test_to_json_with_more_deep_format()[source]
test_to_json_with_set()[source]
class glance.tests.unit.common.test_wsgi.RequestTest(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_best_match_language_expected()[source]
test_best_match_language_unknown(*args, **keywargs)[source]
test_content_range()[source]
test_content_range_invalid()[source]
test_content_type_accept_default()[source]
test_content_type_from_accept_json()[source]
test_content_type_from_accept_json_xml_quality()[source]
test_content_type_from_accept_xml()[source]
test_content_type_from_accept_xml_json()[source]
test_content_type_missing()[source]
test_content_type_unsupported()[source]
test_content_type_with_charset()[source]
test_http_error_response_codes()[source]
test_language_accept_default()[source]
test_language_accept_none()[source]
test_request_match_language_unexpected()[source]
class glance.tests.unit.common.test_wsgi.ResourceTest(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_call()[source]
test_call_raises_exception()[source]
test_dispatch()[source]
test_dispatch_default()[source]
test_dispatch_no_default()[source]
test_get_action_args()[source]
test_get_action_args_del_controller_error()[source]
test_get_action_args_del_format_error()[source]
test_get_action_args_invalid_index()[source]
test_resource_call_error_handle_localized(*args, **keywargs)[source]
test_response_headers_encoded()[source]
test_translate_exception(*args, **keywargs)[source]
class glance.tests.unit.common.test_wsgi.ServerTest(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_create_pool()[source]

Ensure the wsgi thread pool is an eventlet.greenpool.GreenPool.

test_http_keepalive(*args, **keywargs)[source]
test_number_of_workers()[source]

Ensure the default number of workers matches num cpus.

class glance.tests.unit.common.test_wsgi.TestHelpers(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_data_passed_properly_through_headers()[source]

Verifies that data is the same after being passed through headers

test_headers_are_unicode()[source]

Verifies that the headers returned by conversion code are unicode.

Headers are passed via http in non-testing mode, which automatically converts them to unicode. Verifying that the method does the conversion proves that we aren’t passing data that works in tests but will fail in production.

glance.tests.unit.common.test_wsgi_ipv6 module

class glance.tests.unit.common.test_wsgi_ipv6.IPv6ServerTest(*args, **kwargs)[source]

Bases: glance.tests.utils.BaseTestCase

test_eventlet_no_greendns()[source]

Test eventlet pre-imported with EVENTLET_NO_GREENDNS=’yes’

test_eventlet_w_greendns()[source]

Test eventlet pre-imported with EVENTLET_NO_GREENDNS=’no’

test_evnetlet_no_dnspython()[source]

Test eventlet pre-imported but dnspython not installed

test_no_eventlet_no_greendns()[source]

Test eventlet not imported with EVENTLET_NO_GREENDNS=’yes’

test_no_eventlet_w_greendns()[source]

Test eventlet not imported with EVENTLET_NO_GREENDNS=’no’

test_no_evnetlet_no_dnspython()[source]

Test eventlet not imported and dnspython not installed

Module contents