def test_timeout(self):
     def fake_connection(_address):
         raise socket.timeout('fake error')
     socket.create_connection = fake_connection
     connection = ESConnection('mockservice.cc-zone-1.amazonaws.com',
                               aws_access_key_id='access_key',
                               aws_secret_access_key='secret',
                               region='region_123')
     connection.num_retries = 0
     with self.assertRaises(socket.error):
         connection.make_request('GET', 'https://example.com')
Exemple #2
0
 def test_timeout(self):
     def fake_connection(*args):  # pylint: disable=unused-argument
         raise socket.timeout('fake error')
     socket.create_connection = fake_connection
     connection = ESConnection('mockservice.cc-zone-1.amazonaws.com',
                               aws_access_key_id='access_key',
                               aws_secret_access_key='secret',
                               region='region_123')
     connection.num_retries = 0
     with self.assertRaises(socket.error):
         connection.make_request('GET', 'https://example.com')
Exemple #3
0
    def test_signing(self):
        connection = ESConnection('mockservice.cc-zone-1.amazonaws.com',
                                  aws_access_key_id='my_access_key',
                                  aws_secret_access_key='secret',
                                  region='region_123')
        # create a request and sign it
        request = connection.build_base_http_request('GET', '/', None)
        request.authorize(connection)

        # confirm the header contains signing method and key id
        auth_header = request.headers['Authorization']
        self.assertTrue('AWS4-HMAC-SHA256' in auth_header)
        self.assertTrue('my_access_key' in auth_header)
    def test_signing(self):
        connection = ESConnection('mockservice.cc-zone-1.amazonaws.com',
                                  aws_access_key_id='my_access_key',
                                  aws_secret_access_key='secret',
                                  region='region_123')
        # create a request and sign it
        request = connection.build_base_http_request('GET', '/', None)
        request.authorize(connection)

        # confirm the header contains signing method and key id
        auth_header = request.headers['Authorization']
        self.assertTrue('AWS4-HMAC-SHA256' in auth_header)
        self.assertTrue('my_access_key' in auth_header)
Exemple #5
0
 def test_constructor_params(self):
     connection = ESConnection('mockservice.cc-zone-1.amazonaws.com',
                               aws_access_key_id='access_key',
                               aws_secret_access_key='secret',
                               region='region_123')
     self.assertEqual(connection.auth_region_name, 'region_123')
     self.assertEqual(connection.aws_access_key_id, 'access_key')
     self.assertEqual(connection.aws_secret_access_key, 'secret')