

from keystoneclient.auth import base


class Token(base.BaseAuthPlugin):
    """A provider that will always use the given token and endpoint.

    This is really only useful for testing and in certain CLI cases where you
    have a known endpoint and admin token that you want to use.
    """

    def __init__(self, endpoint, token):
        # NOTE(jamielennox): endpoint is reserved for when plugins
        # can be used to provide that information
        self.endpoint = endpoint
        self.token = token

    def get_token(self, session):
        return self.token



from keystoneclient.auth import base


class Token(base.BaseAuthPlugin):
    """A provider that will always use the given token and endpoint.

    This is really only useful for testing and in certain CLI cases where you
    have a known endpoint and admin token that you want to use.
    """

    def __init__(self, endpoint, token):
        # NOTE(jamielennox): endpoint is reserved for when plugins
        # can be used to provide that information
        self.endpoint = endpoint
        self.token = token

    def get_token(self, session):
        return self.token

    def get_endpoint(self, session, **kwargs):
        """Return the supplied endpoint.

        Using this plugin the same endpoint is returned regardless of the
        parameters passed to the plugin.
        """
        return self.endpoint

Add endpoint handling to Token/Endpoint auth
Add endpoint handling to Token/Endpoint auth

This auth plugin was initially created before get_endpoint was
available. Implement the get_endpoint method so that we can use the
plugin with relative URLs.

Closes-Bug: #1323926
Change-Id: Ic868f509e708ad29faf86ec5ceeab2a9c98a24fc

  
  
  from keystoneclient.auth import base
  
  
  class Token(base.BaseAuthPlugin):
      """A provider that will always use the given token and endpoint.
  
      This is really only useful for testing and in certain CLI cases where you
      have a known endpoint and admin token that you want to use.
      """
  
      def __init__(self, endpoint, token):
          # NOTE(jamielennox): endpoint is reserved for when plugins
          # can be used to provide that information
          self.endpoint = endpoint
          self.token = token
  
      def get_token(self, session):
          return self.token
  
+     def get_endpoint(self, session, **kwargs):
+         """Return the supplied endpoint.
+ 
+         Using this plugin the same endpoint is returned regardless of the
+         parameters passed to the plugin.
+         """
+         return self.endpoint
+ 
Add endpoint handling to Token/Endpoint auth
## Code Before:


from keystoneclient.auth import base


class Token(base.BaseAuthPlugin):
    """A provider that will always use the given token and endpoint.

    This is really only useful for testing and in certain CLI cases where you
    have a known endpoint and admin token that you want to use.
    """

    def __init__(self, endpoint, token):
        # NOTE(jamielennox): endpoint is reserved for when plugins
        # can be used to provide that information
        self.endpoint = endpoint
        self.token = token

    def get_token(self, session):
        return self.token

## Instruction:
Add endpoint handling to Token/Endpoint auth
## Code After:


from keystoneclient.auth import base


class Token(base.BaseAuthPlugin):
    """A provider that will always use the given token and endpoint.

    This is really only useful for testing and in certain CLI cases where you
    have a known endpoint and admin token that you want to use.
    """

    def __init__(self, endpoint, token):
        # NOTE(jamielennox): endpoint is reserved for when plugins
        # can be used to provide that information
        self.endpoint = endpoint
        self.token = token

    def get_token(self, session):
        return self.token

    def get_endpoint(self, session, **kwargs):
        """Return the supplied endpoint.

        Using this plugin the same endpoint is returned regardless of the
        parameters passed to the plugin.
        """
        return self.endpoint
