keystoneauth1.fixture package¶
Submodules¶
- keystoneauth1.fixture.discovery module
DiscoveryBase
DiscoveryBase.__annotations__
DiscoveryBase.__dict__
DiscoveryBase.__doc__
DiscoveryBase.__firstlineno__
DiscoveryBase.__init__()
DiscoveryBase.__module__
DiscoveryBase.__orig_bases__
DiscoveryBase.__static_attributes__
DiscoveryBase.__weakref__
DiscoveryBase.add_link()
DiscoveryBase.add_media_type()
DiscoveryBase.id
DiscoveryBase.links
DiscoveryBase.media_types
DiscoveryBase.status
DiscoveryBase.updated
DiscoveryBase.updated_str
DiscoveryList
DiscoveryList.TEST_URL
DiscoveryList.__annotations__
DiscoveryList.__dict__
DiscoveryList.__doc__
DiscoveryList.__firstlineno__
DiscoveryList.__init__()
DiscoveryList.__module__
DiscoveryList.__orig_bases__
DiscoveryList.__static_attributes__
DiscoveryList.__weakref__
DiscoveryList.add_microversion()
DiscoveryList.add_nova_microversion()
DiscoveryList.add_v2()
DiscoveryList.add_v3()
DiscoveryList.add_version()
DiscoveryList.versions
MicroversionDiscovery
NovaMicroversionDiscovery
NovaMicroversionDiscovery.__annotations__
NovaMicroversionDiscovery.__doc__
NovaMicroversionDiscovery.__firstlineno__
NovaMicroversionDiscovery.__init__()
NovaMicroversionDiscovery.__module__
NovaMicroversionDiscovery.__static_attributes__
NovaMicroversionDiscovery.min_version
NovaMicroversionDiscovery.version
V2Discovery
V3Discovery
VersionDiscovery
- keystoneauth1.fixture.exception module
- keystoneauth1.fixture.hooks module
- keystoneauth1.fixture.keystoneauth_betamax module
- keystoneauth1.fixture.plugin module
LoadingFixture
LoadingFixture.MOCK_POINT
LoadingFixture.__annotations__
LoadingFixture.__doc__
LoadingFixture.__firstlineno__
LoadingFixture.__init__()
LoadingFixture.__module__
LoadingFixture.__static_attributes__
LoadingFixture.create_plugin()
LoadingFixture.get_endpoint()
LoadingFixture.get_plugin_loader()
LoadingFixture.setUp()
TestPlugin
TestPlugin.__annotations__
TestPlugin.__doc__
TestPlugin.__firstlineno__
TestPlugin.__init__()
TestPlugin.__module__
TestPlugin.__static_attributes__
TestPlugin._discovery_cache
TestPlugin.auth_type
TestPlugin.get_endpoint()
TestPlugin.get_project_id()
TestPlugin.get_token()
TestPlugin.get_user_id()
TestPlugin.invalidate()
_TestPluginLoader
_TestPluginLoader.__abstractmethods__
_TestPluginLoader.__doc__
_TestPluginLoader.__firstlineno__
_TestPluginLoader.__init__()
_TestPluginLoader.__module__
_TestPluginLoader.__orig_bases__
_TestPluginLoader.__parameters__
_TestPluginLoader.__static_attributes__
_TestPluginLoader._abc_impl
_TestPluginLoader.create_plugin()
_TestPluginLoader.get_options()
_format_endpoint()
- keystoneauth1.fixture.serializer module
- keystoneauth1.fixture.v2 module
Token
Token.__dict__
Token.__doc__
Token.__firstlineno__
Token.__init__()
Token.__module__
Token.__orig_bases__
Token.__static_attributes__
Token.__weakref__
Token._metadata
Token._token
Token._user
Token.add_role()
Token.add_service()
Token.audit_chain_id
Token.audit_id
Token.expires
Token.expires_str
Token.issued
Token.issued_str
Token.remove_service()
Token.root
Token.set_bind()
Token.set_scope()
Token.set_trust()
Token.tenant_id
Token.tenant_name
Token.token_id
Token.trust_id
Token.trustee_user_id
Token.user_id
Token.user_name
Token.validate()
_Service
- keystoneauth1.fixture.v3 module
Token
Token.__annotations__
Token.__dict__
Token.__doc__
Token.__firstlineno__
Token.__init__()
Token.__module__
Token.__orig_bases__
Token.__static_attributes__
Token.__weakref__
Token._user
Token._user_domain
Token.add_role()
Token.add_service()
Token.add_service_provider()
Token.application_credential_access_rules
Token.application_credential_id
Token.audit_chain_id
Token.audit_id
Token.domain_id
Token.domain_name
Token.expires
Token.expires_str
Token.is_admin_project
Token.issued
Token.issued_str
Token.methods
Token.oauth2_credential
Token.oauth2_thumbprint
Token.oauth_access_token_id
Token.oauth_consumer_id
Token.project_domain_id
Token.project_domain_name
Token.project_id
Token.project_is_domain
Token.project_name
Token.remove_service()
Token.role_ids
Token.role_names
Token.root
Token.service_providers
Token.set_application_credential()
Token.set_bind()
Token.set_domain_scope()
Token.set_oauth()
Token.set_project_scope()
Token.set_system_scope()
Token.set_trust_scope()
Token.system
Token.trust_id
Token.trust_impersonation
Token.trustee_user_id
Token.trustor_user_id
Token.user_domain_id
Token.user_domain_name
Token.user_id
Token.user_name
Token.validate()
V3FederationToken
_Service
Module contents¶
Produce keystone compliant structures for use in testing.
They are part of the public API because they may be relied upon to generate test tokens for other clients. However they should never be imported into the main client (keystoneauth or other). Because of this there may be dependencies from this module on libraries that are only available in testing.
- class keystoneauth1.fixture.DiscoveryList(href=None, v2=True, v3=True, v2_id=None, v3_id=None, v2_status=None, v2_updated=None, v2_html=True, v2_pdf=True, v3_status=None, v3_updated=None, v3_json=True, v3_xml=True)¶
Bases:
dict
[str
,Any
]A List of version elements.
Creates a correctly structured list of identity service endpoints for use in testing with discovery.
- Parameters:
href (string) – The url that this should be based at.
v2 (bool) – Add a v2 element.
v3 (bool) – Add a v3 element.
v2_status (string) – The status to use for the v2 element.
v2_updated (DateTime) – The update time to use for the v2 element.
v2_html (bool) – True to add a html link to the v2 element.
v2_pdf (bool) – True to add a pdf link to the v2 element.
v3_status (string) – The status to use for the v3 element.
v3_updated (DateTime) – The update time to use for the v3 element.
v3_json (bool) – True to add a html link to the v2 element.
v3_xml (bool) – True to add a pdf link to the v2 element.
- TEST_URL = 'http://keystone.host:5000/'¶
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.fixture.discovery', '__firstlineno__': 286, '__doc__': 'A List of version elements.\n\nCreates a correctly structured list of identity service endpoints for\nuse in testing with discovery.\n\n:param string href: The url that this should be based at.\n:param bool v2: Add a v2 element.\n:param bool v3: Add a v3 element.\n:param string v2_status: The status to use for the v2 element.\n:param DateTime v2_updated: The update time to use for the v2 element.\n:param bool v2_html: True to add a html link to the v2 element.\n:param bool v2_pdf: True to add a pdf link to the v2 element.\n:param string v3_status: The status to use for the v3 element.\n:param DateTime v3_updated: The update time to use for the v3 element.\n:param bool v3_json: True to add a html link to the v2 element.\n:param bool v3_xml: True to add a pdf link to the v2 element.\n', 'TEST_URL': 'http://keystone.host:5000/', '__init__': <function DiscoveryList.__init__>, 'versions': <property object>, 'add_version': <function DiscoveryList.add_version>, 'add_v2': <function DiscoveryList.add_v2>, 'add_v3': <function DiscoveryList.add_v3>, 'add_microversion': <function DiscoveryList.add_microversion>, 'add_nova_microversion': <function DiscoveryList.add_nova_microversion>, '__static_attributes__': (), '__orig_bases__': (dict[str, typing.Any],), '__dict__': <attribute '__dict__' of 'DiscoveryList' objects>, '__weakref__': <attribute '__weakref__' of 'DiscoveryList' objects>, '__annotations__': {}})¶
- __doc__ = 'A List of version elements.\n\nCreates a correctly structured list of identity service endpoints for\nuse in testing with discovery.\n\n:param string href: The url that this should be based at.\n:param bool v2: Add a v2 element.\n:param bool v3: Add a v3 element.\n:param string v2_status: The status to use for the v2 element.\n:param DateTime v2_updated: The update time to use for the v2 element.\n:param bool v2_html: True to add a html link to the v2 element.\n:param bool v2_pdf: True to add a pdf link to the v2 element.\n:param string v3_status: The status to use for the v3 element.\n:param DateTime v3_updated: The update time to use for the v3 element.\n:param bool v3_json: True to add a html link to the v2 element.\n:param bool v3_xml: True to add a pdf link to the v2 element.\n'¶
- __firstlineno__ = 286¶
- __init__(href=None, v2=True, v3=True, v2_id=None, v3_id=None, v2_status=None, v2_updated=None, v2_html=True, v2_pdf=True, v3_status=None, v3_updated=None, v3_json=True, v3_xml=True)¶
- __module__ = 'keystoneauth1.fixture.discovery'¶
- __orig_bases__ = (dict[str, typing.Any],)¶
- __static_attributes__ = ()¶
- __weakref__¶
list of weak references to the object
- add_microversion(href, id, **kwargs)¶
Add a microversion version to the list.
The parameters are the same as MicroversionDiscovery.
- add_nova_microversion(href, id, **kwargs)¶
Add a nova microversion version to the list.
The parameters are the same as NovaMicroversionDiscovery.
- add_v2(href, **kwargs)¶
Add a v2 version to the list.
The parameters are the same as V2Discovery.
- add_v3(href, **kwargs)¶
Add a v3 version to the list.
The parameters are the same as V3Discovery.
- add_version(version)¶
Add a new version structure to the list.
- Parameters:
version (dict) – A new version structure to add to the list.
- property versions¶
- exception keystoneauth1.fixture.FixtureValidationError¶
Bases:
Exception
The token you created is not legitimate.
The data contained in the token that was generated is not valid and would not have been returned from a keystone server. You should not do testing with this token.
- __doc__ = 'The token you created is not legitimate.\n\nThe data contained in the token that was generated is not valid and would\nnot have been returned from a keystone server. You should not do testing\nwith this token.\n'¶
- __firstlineno__ = 14¶
- __module__ = 'keystoneauth1.fixture.exception'¶
- __static_attributes__ = ()¶
- __weakref__¶
list of weak references to the object
- class keystoneauth1.fixture.LoadingFixture(token=None, endpoint=None, user_id=None, project_id=None)¶
Bases:
Fixture
A fixture that will stub out all plugin loading calls.
When using keystoneauth plugins loaded from config, CLI or elsewhere it is often difficult to handle the plugin parts in tests because we don’t have a reasonable default.
This fixture will create a
TestPlugin
that will be returned for all calls to plugin loading so you can simply bypass the authentication steps and return something well known.- Parameters:
token (str) – The token to include in authenticated requests.
endpoint (str) – The endpoint to respond to service lookups with.
user_id (str) – The user_id to report for the authenticated user.
project_id (str) – The project_id to report for the authenticated user.
- MOCK_POINT = 'keystoneauth1.loading.base.get_plugin_loader'¶
- __doc__ = "A fixture that will stub out all plugin loading calls.\n\nWhen using keystoneauth plugins loaded from config, CLI or elsewhere it is\noften difficult to handle the plugin parts in tests because we don't have a\nreasonable default.\n\nThis fixture will create a :py:class:`TestPlugin` that will be\nreturned for all calls to plugin loading so you can simply bypass the\nauthentication steps and return something well known.\n\n:param str token: The token to include in authenticated requests.\n:param str endpoint: The endpoint to respond to service lookups with.\n:param str user_id: The user_id to report for the authenticated user.\n:param str project_id: The project_id to report for the authenticated user.\n"¶
- __firstlineno__ = 110¶
- __init__(token=None, endpoint=None, user_id=None, project_id=None)¶
- __module__ = 'keystoneauth1.fixture.plugin'¶
- __static_attributes__ = ('endpoint', 'project_id', 'token', 'user_id')¶
- create_plugin()¶
- get_endpoint(path=None, **kwargs)¶
Utility function to get the endpoint the plugin would return.
This function is provided as a convenience so you can do comparisons in your tests. Overriding it will not affect the endpoint returned by the plugin.
- Parameters:
path (str) – The path to append to the plugin endpoint.
- get_plugin_loader(auth_type)¶
- setUp()¶
Prepare the Fixture for use.
This should not be overridden. Concrete fixtures should implement _setUp. Overriding of setUp is still supported, just not recommended.
After setUp has completed, the fixture will have one or more attributes which can be used (these depend totally on the concrete subclass).
- Raises:
MultipleExceptions if _setUp fails. The last exception captured within the MultipleExceptions will be a SetupError exception.
- Returns:
None.
- Changed in 1.3:
The recommendation to override setUp has been reversed - before 1.3, setUp() should be overridden, now it should not be.
- Changed in 1.3.1:
BaseException is now caught, and only subclasses of Exception are wrapped in MultipleExceptions.
- class keystoneauth1.fixture.TestPlugin(token=None, endpoint=None, user_id=None, project_id=None)¶
Bases:
BaseAuthPlugin
A simple plugin that returns what you gave it for testing.
When testing services that use authentication plugins you often want to stub out the authentication calls and focus on the important part of your service. This plugin acts like a real keystoneauth plugin and returns known standard values without having to stub out real keystone responses.
Note that this plugin is a BaseAuthPlugin and not a BaseIdentityPlugin. This means it implements the basic plugin interface that services should be using but does not implement get_auth_ref. get_auth_ref should not be relied upon by services because a user could always configure the service to use a non-keystone auth.
- Parameters:
token (str) – The token to include in authenticated requests.
endpoint (str) – The endpoint to respond to service lookups with.
user_id (str) – The user_id to report for the authenticated user.
project_id (str) – The project_id to report for the authenticated user.
- __annotations__ = {}¶
- __doc__ = 'A simple plugin that returns what you gave it for testing.\n\nWhen testing services that use authentication plugins you often want to\nstub out the authentication calls and focus on the important part of your\nservice. This plugin acts like a real keystoneauth plugin and returns known\nstandard values without having to stub out real keystone responses.\n\nNote that this plugin is a BaseAuthPlugin and not a BaseIdentityPlugin.\nThis means it implements the basic plugin interface that services should be\nusing but does not implement get_auth_ref. get_auth_ref should not be\nrelied upon by services because a user could always configure the service\nto use a non-keystone auth.\n\n:param str token: The token to include in authenticated requests.\n:param str endpoint: The endpoint to respond to service lookups with.\n:param str user_id: The user_id to report for the authenticated user.\n:param str project_id: The project_id to report for the authenticated user.\n'¶
- __firstlineno__ = 40¶
- __init__(token=None, endpoint=None, user_id=None, project_id=None)¶
- __module__ = 'keystoneauth1.fixture.plugin'¶
- __static_attributes__ = ('endpoint', 'project_id', 'token', 'user_id')¶
- auth_type = 'test_plugin'¶
- 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.
kwargs – Ignored.
- 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:
str
- 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.
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:
str
- 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:
bool
- class keystoneauth1.fixture.V2Discovery(href, id=None, html=True, pdf=True, **kwargs)¶
Bases:
DiscoveryBase
A Version element for a V2 identity service endpoint.
Provides some default values and helper methods for creating a v2.0 endpoint version structure. Clients should use this instead of creating their own structures.
- Parameters:
href (string) – The url that this entry should point to.
id (string) – The version id that should be reported. (optional) Defaults to ‘v2.0’.
html (bool) – Add HTML describedby links to the structure.
pdf (bool) – Add PDF describedby links to the structure.
- _DESC_URL = 'https://developer.openstack.org/api-ref/identity/v2/'¶
- __doc__ = "A Version element for a V2 identity service endpoint.\n\nProvides some default values and helper methods for creating a v2.0\nendpoint version structure. Clients should use this instead of creating\ntheir own structures.\n\n:param string href: The url that this entry should point to.\n:param string id: The version id that should be reported. (optional)\n Defaults to 'v2.0'.\n:param bool html: Add HTML describedby links to the structure.\n:param bool pdf: Add PDF describedby links to the structure.\n\n"¶
- __firstlineno__ = 187¶
- __init__(href, id=None, html=True, pdf=True, **kwargs)¶
- __module__ = 'keystoneauth1.fixture.discovery'¶
- __static_attributes__ = ()¶
- add_html_description()¶
Add the HTML described by links.
The standard structure includes a link to a HTML document with the API specification. Add it to this entry.
- add_pdf_description()¶
Add the PDF described by links.
The standard structure includes a link to a PDF document with the API specification. Add it to this entry.
- class keystoneauth1.fixture.V3Discovery(href, id=None, json=True, xml=True, **kwargs)¶
Bases:
DiscoveryBase
A Version element for a V3 identity service endpoint.
Provides some default values and helper methods for creating a v3 endpoint version structure. Clients should use this instead of creating their own structures.
- Parameters:
href – The url that this entry should point to.
id (string) – The version id that should be reported. (optional) Defaults to ‘v3.0’.
json (bool) – Add JSON media-type elements to the structure.
xml (bool) – Add XML media-type elements to the structure.
- __annotations__ = {}¶
- __doc__ = "A Version element for a V3 identity service endpoint.\n\nProvides some default values and helper methods for creating a v3\nendpoint version structure. Clients should use this instead of creating\ntheir own structures.\n\n:param href: The url that this entry should point to.\n:param string id: The version id that should be reported. (optional)\n Defaults to 'v3.0'.\n:param bool json: Add JSON media-type elements to the structure.\n:param bool xml: Add XML media-type elements to the structure.\n"¶
- __firstlineno__ = 239¶
- __init__(href, id=None, json=True, xml=True, **kwargs)¶
- __module__ = 'keystoneauth1.fixture.discovery'¶
- __static_attributes__ = ()¶
- add_json_media_type()¶
Add the JSON media-type links.
The standard structure includes a list of media-types that the endpoint supports. Add JSON to the list.
- add_xml_media_type()¶
Add the XML media-type links.
The standard structure includes a list of media-types that the endpoint supports. Add XML to the list.
- class keystoneauth1.fixture.V3FederationToken(methods=None, identity_provider=None, protocol=None, groups=None)¶
Bases:
Token
A V3 Keystone Federation token that can be used for testing.
Similar to V3Token, this object is designed to allow clients to generate a correct V3 federation token for use in test code.
- FEDERATED_DOMAIN_ID = 'Federated'¶
- __doc__ = 'A V3 Keystone Federation token that can be used for testing.\n\nSimilar to V3Token, this object is designed to allow clients to generate\na correct V3 federation token for use in test code.\n'¶
- __firstlineno__ = 561¶
- __init__(methods=None, identity_provider=None, protocol=None, groups=None)¶
- __module__ = 'keystoneauth1.fixture.v3'¶
- __static_attributes__ = ('_user_domain',)¶
- add_federation_info_to_user(identity_provider=None, protocol=None, groups=None)¶
- class keystoneauth1.fixture.VersionDiscovery(href, id, **kwargs)¶
Bases:
DiscoveryBase
A Version element for non-keystone services without microversions.
Provides some default values and helper methods for creating a microversion endpoint version structure. Clients should use this instead of creating their own structures.
- Parameters:
href (string) – The url that this entry should point to.
id (string) – The version id that should be reported.
- __annotations__ = {}¶
- __doc__ = 'A Version element for non-keystone services without microversions.\n\nProvides some default values and helper methods for creating a microversion\nendpoint version structure. Clients should use this instead of creating\ntheir own structures.\n\n:param string href: The url that this entry should point to.\n:param string id: The version id that should be reported.\n'¶
- __firstlineno__ = 92¶
- __init__(href, id, **kwargs)¶
- __module__ = 'keystoneauth1.fixture.discovery'¶
- __static_attributes__ = ()¶