(tenant_id,
              entry_generator=None,
              prefix_for_endpoint=None,
              timestamp=format_timestamp,
              response_token=HARD_CODED_TOKEN,
              response_user_id=HARD_CODED_USER_ID,
              response_user_name=HARD_CODED_USER_NAME,
              response_roles=HARD_CODED_ROLES,
              response_default_region=HARD_CODED_DEFAULT_REGION)
return response
Canned response for authentication, with service catalog containing
    endpoints only for services implemented by Mimic.

    :param callable timestamp: A callable, like format_timestamp, which takes a
        datetime and returns a string.
    :param entry_generator: A callable, like canned_entries, which takes a
        datetime and returns an iterable of Entry.

    :return: a JSON-serializable dictionary matching the format of the JSON
             response for the identity ``/v2/tokens`` request.
Canned response for authentication, with service catalog containing
    endpoints only for services implemented by Mimic.
Canned response for authentication with service catalog containing endpoints only for services implemented by Mimic .
def get_token(tenant_id,
              entry_generator=None,
              prefix_for_endpoint=None,
              timestamp=format_timestamp,
              response_token=HARD_CODED_TOKEN,
              response_user_id=HARD_CODED_USER_ID,
              response_user_name=HARD_CODED_USER_NAME,
              response_roles=HARD_CODED_ROLES,
              response_default_region=HARD_CODED_DEFAULT_REGION):
    """
    Canned response for authentication, with service catalog containing
    endpoints only for services implemented by Mimic.

    :param callable timestamp: A callable, like format_timestamp, which takes a
        datetime and returns a string.
    :param entry_generator: A callable, like canned_entries, which takes a
        datetime and returns an iterable of Entry.

    :return: a JSON-serializable dictionary matching the format of the JSON
             response for the identity ``/v2/tokens`` request.
    """
    def entry_json():
        for entry in entry_generator(tenant_id):
            def endpoint_json():
                for endpoint in entry.endpoints:
                    yield {
                        "region": endpoint.region,
                        "tenantId": endpoint.tenant_id,
                        "internalURL": endpoint.url_with_prefix(
                            prefix_for_endpoint(endpoint),
                            internal_url=True
                        ),
                        "publicURL": endpoint.url_with_prefix(
                            prefix_for_endpoint(endpoint)
                        ),
                    }
            yield {
                "name": entry.name,
                "type": entry.type,
                "endpoints": list(endpoint_json())
            }

    response = {
        "access": {
            "token": {
                # TODO: This token should be synthesized and stored in an
                # auth_store-style argument, alongside impersonation tokens.
                "id": response_token,
                "expires": timestamp(datetime.now() + timedelta(days=1)),
                "tenant": {
                    "id": tenant_id,
                    "name": tenant_id},
                "RAX-AUTH:authenticatedBy": ["PASSWORD"]},
            "user": {
                "RAX-AUTH:defaultRegion": response_default_region,
                "id": response_user_id,
                "name": response_user_name,
                "roles": response_roles,
            }
        }
    }

    if entry_generator is not None and prefix_for_endpoint is not None:
        response["access"]["serviceCatalog"] = list(entry_json())
    return response
def get_token ( tenant_id , entry_generator = None , prefix_for_endpoint = None , timestamp = format_timestamp , response_token = HARD_CODED_TOKEN , response_user_id = HARD_CODED_USER_ID , response_user_name = HARD_CODED_USER_NAME , response_roles = HARD_CODED_ROLES , response_default_region = HARD_CODED_DEFAULT_REGION ) : def entry_json ( ) : for entry in entry_generator ( tenant_id ) : def endpoint_json ( ) : for endpoint in entry . endpoints : yield { "region" : endpoint . region , "tenantId" : endpoint . tenant_id , "internalURL" : endpoint . url_with_prefix ( prefix_for_endpoint ( endpoint ) , internal_url = True ) , "publicURL" : endpoint . url_with_prefix ( prefix_for_endpoint ( endpoint ) ) , } yield { "name" : entry . name , "type" : entry . type , "endpoints" : list ( endpoint_json ( ) ) } response = { "access" : { "token" : { # TODO: This token should be synthesized and stored in an # auth_store-style argument, alongside impersonation tokens. "id" : response_token , "expires" : timestamp ( datetime . now ( ) + timedelta ( days = 1 ) ) , "tenant" : { "id" : tenant_id , "name" : tenant_id } , "RAX-AUTH:authenticatedBy" : [ "PASSWORD" ] } , "user" : { "RAX-AUTH:defaultRegion" : response_default_region , "id" : response_user_id , "name" : response_user_name , "roles" : response_roles , } } } if entry_generator is not None and prefix_for_endpoint is not None : response [ "access" ] [ "serviceCatalog" ] = list ( entry_json ( ) ) return response