def authenticate(url, username, api_key):
            client = HTTPClient()
            content = {
                "auth": {
                    "RAX-KSKEY:apiKeyCredentials": {
                        "username": username,
                        "apiKey": api_key
                    }
                }
            }
            body = json.dumps(content)
            response = client.request(
                "POST",
                os.path.join(url, 'v2.0/tokens'),
                data=body,
                headers={'Content-type': 'application/json'})

            return response
Beispiel #2
0
 def setUpClass(cls):
     super(TempUrlTest, cls).setUpClass()
     cls.key_cache_time = (
         cls.objectstorage_api_config.tempurl_key_cache_time)
     cls.http = HTTPClient()
     cls.tempurl_key = Constants.BASE_TEMPURL_KEY
     cls.object_name = Constants.VALID_OBJECT_NAME
     cls.obj_name_containing_trailing_slash = \
         Constants.VALID_OBJECT_NAME_WITH_TRAILING_SLASH
     cls.obj_name_containing_slash = \
         Constants.VALID_OBJECT_NAME_WITH_SLASH
     cls.object_data = Constants.VALID_OBJECT_DATA
     cls.content_length = str(len(Constants.VALID_OBJECT_DATA))
Beispiel #3
0
 def test_persistent_session_calls_logging_hook_on_request(self):
     self._logging_hook_test(
         HTTPClient(logging_hook=mock.MagicMock(),
                    persistent_session=True), )
Beispiel #4
0
 def test_ephemeral_session_calls_logging_hook_on_request(self):
     self._logging_hook_test(HTTPClient(logging_hook=mock.MagicMock()), )
Beispiel #5
0
 def test_persistent_session_mounted_hooks(self):
     httpc = HTTPClient(persistent_session=True)
     for adapter_mount_point in httpc._session.adapters.keys():
         self.assertIsInstance(httpc._session.adapters[adapter_mount_point],
                               HookableHTTPAdapter)
Beispiel #6
0
 def test_persistent_session_instantiation(self):
     httpc = HTTPClient(persistent_session=True)
     self.assertIsInstance(httpc._session, Session)
Beispiel #7
0
 def test_init_accepts_user_defined_LoggingHook(self):
     hook = CafeLoggingHook(logging.getLogger())
     httpc = HTTPClient(logging_hook=hook)
     self.assertIsInstance(httpc._http_adapter._loghook, CafeLoggingHook)
Beispiel #8
0
 def test_init_accepts_user_defined_HTTPAdapter(self):
     adapter = HTTPAdapter()
     httpc = HTTPClient(http_adapter=adapter)
     self.assertIsInstance(httpc._http_adapter, HTTPAdapter)
Beispiel #9
0
 def test_init_kwarg_default_logging_hook_is_VerboseLoggingHook(self):
     httpc = HTTPClient()
     self.assertIsInstance(httpc._http_adapter._loghook, VerboseLoggingHook)
Beispiel #10
0
 def test_init_kwarg_default_HTTPAdapter_is_HookableHTTPAdapter(self):
     httpc = HTTPClient()
     self.assertIsInstance(httpc._http_adapter, HookableHTTPAdapter)
Beispiel #11
0
 def test_init_with_no_arguments_works(self):
     with self.assertDoesNotRaise():
         HTTPClient()
Beispiel #12
0
 def setUp(self):
     self.httpc = HTTPClient(persistent_session=True)
Beispiel #13
0
 def setUp(self):
     self.httpc = HTTPClient()
Beispiel #14
0
    def setUpClass(cls):
        super(CORSTest, cls).setUpClass()

        cls.dumb_client = HTTPClient()
        cls.object_name = Constants.VALID_OBJECT_NAME