keystoneauth1.tests.unit package¶
Subpackages¶
- keystoneauth1.tests.unit.access package
- keystoneauth1.tests.unit.exceptions package
- keystoneauth1.tests.unit.extras package
- Subpackages
- keystoneauth1.tests.unit.extras.kerberos package
- Submodules
- keystoneauth1.tests.unit.extras.kerberos.base module
- keystoneauth1.tests.unit.extras.kerberos.test_fedkerb_loading module
- keystoneauth1.tests.unit.extras.kerberos.test_kerberos_loading module
- keystoneauth1.tests.unit.extras.kerberos.test_mapped module
- keystoneauth1.tests.unit.extras.kerberos.test_v3 module
- keystoneauth1.tests.unit.extras.kerberos.utils module
- Module contents
- keystoneauth1.tests.unit.extras.oauth1 package
- keystoneauth1.tests.unit.extras.saml2 package
- keystoneauth1.tests.unit.extras.kerberos package
- Module contents
- Subpackages
- keystoneauth1.tests.unit.identity package
- Submodules
- keystoneauth1.tests.unit.identity.test_access module
- keystoneauth1.tests.unit.identity.test_identity_common module
- keystoneauth1.tests.unit.identity.test_identity_v2 module
- keystoneauth1.tests.unit.identity.test_identity_v3 module
- keystoneauth1.tests.unit.identity.test_identity_v3_federation module
- keystoneauth1.tests.unit.identity.test_identity_v3_oidc module
- keystoneauth1.tests.unit.identity.test_password module
- keystoneauth1.tests.unit.identity.test_token module
- keystoneauth1.tests.unit.identity.test_tokenless_auth module
- keystoneauth1.tests.unit.identity.utils module
- Module contents
- keystoneauth1.tests.unit.loading package
- Submodules
- keystoneauth1.tests.unit.loading.test_adapter module
- keystoneauth1.tests.unit.loading.test_cli module
- keystoneauth1.tests.unit.loading.test_conf module
- keystoneauth1.tests.unit.loading.test_entry_points module
- keystoneauth1.tests.unit.loading.test_fixtures module
- keystoneauth1.tests.unit.loading.test_generic module
- keystoneauth1.tests.unit.loading.test_loading module
- keystoneauth1.tests.unit.loading.test_session module
- keystoneauth1.tests.unit.loading.test_v3 module
- keystoneauth1.tests.unit.loading.utils module
- Module contents
Submodules¶
keystoneauth1.tests.unit.client_fixtures module¶
-
keystoneauth1.tests.unit.client_fixtures.
domain_scoped_token
()¶
-
keystoneauth1.tests.unit.client_fixtures.
project_scoped_token
()¶
keystoneauth1.tests.unit.k2k_fixtures module¶
keystoneauth1.tests.unit.keystoneauth_fixtures module¶
-
class
keystoneauth1.tests.unit.keystoneauth_fixtures.
HackingCode
¶ Bases:
fixtures.fixture.Fixture
A fixture to house the various code examples.
Examples contains various keystoneauth hacking style checks.
-
oslo_namespace_imports
= {'code': '\n import oslo.utils\n import oslo_utils\n import oslo.utils.encodeutils\n import oslo_utils.encodeutils\n from oslo import utils\n from oslo.utils import encodeutils\n from oslo_utils import encodeutils\n\n import oslo.serialization\n import oslo_serialization\n import oslo.serialization.jsonutils\n import oslo_serialization.jsonutils\n from oslo import serialization\n from oslo.serialization import jsonutils\n from oslo_serialization import jsonutils\n\n import oslo.config\n import oslo_config\n import oslo.config.cfg\n import oslo_config.cfg\n from oslo import config\n from oslo.config import cfg\n from oslo_config import cfg\n\n import oslo.i18n\n import oslo_i18n\n import oslo.i18n.log\n import oslo_i18n.log\n from oslo import i18n\n from oslo.i18n import log\n from oslo_i18n import log\n ', 'expected_errors': [(1, 0, 'K333'), (3, 0, 'K333'), (5, 0, 'K333'), (6, 0, 'K333'), (9, 0, 'K333'), (11, 0, 'K333'), (13, 0, 'K333'), (14, 0, 'K333'), (17, 0, 'K333'), (19, 0, 'K333'), (21, 0, 'K333'), (22, 0, 'K333'), (25, 0, 'K333'), (27, 0, 'K333'), (29, 0, 'K333'), (30, 0, 'K333')]}¶
-
keystoneauth1.tests.unit.matchers module¶
-
class
keystoneauth1.tests.unit.matchers.
XMLEquals
(expected)¶ Bases:
object
Parses two XML documents from strings and compares the results.
-
match
(other)¶
-
-
class
keystoneauth1.tests.unit.matchers.
XMLMismatch
(expected, other)¶ Bases:
testtools.matchers._impl.Mismatch
-
describe
()¶ Describe the mismatch.
This should be either a human-readable string or castable to a string. In particular, is should either be plain ascii or unicode on Python 2, and care should be taken to escape control characters.
-
keystoneauth1.tests.unit.oidc_fixtures module¶
keystoneauth1.tests.unit.test_betamax_fixture module¶
-
class
keystoneauth1.tests.unit.test_betamax_fixture.
TestBetamaxFixture
(*args, **kwargs)¶ Bases:
testtools.testcase.TestCase
-
TEST_AUTH_URL
= 'http://keystoneauth-betamax.test/v2.0/'¶
-
TEST_PASSWORD
= 'test_password'¶
-
TEST_TENANT_NAME
= 'test_tenant_name'¶
-
TEST_USERNAME
= 'test_user_name'¶
-
V2_TOKEN
= {'access': {'token': {'audit_ids': ['1dd8e09feb5b4f44b5c02c3b7648077e', None], 'expires': '2021-01-19T10:59:41.072137', 'id': 'abc61f659cf34f08b20d16cc4a56616a', 'issued_at': '2021-01-19T09:59:41.072137', 'tenant': {'id': '2a8c6cb2a57c4f30a44af48ec6468f11', 'name': 'test_tenant_name'}}, 'user': {'id': 'bb46444a6d0e4e8ca053f32e0c773c26', 'name': 'test_user_name'}}}¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_keystoneauth_betamax_fixture
()¶
-
test_replay_of_bad_url_fails
()¶
-
-
class
keystoneauth1.tests.unit.test_betamax_fixture.
TestBetamaxFixtureSerializerBehaviour
(*args, **kwargs)¶ Bases:
testtools.testcase.TestCase
Test the fixture’s logic, not its monkey-patching.
The setUp method of our BetamaxFixture monkey-patches the function to construct a session. We don’t need to test that particular bit of logic here so we do not need to call useFixture in our setUp method.
-
test_can_pass_custom_serializer
(register_serializer)¶
-
test_can_pass_serializer_name
()¶
-
test_no_request_matchers_provided
()¶
-
test_no_serializer_options_provided
()¶
-
test_request_matchers
()¶
-
keystoneauth1.tests.unit.test_betamax_hooks module¶
keystoneauth1.tests.unit.test_betamax_serializer module¶
-
class
keystoneauth1.tests.unit.test_betamax_serializer.
TestBetamaxSerializer
(*args, **kwargs)¶ Bases:
testtools.testcase.TestCase
-
TEST_FILE
= '/home/zuul/src/opendev.org/openstack/keystoneauth/keystoneauth1/tests/unit/data/ksa_betamax_test_cassette.yaml'¶
-
TEST_JSON
= '/home/zuul/src/opendev.org/openstack/keystoneauth/keystoneauth1/tests/unit/data/ksa_serializer_data.json'¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_deserialize
()¶
-
test_serialize
()¶
-
keystoneauth1.tests.unit.test_discovery module¶
-
class
keystoneauth1.tests.unit.test_discovery.
CatalogHackTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
BASE_URL
= 'http://keystone.server:5000/'¶
-
IDENTITY
= 'identity'¶
-
OTHER_URL
= 'http://other.server:5000/path'¶
-
TEST_URL
= 'http://keystone.server:5000/v2.0'¶
-
V2_URL
= 'http://keystone.server:5000/v2.0'¶
-
V3_URL
= 'http://keystone.server:5000/v3'¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_ignored_non_service_type
()¶
-
test_version_hacks
()¶
-
-
class
keystoneauth1.tests.unit.test_discovery.
DiscoverUtils
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
test_version_args
()¶ Validate _normalize_version_args.
-
test_version_between
()¶
-
test_version_number
()¶
-
test_version_to_string
()¶
-
-
class
keystoneauth1.tests.unit.test_discovery.
EndpointDataTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
test_endpoint_data_str
()¶ Validate EndpointData.__str__.
-
test_project_id_int_fallback
()¶
-
test_run_discovery_cache
(mock_url_choices, mock_get_disc)¶
-
-
class
keystoneauth1.tests.unit.test_discovery.
VersionDataTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_allow_deprecated
()¶
-
test_allow_experimental
()¶
-
test_allow_unknown
()¶
-
test_cinder_version_data
()¶
-
test_data_for_no_version
()¶
-
test_data_for_url
()¶
-
test_endpoint_data_noauth_adapter
()¶
-
test_endpoint_data_noauth_discover
()¶
-
test_endpoint_data_noauth_no_discover
()¶
-
test_endpoint_data_token_endpoint_adapter
()¶
-
test_endpoint_data_token_endpoint_discover
()¶
-
test_endpoint_data_token_endpoint_no_discover
()¶
-
test_glance_version_data
()¶
-
test_ignoring_invalid_links
()¶
-
test_keystone_version_data
()¶
-
test_version_data_basics
()¶
-
test_version_data_individual
()¶
-
test_version_data_ironic_microversions
()¶ Validate detection of Ironic microversion ranges.
-
test_version_data_legacy_ironic_microversions
()¶ Validate detection of legacy Ironic microversion ranges.
-
test_version_data_legacy_ironic_no_override
()¶ Validate detection of legacy Ironic microversion ranges.
-
test_version_data_microversions
()¶ Validate [min_|max_]version conversion to {min|max}_microversion.
-
test_version_data_override_version_url
()¶
-
test_version_data_unknown
()¶
-
keystoneauth1.tests.unit.test_fair_sempahore module¶
-
class
keystoneauth1.tests.unit.test_fair_sempahore.
SemaphoreTests
(*args, **kwargs)¶ Bases:
testtools.testcase.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_semaphore_fast_multiple_concurrency
()¶
-
test_semaphore_fast_no_concurrency
()¶
-
test_semaphore_fast_single_concurrency
()¶
-
test_semaphore_multiple_concurrency
()¶
-
test_semaphore_no_concurrency
()¶
-
test_semaphore_single_concurrency
()¶
-
keystoneauth1.tests.unit.test_fixtures module¶
-
class
keystoneauth1.tests.unit.test_fixtures.
V2TokenTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
test_roles
()¶
-
test_services
()¶
-
test_tenant_scoped
()¶
-
test_token_bind
()¶
-
test_trust_scoped
()¶
-
test_unscoped
()¶
-
-
class
keystoneauth1.tests.unit.test_fixtures.
V3TokenTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
test_catalog
()¶
-
test_domain_scoped
()¶
-
test_empty_default_service_providers
()¶
-
test_is_admin_project
()¶
-
test_oauth_scoped
()¶
-
test_project_as_domain_scoped
()¶
-
test_project_scoped
()¶
-
test_roles
()¶
-
test_service_providers
()¶
-
test_token_bind
()¶
-
test_trust_scoped
()¶
-
test_unscoped
()¶
-
keystoneauth1.tests.unit.test_hacking_checks module¶
keystoneauth1.tests.unit.test_matchers module¶
-
class
keystoneauth1.tests.unit.test_matchers.
TestXMLEquals
(*args, **kwargs)¶ Bases:
testtools.testcase.TestCase
-
describe_examples
= [('expected =\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <first z="0" y="1" x="2"/>\n <second a="a" b="b"/>\n</test>\n\nactual =\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <nope_it_fails/>\n</test>\n', b'<?xml version="1.0" encoding="UTF-8"?>\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <nope_it_fails/>\n</test>\n', <keystoneauth1.tests.unit.matchers.XMLEquals object>)]¶
-
equivalent_xml
= b'<?xml version="1.0" encoding="UTF-8"?>\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <second a="a" b="b"/>\n <first z="0" y="1" x="2"></first>\n</test>\n'¶
-
matches_matcher
= <keystoneauth1.tests.unit.matchers.XMLEquals object>¶
-
matches_matches
= [b'<?xml version="1.0" encoding="UTF-8"?>\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <first z="0" y="1" x="2"/>\n <second a="a" b="b"></second>\n</test>\n', b'<?xml version="1.0" encoding="UTF-8"?>\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <second a="a" b="b"/>\n <first z="0" y="1" x="2"></first>\n</test>\n']¶
-
matches_mismatches
= [b'<?xml version="1.0" encoding="UTF-8"?>\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <nope_it_fails/>\n</test>\n']¶
-
matches_xml
= b'<?xml version="1.0" encoding="UTF-8"?>\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <first z="0" y="1" x="2"/>\n <second a="a" b="b"></second>\n</test>\n'¶
-
mismatches_description
= 'expected =\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <first z="0" y="1" x="2"/>\n <second a="a" b="b"/>\n</test>\n\nactual =\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <nope_it_fails/>\n</test>\n'¶
-
mismatches_xml
= b'<?xml version="1.0" encoding="UTF-8"?>\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\n <nope_it_fails/>\n</test>\n'¶
-
str_examples
= [('XMLEquals(b\'<?xml version="1.0" encoding="UTF-8"?>\\n<test xmlns="https://docs.openstack.org/identity/api/v2.0">\\n <first z="0" y="1" x="2"/>\\n <second a="a" b="b"></second>\\n</test>\\n\')', <keystoneauth1.tests.unit.matchers.XMLEquals object>)]¶
-
test__str__
()¶
-
test_describe_difference
()¶
-
test_matches_match
()¶
-
test_mismatch_details
()¶
-
keystoneauth1.tests.unit.test_noauth module¶
keystoneauth1.tests.unit.test_service_token module¶
-
class
keystoneauth1.tests.unit.test_service_token.
ServiceTokenTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
SERVICE_URL
= 'http://service-keystone.example.com/v3'¶
-
TEST_URL
= 'http://test.example.com/path/'¶
-
USER_URL
= 'http://user-keystone.example.com/v3'¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_invalidation
()¶
-
test_pass_throughs
()¶
-
test_setting_service_token
()¶
-
keystoneauth1.tests.unit.test_session module¶
-
class
keystoneauth1.tests.unit.test_session.
AdapterTest
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
ALLOW
= {'allow_deprecated': False, 'allow_experimental': True, 'allow_unknown': True}¶
-
INTERFACE
= 'ab0b0956cc79478182df87a8669725b2'¶
-
REGION_NAME
= '544503246ac74dae93d32d5c49bde9bf'¶
-
SERVICE_NAME
= '0127370a578c4f389b0b735e96f5e4fe'¶
-
SERVICE_TYPE
= '7fabd7b3223c4654b17655d25d2625be'¶
-
TEST_URL
= 'http://fakeendpoint/'¶
-
USER_AGENT
= 'f66fdb5a249446b393b42ae35ce156bb'¶
-
VERSION
= 'd0f190b7cbaf4896915d351274a27edc'¶
-
test_adapter_connect_retries
()¶
-
test_adapter_get_token
()¶
-
test_adapter_http_503_retries
()¶
-
test_adapter_http_status_retries
()¶
-
test_adapter_invalidate
()¶
-
test_adapter_user_agent_adapter
()¶
-
test_adapter_user_agent_session
()¶
-
test_adapter_user_agent_session_adapter
()¶
-
test_adapter_user_agent_session_adapter_additional
()¶
-
test_adapter_user_agent_session_adapter_no_app_version
()¶
-
test_adapter_user_agent_session_adapter_no_client_version
()¶
-
test_adapter_user_agent_session_override
()¶
-
test_adapter_user_agent_session_version_on_adapter
()¶
-
test_additional_headers
()¶
-
test_additional_headers_overrides
()¶
-
test_default_microversion
()¶
-
test_legacy_binding
()¶
-
test_legacy_binding_non_json_resp
()¶
-
test_logger_object_passed
()¶
-
test_methods
()¶
-
test_nested_adapters
()¶
-
test_raise_exc_override
()¶
-
test_setting_endpoint_override
()¶
-
test_setting_global_id_on_request
()¶
-
test_setting_variables_on_get_endpoint
()¶
-
test_setting_variables_on_request
()¶
-
test_unknown_connection_error
()¶
-
test_user_and_project_id
()¶
-
-
class
keystoneauth1.tests.unit.test_session.
AuthPlugin
(token='a2aac210ef4348ca9e633e8894cbf740', invalidate=True)¶ Bases:
keystoneauth1.plugin.BaseAuthPlugin
Very simple debug authentication plugin.
Takes Parameters such that it can throw exceptions at the right times.
-
SERVICE_URLS
= {'compute': {'admin': 'http://compute-admin:2222/v1.0', 'public': 'http://compute-public:2222/v1.0'}, 'identity': {'admin': 'http://identity-admin:1111/v2.0', 'public': 'http://identity-public:1111/v2.0'}, 'image': {'admin': 'http://image-admin:3333/v2.0', 'public': 'http://image-public:3333/v2.0'}}¶
-
TEST_PROJECT_ID
= 'aProject'¶
-
TEST_TOKEN
= 'a2aac210ef4348ca9e633e8894cbf740'¶
-
TEST_USER_ID
= 'aUser'¶
-
get_endpoint
(session, service_type=None, interface=None, **kwargs)¶ Return an endpoint for the client.
There are no required keyword arguments to
get_endpoint
as a plugin implementation should use best effort with the information available to determine the endpoint. However there are certain standard options that will be generated by the clients and should be used by plugins:service_type
: what sort of service is required.service_name
: the name of the service in the catalog.interface
: what visibility the endpoint should have.region_name
: the region the endpoint exists in.
- Parameters
session (keystoneauth1.session.Session) – The session object that the auth_plugin belongs to.
- Returns
The base URL that will be used to talk to the required service or None if not available.
- Return type
string
-
get_project_id
(session)¶ Return the project id that we are authenticated to.
Wherever possible the project id should be inferred from the token however there are certain URLs and other places that require access to the currently authenticated project id.
- Parameters
session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.
- Returns
A project identifier or None if one is not available.
- Return type
-
get_token
(session)¶ Obtain a token.
How the token is obtained is up to the plugin. If it is still valid it may be re-used, retrieved from cache or invoke an authentication request against a server.
There are no required kwargs. They are passed directly to the auth plugin and they are implementation specific.
Returning None will indicate that no token was able to be retrieved.
This function is misplaced as it should only be required for auth plugins that use the ‘X-Auth-Token’ header. However due to the way plugins evolved this method is required and often called to trigger an authentication request on a new plugin.
When implementing a new plugin it is advised that you implement this method, however if you don’t require the ‘X-Auth-Token’ header override the get_headers method instead.
- Parameters
session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.
- Returns
A token to use.
- Return type
string
-
get_user_id
(session)¶ Return a unique user identifier of the plugin.
Wherever possible the user id should be inferred from the token however there are certain URLs and other places that require access to the currently authenticated user id.
- Parameters
session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.
- Returns
A user identifier or None if one is not available.
- Return type
-
invalidate
()¶ Invalidate the current authentication data.
This should result in fetching a new token on next call.
A plugin may be invalidated if an Unauthorized HTTP response is returned to indicate that the token may have been revoked or is otherwise now invalid.
- Returns
True if there was something that the plugin did to invalidate. This means that it makes sense to try again. If nothing happens returns False to indicate give up.
- Return type
-
-
class
keystoneauth1.tests.unit.test_session.
CalledAuthPlugin
(invalidate=True)¶ Bases:
keystoneauth1.plugin.BaseAuthPlugin
-
ENDPOINT
= 'http://fakeendpoint/'¶
-
PROJECT_ID
= '45583de8b4544b20a459402dbce33689'¶
-
TOKEN
= 'a2aac210ef4348ca9e633e8894cbf740'¶
-
USER_ID
= '65a7bb0e968f4963b6f5ba83f52621ea'¶
-
get_endpoint
(session, **kwargs)¶ Return an endpoint for the client.
There are no required keyword arguments to
get_endpoint
as a plugin implementation should use best effort with the information available to determine the endpoint. However there are certain standard options that will be generated by the clients and should be used by plugins:service_type
: what sort of service is required.service_name
: the name of the service in the catalog.interface
: what visibility the endpoint should have.region_name
: the region the endpoint exists in.
- Parameters
session (keystoneauth1.session.Session) – The session object that the auth_plugin belongs to.
- Returns
The base URL that will be used to talk to the required service or None if not available.
- Return type
string
-
get_project_id
(session, **kwargs)¶ Return the project id that we are authenticated to.
Wherever possible the project id should be inferred from the token however there are certain URLs and other places that require access to the currently authenticated project id.
- Parameters
session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.
- Returns
A project identifier or None if one is not available.
- Return type
-
get_token
(session)¶ Obtain a token.
How the token is obtained is up to the plugin. If it is still valid it may be re-used, retrieved from cache or invoke an authentication request against a server.
There are no required kwargs. They are passed directly to the auth plugin and they are implementation specific.
Returning None will indicate that no token was able to be retrieved.
This function is misplaced as it should only be required for auth plugins that use the ‘X-Auth-Token’ header. However due to the way plugins evolved this method is required and often called to trigger an authentication request on a new plugin.
When implementing a new plugin it is advised that you implement this method, however if you don’t require the ‘X-Auth-Token’ header override the get_headers method instead.
- Parameters
session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.
- Returns
A token to use.
- Return type
string
-
get_user_id
(session, **kwargs)¶ Return a unique user identifier of the plugin.
Wherever possible the user id should be inferred from the token however there are certain URLs and other places that require access to the currently authenticated user id.
- Parameters
session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.
- Returns
A user identifier or None if one is not available.
- Return type
-
invalidate
()¶ Invalidate the current authentication data.
This should result in fetching a new token on next call.
A plugin may be invalidated if an Unauthorized HTTP response is returned to indicate that the token may have been revoked or is otherwise now invalid.
- Returns
True if there was something that the plugin did to invalidate. This means that it makes sense to try again. If nothing happens returns False to indicate give up.
- Return type
-
-
class
keystoneauth1.tests.unit.test_session.
RedirectTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
DEFAULT_REDIRECT_BODY
= 'Redirect'¶
-
DEFAULT_RESP_BODY
= 'Found'¶
-
REDIRECT_CHAIN
= ['http://myhost:3445/', 'http://anotherhost:6555/', 'http://thirdhost/', 'http://finaldestination:55/']¶
-
assertResponse
(resp)¶
-
setup_redirects
(method='GET', status_code=305, redirect_kwargs={}, final_kwargs={})¶
-
test_basic_get
()¶
-
test_basic_post_keeps_correct_method
()¶
-
test_history_matches_requests
()¶
-
test_no_redirect
()¶
-
test_permanent_redirect_308
()¶
-
test_redirect_forever
()¶
-
test_redirect_limit
()¶
-
-
class
keystoneauth1.tests.unit.test_session.
RequestsAuth
(*args, **kwargs)¶ Bases:
requests.auth.AuthBase
-
class
keystoneauth1.tests.unit.test_session.
SessionAuthTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
TEST_JSON
= {'hello': 'world'}¶
-
TEST_URL
= 'http://127.0.0.1:5000/'¶
-
stub_service_url
(service_type, interface, path, method='GET', **kwargs)¶
-
test_auth_plugin_default_with_plugin
()¶
-
test_auth_plugin_disable
()¶
-
test_collect_timing
()¶
-
test_endpoint_override_does_id_replacement
()¶
-
test_endpoint_override_fails_to_do_unknown_replacement
()¶
-
test_endpoint_override_fails_to_replace_if_none
()¶
-
test_endpoint_override_ignore_full_url
()¶
-
test_endpoint_override_overrides_filter
()¶
-
test_logger_object_passed
()¶
-
test_object_delete
()¶
-
test_passed_auth_plugin
()¶
-
test_passed_auth_plugin_overrides
()¶
-
test_raises_exc_only_when_asked
()¶
-
test_reauth_called
()¶
-
test_reauth_not_called
()¶
-
test_requests_auth_plugin
()¶
-
test_service_type_urls
()¶
-
test_service_url_raises_if_no_auth_plugin
()¶
-
test_service_url_raises_if_no_url_returned
()¶
-
test_split_loggers
()¶
-
test_user_and_project_id
()¶
-
-
class
keystoneauth1.tests.unit.test_session.
SessionTests
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
TEST_URL
= 'http://127.0.0.1:5000/'¶
-
test_api_sig_error_message_empty
()¶
-
test_api_sig_error_message_multiple
()¶
-
test_api_sig_error_message_single
()¶
-
test_connect_retries
()¶
-
test_connect_retries_fixed_delay
()¶
-
test_connect_retries_interval_limit
()¶
-
test_delete
()¶
-
test_does_not_set_tcp_keepalive_on_custom_sessions
()¶
-
test_error_message_unknown_schema
()¶
-
test_get
()¶
-
test_head
()¶
-
test_http_503_retries
()¶
-
test_http_session_opts
()¶
-
test_http_status_retries
()¶
-
test_http_status_retries_another_code
()¶
-
test_http_status_retries_fixed_delay
()¶
-
test_http_status_retries_inverval_limit
()¶
-
test_json_content_type
()¶
-
test_logging_body_only_for_specified_content_types
()¶ Verify response body is only logged in specific content types.
Response bodies are logged only when the response’s Content-Type header is set to application/json. This prevents us to get an unexpected MemoryError when reading arbitrary responses, such as streams.
-
test_logging_cacerts
()¶
-
test_logs_failed_output
()¶ Test that output is logged even for failed requests.
-
test_microversion
()¶
-
test_not_found
()¶
-
test_patch
()¶
-
test_post
()¶
-
test_put
()¶
-
test_server_error
()¶
-
test_session_debug_output
()¶ Test request and response headers in debug logs.
in order to redact secure headers while debug is true.
-
test_session_debug_output_logs_openstack_request_id
()¶ Test x-openstack-request-id is logged in debug logs.
-
test_set_microversion_headers
()¶
-
test_ssl_error_message
()¶
-
test_user_agent
()¶
-
test_uses_tcp_keepalive_by_default
()¶
-
-
class
keystoneauth1.tests.unit.test_session.
TCPKeepAliveAdapterTest
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
patch
(target, name, *args, **kwargs)¶ Monkey-patch ‘obj.attribute’ to ‘value’ while the test is running.
If ‘obj’ has no attribute, then the monkey-patch will still go ahead, and the attribute will be deleted instead of restored to its original value.
- Parameters
obj – The object to patch. Can be anything.
attribute – The attribute on ‘obj’ to patch.
value – The value to set ‘obj.attribute’ to.
-
patch_socket_with_options
(option_names)¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_init_poolmanager_with_basic_options
()¶
-
test_init_poolmanager_with_given_optionsl
()¶
-
test_init_poolmanager_with_requests_lesser_than_2_4_1
()¶
-
test_init_poolmanager_with_tcp_keepcnt
()¶
-
test_init_poolmanager_with_tcp_keepcnt_on_windows
()¶
-
test_init_poolmanager_with_tcp_keepidle
()¶
-
test_init_poolmanager_with_tcp_keepintvl
()¶
-
keystoneauth1.tests.unit.test_token_endpoint module¶
-
class
keystoneauth1.tests.unit.test_token_endpoint.
AdminTokenTest
(*args, **kwargs)¶ Bases:
keystoneauth1.tests.unit.utils.TestCase
-
test_token_endpoint_deprecated_options
()¶
-
test_token_endpoint_options
()¶
-
keystoneauth1.tests.unit.test_utils module¶
keystoneauth1.tests.unit.utils module¶
-
class
keystoneauth1.tests.unit.utils.
TestCase
(*args, **kwargs)¶ Bases:
testtools.testcase.TestCase
-
TEST_DOMAIN_ID
= 'c72efb024e2b4bd196a2f89986fb068a'¶
-
TEST_DOMAIN_NAME
= '55ed53eafbe748308957809b2ccfd8dc'¶
-
TEST_GROUP_ID
= 'b9b4fb6858a24822be19dd67d2e77269'¶
-
TEST_RECEIPT
= '25372465d6b045808cc953b3fa356677'¶
-
TEST_ROLE_ID
= '4acf9ef8a02643ecbb53facbe2a94a51'¶
-
TEST_ROOT_URL
= 'http://127.0.0.1:5000/'¶
-
TEST_TENANT_ID
= '67a58165632849009be3a048cbb5cd51'¶
-
TEST_TENANT_NAME
= 'c59078d87bf64a90afee0196cc2bb57e'¶
-
TEST_TOKEN
= 'a2aac210ef4348ca9e633e8894cbf740'¶
-
TEST_TRUST_ID
= '7ee3d98194c74a31916266bf61976f71'¶
-
TEST_USER
= '58797dff55ec46d1bcf31da3d003e96d'¶
-
TEST_USER_ID
= 'c757485bb94f424293a4af1aca5f14cd'¶
-
assertContentTypeIs
(content_type)¶
-
assertQueryStringContains
(**kwargs)¶ Verify the query string contains the expected parameters.
This method is used to verify that the query string for the most recent request made contains all the parameters provided as
kwargs
, and that the value of each parameter contains the value for the kwarg. If the value for the kwarg is an empty string (‘’), then all that’s verified is that the parameter is present.
-
assertQueryStringIs
(qs='')¶ Verify the QueryString matches what is expected.
The qs parameter should be of the format ‘foo=bar&abc=xyz’
-
assertRequestBodyIs
(body=None, json=None)¶
-
assertRequestHeaderEqual
(name, val)¶ Verify that the last request made contains a header and its value.
The request must have already been made.
-
assertRequestNotInHeader
(name)¶ Verify that the last request made does not contain a header key.
The request must have already been made.
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
stub_url
(method, parts=None, base_url=None, json=None, **kwargs)¶
-
-
class
keystoneauth1.tests.unit.utils.
TestResponse
(data)¶ Bases:
requests.models.Response
Class used to wrap requests.Response.
This provides some convenience to initialize with a dict.
-
property
text
¶ Content of the response, in unicode.
If Response.encoding is None, encoding will be guessed using
chardet
.The encoding of the response content is determined based solely on HTTP headers, following RFC 2616 to the letter. If you can take advantage of non-HTTP knowledge to make a better guess at the encoding, you should set
r.encoding
appropriately before accessing this property.
-
property