glance.tests.unit.v1 package¶
Submodules¶
glance.tests.unit.v1.test_api module¶
-
class
glance.tests.unit.v1.test_api.
TestAPIPropertyQuotas
(*args, **kwargs)[source]¶ Bases:
glance.tests.unit.base.IsolatedUnitTest
-
test_update_image_with_too_many_properties
()[source]¶ Ensure that updating image properties enforces the quota.
-
-
class
glance.tests.unit.v1.test_api.
TestAPIProtectedProps
(*args, **kwargs)[source]¶ Bases:
glance.tests.unit.base.IsolatedUnitTest
-
test_create_locked_down_protected_prop
()[source]¶ Verify a property protected by special char ‘!’ is creatable by no one
-
test_create_non_protected_prop
()[source]¶ Verify property marked with special char ‘@’ is creatable by an unknown role
-
test_create_protected_prop_check_case_insensitive
()[source]¶ Verify that role check is case-insensitive i.e. the property marked with role Member is creatable by the member role
-
test_delete_locked_down_protected_prop
()[source]¶ Verify a property protected by special char ‘!’ is deletable by no one
-
test_delete_non_protected_prop
()[source]¶ Verify property marked with special char ‘@’ is deletable by an unknown role
-
test_delete_protected_props_check_case_insensitive
()[source]¶ Verify that role check is case-insensitive i.e. the property marked with role Member is deletable by the member role
-
test_delete_protected_props_mix_no_read
()[source]¶ Create an image with two props - one only readable by admin, and one readable/deletable by member. Verify member can successfully delete their property while the admin owned one is ignored transparently
-
test_delete_protected_props_mix_read
()[source]¶ Create an image with two props - one readable/deletable by admin, but also readable by spl_role. The other is readable/deletable by spl_role. Verify spl_role is forbidden to purge_props in this scenario without retaining the readable prop.
-
test_prop_protection_update_noop
()[source]¶ Test protected property update is allowed as long as the user has read access and the value is unchanged
-
test_prop_protection_update_without_read
()[source]¶ Test protected property cannot be updated without read permission
-
test_prop_protection_with_create_and_permitted_role
()[source]¶ As admin role, create an image and verify permitted role ‘member’ can create a protected property
-
test_prop_protection_with_create_and_unpermitted_role
()[source]¶ As admin role, create an image and verify unpermitted role ‘fake_member’ can not create a protected property
-
test_prop_protection_with_delete_and_permitted_policy
()[source]¶ As admin role, create an image with protected property, and verify permitted role ‘member’ can can delete that protected property
-
test_prop_protection_with_delete_and_permitted_role
()[source]¶ As admin role, create an image with protected property, and verify permitted role ‘member’ can can delete that protected property
-
test_prop_protection_with_delete_and_unpermitted_delete
()[source]¶ Test protected property cannot be deleted without delete permission
-
test_prop_protection_with_delete_and_unpermitted_read
()[source]¶ Test protected property cannot be deleted without read permission
-
test_prop_protection_with_detail_and_permitted_policy
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘member’ can read that protected property via /images/detail
-
test_prop_protection_with_detail_and_permitted_role
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘member’ can read that protected property via /images/detail
-
test_prop_protection_with_detail_and_unpermitted_policy
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘fake_role’ can not read that protected property via /images/detail
-
test_prop_protection_with_detail_and_unpermitted_role
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘fake_role’ can not read that protected property via /images/detail
-
test_prop_protection_with_get_and_permitted_role
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘member’ can read that protected property via GET
-
test_prop_protection_with_get_and_unpermitted_role
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘fake_role’ can not read that protected property via GET
-
test_prop_protection_with_permitted_policy_config
()[source]¶ As admin role, create an image and verify permitted role ‘member’ can create a protected property
-
test_prop_protection_with_show_and_permitted_role
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘member’ can read that protected property via HEAD
-
test_prop_protection_with_show_and_unpermitted_role
()[source]¶ As admin role, create an image with a protected property, and verify permitted role ‘fake_role’ can not read that protected property via HEAD
-
test_prop_protection_with_update_and_permitted_policy
()[source]¶ As admin role, create an image with protected property, and verify permitted role ‘admin’ can update that protected property
-
test_prop_protection_with_update_and_permitted_role
()[source]¶ As admin role, create an image with protected property, and verify permitted role ‘member’ can update that protected property
-
test_prop_protection_with_update_and_unpermitted_policy
()[source]¶ As admin role, create an image with protected property, and verify unpermitted role ‘fake_role’ can not update that protected property
-
test_prop_protection_with_update_and_unpermitted_role
()[source]¶ As admin role, create an image with protected property, and verify unpermitted role ‘fake_role’ can not update that protected property
-
test_read_locked_down_protected_prop
()[source]¶ Verify a property protected by special char ‘!’ is readable by no one
-
test_read_non_protected_prop
()[source]¶ Verify property marked with special char ‘@’ is readable by an unknown role
-
test_read_protected_prop_check_case_insensitive
()[source]¶ Verify that role check is case-insensitive i.e. the property marked with role Member is readable by the member role
-
test_read_protected_props_leak_with_update
()[source]¶ Verify when updating props that ones we don’t have read permission for are not disclosed
-
test_update_locked_down_protected_prop
()[source]¶ Verify a property protected by special char ‘!’ is updatable by no one
-
test_update_non_protected_prop
()[source]¶ Verify property marked with special char ‘@’ is updatable by an unknown role
-
test_update_protected_props_check_case_insensitive
()[source]¶ Verify that role check is case-insensitive i.e. the property marked with role Member is updatable by the member role
-
-
class
glance.tests.unit.v1.test_api.
TestGlanceAPI
(*args, **kwargs)[source]¶ Bases:
glance.tests.unit.base.IsolatedUnitTest
-
test_active_image_immutable_props_for_user
()[source]¶ Tests user cannot update immutable props of active image
-
test_add_copy_from_with_nonempty_body
()[source]¶ Tests creates an image from copy-from and nonempty body
-
test_add_copy_from_with_restricted_sources
()[source]¶ Tests creates an image from copy-from with restricted sources
-
test_add_image_no_location_no_content_type
()[source]¶ Tests creates a queued image for no body and no loc header
-
test_add_image_no_location_no_image_as_body
()[source]¶ Tests creates a queued image for no body and no loc header
-
test_add_image_size_header_too_big
()[source]¶ Tests raises BadRequest for supplied image size that is too big
-
test_add_location_with_conflict_image_size
()[source]¶ Tests creates an image from location and conflict image size
-
test_add_location_with_invalid_location_on_conflict_image_size
()[source]¶ Tests creates an image from location and conflict image size
-
test_add_location_with_invalid_location_on_restricted_sources
()[source]¶ Tests creates an image from location and restricted sources
-
test_add_location_with_nonempty_body
()[source]¶ Tests creates an image from location and nonempty body
Tests adding image members raises right exception
-
test_bad_checksum_prevents_image_creation
()[source]¶ Test that the image contents are checksummed properly
-
test_create_member_to_deleted_image_raises_404
()[source]¶ Tests adding members to deleted image raises 404.
-
test_deactivated_image_immutable_props_for_user
()[source]¶ Tests user cannot update immutable props of deactivated image
-
test_delete_member_of_deleted_image_raises_404
()[source]¶ Tests deleting members of deleted image raises 404.
-
test_delete_member_on_non_existing_image
()[source]¶ Tests deleting image members raises right exception
-
test_delete_pending_delete_image
()[source]¶ Tests that correct response returned when deleting a pending_delete image
-
test_delete_queued_image
()[source]¶ Delete an image in a queued state
Bug #747799 demonstrated that trying to DELETE an image that had had its save process killed manually results in failure because the location attribute is None.
Bug #1048851 demonstrated that the status was not properly being updated to ‘deleted’ from ‘queued’.
-
test_delete_queued_image_delayed_delete
()[source]¶ Delete an image in a queued state when delayed_delete is on
Bug #1048851 demonstrated that the status was not properly being updated to ‘deleted’ from ‘queued’.
-
test_disable_purge_props
()[source]¶ Test the special x-glance-registry-purge-props header controls the purge property behaviour of the registry. :see LP Bug#901534
-
test_download_deactivated_images
()[source]¶ Tests exception raised trying to download a deactivated image
Test image download returns HTTPServiceUnavailable.
-
test_etag_equals_checksum_header
()[source]¶ Test that the ETag header matches the x-image-meta-checksum
-
test_get_details_filter_changes_since
()[source]¶ Tests that the /images/detail API returns list of images that changed since the time defined by changes-since
-
test_get_details_invalid_marker
()[source]¶ Tests that the /images/detail API returns a 400 when an invalid marker is provided
-
test_get_image_members_not_existing
()[source]¶ Tests proper exception is raised if attempt to get members of non-existing image
-
test_get_index_filter_on_user_defined_properties
()[source]¶ Check that image filtering works on user-defined properties
-
test_get_index_sort_name_asc
()[source]¶ Tests that the /images API returns list of public images sorted alphabetically by name in ascending order.
-
test_get_members_of_deleted_image_raises_404
()[source]¶ Tests members listing for deleted image raises 404.
-
test_image_status_when_delete_fails
()[source]¶ Tests that the image status set to active if deletion of image fails.
-
test_post_image_content_missing_container_type
()[source]¶ Tests creation of an image with missing container format
-
test_post_image_content_missing_disk_format
()[source]¶ Tests creation of an image with missing disk format
-
test_props_of_active_image_mutable_for_admin
()[source]¶ Tests admin can update ‘immutable’ props of active image
-
test_props_of_deactivated_image_mutable_for_admin
()[source]¶ Tests admin can update ‘immutable’ props of deactivated image
Create a non-public image then fail to make public
-
test_put_image_content_missing_container_type
()[source]¶ Tests delayed activation of image with missing container format
-
test_put_image_content_missing_disk_format
()[source]¶ Tests delayed activation of image with missing disk format
-
test_register_and_upload
()[source]¶ Test that the process of registering an image with some metadata, then uploading an image file with some more metadata doesn’t mark the original metadata deleted :see LP Bug#901534
-
test_replace_members_bad_request
()[source]¶ Tests replacing image members raises bad request if body is wrong
-
test_replace_members_non_existing_image
()[source]¶ Tests replacing image members raises right exception
-
test_store_location_not_revealed
()[source]¶ Test that the internal store location is NOT revealed through the API server
-
test_update_image_size_header_too_big
()[source]¶ Tests raises BadRequest for supplied image size that is too big
-
test_update_members_of_deleted_image_raises_404
()[source]¶ Tests update members of deleted image raises 404.
-
-
class
glance.tests.unit.v1.test_api.
TestImageSerializer
(*args, **kwargs)[source]¶
glance.tests.unit.v1.test_registry_api module¶
-
class
glance.tests.unit.v1.test_registry_api.
TestRegistryAPI
(*args, **kwargs)[source]¶ Bases:
glance.tests.unit.base.IsolatedUnitTest
,glance.tests.utils.RegistryAPIMixIn
Test update image members raises right exception
-
test_add_member_delete_create
()[source]¶ Test check that the same member can be successfully added after delete it, and the same record will be reused for the same membership.
-
test_add_member_to_non_exist_image
()[source]¶ Test check that member can’t be added for non exist image
-
test_create_image_with_bad_id
()[source]¶ Tests proper exception is raised if a bad disk_format is set
-
test_create_image_with_bad_status
()[source]¶ Tests proper exception is raised if a bad status is set
-
test_create_image_with_image_id_in_log
()[source]¶ Tests correct image id in log message when creating image
-
test_create_image_with_min_disk
()[source]¶ Tests that the /images POST registry API creates the image
-
test_create_image_with_min_disk_default
()[source]¶ Tests that the /images POST registry API creates the image
-
test_create_image_with_min_ram
()[source]¶ Tests that the /images POST registry API creates the image
-
test_create_image_with_min_ram_default
()[source]¶ Tests that the /images POST registry API creates the image
Test delete image members raises right exception
-
test_delete_image_not_existing
()[source]¶ Tests proper exception is raised if attempt to delete non-existing image
-
test_delete_member_from_non_exist_image
()[source]¶ Tests deleting image members raises right exception
-
test_delete_member_invalid
()[source]¶ Tests deleting a invalid/non existing member raises right exception
-
test_delete_private_image_no_admin
()[source]¶ Tests proper exception is raised if attempt to delete private image with non admin user, that not belongs to it
-
test_delete_public_image_no_admin
()[source]¶ Tests proper exception is raised if attempt to delete public image with non admin user
-
test_get_details
()[source]¶ Tests that the /images/detail registry API returns a mapping containing a list of detailed image information
-
test_get_details_filter_changes_since
()[source]¶ Tests that the /images/detail registry API returns list of images that changed since the time defined by changes-since
-
test_get_details_filter_container_format
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a specific container_format
-
test_get_details_filter_deleted_false
()[source]¶ Test that the /images/detail registry API return list of images with deleted filter = false
-
test_get_details_filter_disk_format
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a specific disk_format
-
test_get_details_filter_min_disk
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a specific min_disk
-
test_get_details_filter_min_ram
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a specific min_ram
-
test_get_details_filter_name
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a specific name
-
test_get_details_filter_property
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a specific custom property
-
test_get_details_filter_public_false
()[source]¶ Tests that the /images/detail registry API returns list of private images if is_public false is passed
-
test_get_details_filter_public_none
()[source]¶ Tests that the /images/detail registry API returns list of all images if is_public none is passed
-
test_get_details_filter_public_string_format
()[source]¶ Tests that the /images/detail registry API returns 400 Bad error for filter is_public with wrong format
-
test_get_details_filter_public_true
()[source]¶ Tests that the /images/detail registry API returns list of public images if is_public true is passed (same as default)
-
test_get_details_filter_size_max
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a size less than or equal to size_max
-
test_get_details_filter_size_min
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a size greater than or equal to size_min
-
test_get_details_filter_size_min_max
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a size less than or equal to size_max and greater than or equal to size_min
-
test_get_details_filter_status
()[source]¶ Tests that the /images/detail registry API returns list of public images that have a specific status
-
test_get_details_forbidden_marker
()[source]¶ Tests that the /images/detail registry API returns a 400 when a forbidden marker is provided
-
test_get_details_invalid_marker
()[source]¶ Tests that the /images/detail registry API returns a 400 when an invalid marker is provided
-
test_get_details_limit_marker
()[source]¶ Tests that the /images/details registry API returns list of public images that conforms to limit and marker query params. This functionality is tested more thoroughly on /images, this is just a sanity check
-
test_get_details_malformed_marker
()[source]¶ Tests that the /images/detail registry API returns a 400 when a malformed marker is provided
-
test_get_details_sort_name_asc
()[source]¶ Tests that the /images/details registry API returns list of public images sorted alphabetically by name in ascending order.
-
test_get_filter_no_public_with_no_admin
()[source]¶ Tests that the /images/detail registry API returns list of public images if is_public true is passed (same as default)
-
test_get_filter_protected_with_None_value
()[source]¶ Tests that the /images/detail registry API returns 400 error
-
test_get_filter_protected_with_True_value
()[source]¶ Tests that the /images/detail registry API returns 400 error
-
test_get_image_members_forbidden
()[source]¶ Tests proper exception is raised if attempt to get members of non-existing image
-
test_get_image_members_not_existing
()[source]¶ Tests proper exception is raised if attempt to get members of non-existing image
-
test_get_index_filter_name
()[source]¶ Tests that the /images registry API returns list of public images that have a specific name. This is really a sanity check, filtering is tested more in-depth using /images/detail
-
test_get_index_filter_on_user_defined_properties
()[source]¶ Tests that /images registry API returns list of public images based a filter on user-defined properties.
-
test_get_index_forbidden_marker
()[source]¶ Tests that the /images registry API returns a 400 when a forbidden marker is provided
-
test_get_index_limit
()[source]¶ Tests that the /images registry API returns list of public images that conforms to a limit query param
-
test_get_index_limit_marker
()[source]¶ Tests that the /images registry API returns list of public images that conforms to limit and marker query params
-
test_get_index_limit_negative
()[source]¶ Tests that the /images registry API returns list of public images that conforms to a limit query param
-
test_get_index_limit_non_int
()[source]¶ Tests that the /images registry API returns list of public images that conforms to a limit query param
-
test_get_index_malformed_marker
()[source]¶ Tests that the /images registry API returns a 400 when a malformed marker is provided
-
test_get_index_marker
()[source]¶ Tests that the /images registry API returns list of public images that conforms to a marker query param
-
test_get_index_null_container_format
()[source]¶ Check 200 is returned when sort_key is null container_format
Check 200 is returned when sort_key is container_format and container_format is null for specified marker
-
test_get_index_null_disk_format
()[source]¶ Check 200 is returned when sort_key is null disk_format
Check 200 is returned when sort_key is disk_format and disk_format is null for specified marker
-
test_get_index_null_name
()[source]¶ Check 200 is returned when sort_key is null name
Check 200 is returned when sort_key is name and name is null for specified marker
-
test_get_index_sort_container_format_desc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by container_format in descending order.
-
test_get_index_sort_created_at_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted by created_at in ascending order.
-
test_get_index_sort_default_created_at_desc
()[source]¶ Tests that the /images registry API returns list of public images that conforms to a default sort key/dir
-
test_get_index_sort_disk_format_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by disk_format in ascending order.
-
test_get_index_sort_name_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by name in ascending order.
-
test_get_index_sort_size_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted by size in ascending order.
-
test_get_index_sort_status_desc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by status in descending order.
-
test_get_index_sort_updated_at_desc
()[source]¶ Tests that the /images registry API returns list of public images sorted by updated_at in descending order.
-
test_get_index_unknown_marker
()[source]¶ Tests that the /images registry API returns a 400 when an unknown marker is provided
-
test_get_on_image_member
()[source]¶ Test GET on image members raises 404 and produces correct Allow headers
-
test_get_root
()[source]¶ Tests that the root registry API returns “index”, which is a list of public images
-
test_show_deleted_image_as_admin
()[source]¶ Tests that the /images/<id> registry API endpoint returns a 200 for deleted image to admin user.
-
test_show_deleted_image_as_nonadmin
()[source]¶ Tests that the /images/<id> registry API endpoint returns a 404 for deleted image to non-admin user.
-
test_show_invalid
()[source]¶ Tests that the /images/<id> registry API endpoint returns a 404 for an invalid (therefore unknown) image id
-
test_show_unknown
()[source]¶ Tests that the /images/<id> registry API endpoint returns a 404 for an unknown image id
-
test_update_all_image_members_bad_request
()[source]¶ Test that right exception is raises in case if wrong memberships association is supplied
-
test_update_all_image_members_invalid_membership_association
()[source]¶ Test update image members raises right exception
-
test_update_all_image_members_non_existing_image_id
()[source]¶ Test update image members raises right exception
Test update image members raises right exception
-
test_update_image_not_existing
()[source]¶ Tests proper exception is raised if attempt to update non-existing image
-
class
glance.tests.unit.v1.test_registry_api.
TestRegistryAPILocations
(*args, **kwargs)[source]¶ Bases:
glance.tests.unit.base.IsolatedUnitTest
,glance.tests.utils.RegistryAPIMixIn
-
class
glance.tests.unit.v1.test_registry_api.
TestSharability
(*args, **kwargs)[source]¶ Bases:
glance.tests.utils.BaseTestCase
glance.tests.unit.v1.test_registry_client module¶
-
class
glance.tests.unit.v1.test_registry_client.
TestBaseClient
(*args, **kwargs)[source]¶ Bases:
testtools.testcase.TestCase
Test proper actions made for both valid and invalid requests against a Registry service
-
class
glance.tests.unit.v1.test_registry_client.
TestRegistryV1Client
(*args, **kwargs)[source]¶ Bases:
glance.tests.unit.base.IsolatedUnitTest
,glance.tests.utils.RegistryAPIMixIn
Test proper actions made for both valid and invalid requests against a Registry service
-
test_add_image_already_exists
()[source]¶ Tests proper exception is raised if image with ID already exists
-
test_add_image_with_location_data_with_encryption
()[source]¶ Tests that we can add image metadata with properties and enable encryption.
-
test_get_image_details_by_container_format
()[source]¶ Tests that a detailed call can be filtered by container_format
-
test_get_image_details_by_disk_format
()[source]¶ Tests that a detailed call can be filtered by disk_format
-
test_get_image_details_by_property
()[source]¶ Tests that a detailed call can be filtered by a property
-
test_get_image_details_forbidden_marker
()[source]¶ Test exception is raised when marker is forbidden
-
test_get_image_details_marker_limit
()[source]¶ Test correct set of images returned with marker/limit params.
-
test_get_image_details_private_marker
()[source]¶ Test exception is not raised if private non-owned marker is used
-
test_get_image_details_sort_disk_format_asc
()[source]¶ Tests that a detailed call returns list of public images sorted alphabetically by disk_format in ascending order.
-
test_get_image_details_with_changes_since
()[source]¶ Tests that a detailed call can be filtered by changes-since
-
test_get_image_details_with_maximum_size
()[source]¶ Tests that a detailed call can be filtered by size_max
-
test_get_image_details_with_minimum_size
()[source]¶ Tests that a detailed call can be filtered by size_min
-
test_get_image_details_with_size_min
()[source]¶ Tests that a detailed call can be filtered by size_min
-
test_get_image_index_by_name
()[source]¶ Test correct set of public, name-filtered image returned. This is just a sanity check, we test the details call more in-depth.
-
test_get_image_index_limit_None
()[source]¶ Test correct set of images returned with limit param == None.
-
test_get_image_index_marker_limit
()[source]¶ Test correct set of images returned with marker/limit params.
-
test_get_image_index_private_marker
()[source]¶ Test exception is not raised if private non-owned marker is used
-
test_get_image_non_existing
()[source]¶ Tests that NotFound is raised when getting a non-existing image
-
test_get_index_sort_container_format_desc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by container_format in descending order.
-
test_get_index_sort_created_at_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted by created_at in ascending order.
-
test_get_index_sort_disk_format_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by disk_format in ascending order.
-
test_get_index_sort_name_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by name in ascending order.
-
test_get_index_sort_size_asc
()[source]¶ Tests that the /images registry API returns list of public images sorted by size in ascending order.
-
test_get_index_sort_status_desc
()[source]¶ Tests that the /images registry API returns list of public images sorted alphabetically by status in descending order.
-
glance.tests.unit.v1.test_upload_utils module¶
-
class
glance.tests.unit.v1.test_upload_utils.
TestUploadUtils
(*args, **kwargs)[source]¶ Bases:
glance.tests.unit.base.StoreClearingUnitTest
-
test_activate_image_with_expired_token
(*args, **keywargs)[source]¶ Test token expiration during image upload.
If users token expired before image was uploaded then if auth error was caught from registry during changing image status from ‘saving’ to ‘active’ then it’s required to delete all image data.
-
test_upload_data_to_store_duplicate
()[source]¶ See note in glance.api.v1.upload_utils on why we don’t want image to be deleted in this case.
-