def prepare_request(auth_opts=None, data=None, **kwargs): """Prepares a request This method takes care of authentication and all other steps in the preparation chain. The request returned by this call is ready to be sent to the server. :param auth_opts: Auth parameters :type auth_opts: `dict` :param data: Optional data to send along with the request. If data is not None, it'll be serialized. :type data: Any primitive type that is json-serializable. :param kwargs: Anything accepted by `Request` :returns: A `Request` instance ready to be sent. :rtype: `Request` """ req = Request(**kwargs) auth_backend = auth.get_backend(**(auth_opts or {})) # TODO(flaper87): Do something smarter # to get the api_version. req = auth_backend.authenticate(1, req) if data is not None: req.content = json.dumps(data) return req
def setUp(self): super(TestKeystoneAuth, self).setUp() if not ksclient: self.skipTest('Keystone client is not installed') self.auth = auth.get_backend(backend='keystone', options=self.conf)
def setUp(self): super(TestKeystoneAuth, self).setUp() if not ksclient: self.skipTest("Keystone client is not installed") self.auth = auth.get_backend(backend="keystone", options=self.conf)
def test_get_non_existing_backend(self): try: auth.get_backend('not_existing') self.fail("Test failed") except KeyError: pass
def test_get_backend(self): try: auth.get_backend(options=self.conf) except KeyError: self.fail("Test failed")