Ejemplo n.º 1
0
 def test_create_signed_request_with_iam_role_has_token_parameter(self):
     self.builder = RequestBuilder(
         AWSCredentials("access_key", "secret_key", "token"), self.region)
     metric = MetricDataStatistic(
         "test_metric", statistic_values=MetricDataStatistic.Statistics(20))
     request = self.builder.create_signed_request(self.namespace, [metric])
     self.assertTrue("X-Amz-Security-Token" in request)
Ejemplo n.º 2
0
 def setUp(self):
     self.credentials = AWSCredentials("access_key", "secret_key")
     self.region = "test_region"
     self.service = "monitoring"
     self.algorithm = "AWS4-HMAC-SHA256"
     self.signer = Signer(self.credentials, self.region, self.service,
                          self.algorithm)
Ejemplo n.º 3
0
 def test_aws_credentials_with_custom_values(self):
     new_access_key = "accessKey"
     new_secret_key = "secretKey"
     new_token = "token"
     credentials = AWSCredentials(new_access_key, new_secret_key, new_token)
     assert_credentials_data(credentials, new_access_key, new_secret_key,
                             new_token)
Ejemplo n.º 4
0
 def get_regression_signer(self):
     # Warning: changing any of these parameters here will cause regression tests to fail!
     self.credentials = AWSCredentials("access_key", "secret_key")
     self.region = "eu-west-1"
     self.service = "monitoring"
     self.algorithm = "AWS4-HMAC-SHA256"
     return Signer(self.credentials, self.region, self.service,
                   self.algorithm)
Ejemplo n.º 5
0
 def test_get_autoscaling_name_with_iam_role_creds(self):
     instance_id = "i-1818591f"
     self.config_helper.credentials = AWSCredentials(
         "access", "secret", "IAM_ROLE_TOKEN")
     self.client = EC2GetClient(self.config_helper)
     self.client.get_autoscaling_group(instance_id)
     received_request = self.server_get_received_request()
     self.assertTrue(
         "X-Amz-Security-Token=IAM_ROLE_TOKEN" in received_request)
Ejemplo n.º 6
0
 def setUp(self):
     self.server = PutClientTest.FAKE_SERVER
     self.server.set_expected_response("OK", 200)
     self.config_helper = MagicMock()
     self.config_helper.credentials = AWSCredentials("access", "secret")
     self.config_helper.region = "localhost"
     self.config_helper.endpoint = "http://localhost:57575/"
     self.client = PutClient(self.config_helper)
     self.logger = MagicMock()
     self.logger.warning = Mock()
     self.client.__class__._LOGGER = self.logger
Ejemplo n.º 7
0
 def test_credentials_are_updated_in_the_get_client(self):
     instance_id = "i-1818591f"
     self.client.get_autoscaling_group(instance_id)
     received_request = self.server_get_received_request()
     self.assertTrue("access" in received_request)
     self.config_helper.credentials = AWSCredentials(
         "NEW_ACCESS_KEY", "NEW_SECRET_KEY")
     self.client = EC2GetClient(self.config_helper)
     self.client.get_autoscaling_group(instance_id)
     received_request = self.server_get_received_request()
     self.assertTrue("NEW_ACCESS_KEY" in received_request)
Ejemplo n.º 8
0
 def test_put_metric_data_with_iam_role_creds(self):
     metric_name = "test_metric"
     namespace = "testing_namespace"
     metric = MetricDataStatistic(
         metric_name,
         statistic_values=MetricDataStatistic.Statistics(20),
         namespace=namespace)
     self.config_helper.credentials = AWSCredentials(
         "access", "secret", "IAM_ROLE_TOKEN")
     self.client = PutClient(self.config_helper)
     self.client.put_metric_data(namespace, [metric])
     received_request = self.server_get_received_request()
     self.assertTrue(
         "X-Amz-Security-Token=IAM_ROLE_TOKEN" in received_request)
Ejemplo n.º 9
0
 def test_credentials_are_updated_in_the_put_client(self):
     metric = MetricDataStatistic(
         metric_name="test_metric",
         statistic_values=MetricDataStatistic.Statistics(20),
         namespace="testing_namespace")
     self.client.put_metric_data("testing_namespace", [metric])
     received_request = self.server_get_received_request()
     self.assertTrue("access" in received_request)
     self.config_helper.credentials = AWSCredentials(
         "NEW_ACCESS_KEY", "NEW_SECRET_KEY")
     self.client = PutClient(self.config_helper)
     self.client.put_metric_data("testing_namespace", [metric])
     received_request = self.server_get_received_request()
     self.assertTrue("NEW_ACCESS_KEY" in received_request)
Ejemplo n.º 10
0
 def setUp(self):
     self.region = "test_region"
     self.namespace = "test_namespace"
     self.credentials = AWSCredentials("access_key", "secret_key")
     self.builder = RequestBuilder(self.credentials, self.region)
Ejemplo n.º 11
0
 def test_aws_credentials_with_default_constructor(self):
     creds = AWSCredentials()
     assert_credentials_data(creds)