def test_s3_client_created_lazily(self):
     session = Mock()
     command = CloudTrailValidateLogs(session)
     parsed_globals = Mock(region=None, verify_ssl=None, endpoint_url=None)
     command.setup_services(None, parsed_globals)
     create_client_calls = session.create_client.call_args_list
     self.assertEqual(create_client_calls, [call("cloudtrail", verify=None, region_name=None)])
Exemple #2
0
 def test_s3_client_created_lazily(self):
     session = Mock()
     command = CloudTrailValidateLogs(session)
     parsed_globals = Mock(region=None, verify_ssl=None, endpoint_url=None)
     command.setup_services(parsed_globals)
     create_client_calls = session.create_client.call_args_list
     self.assertEqual(create_client_calls,
                      [call('cloudtrail', verify=None, region_name=None)])
 def test_endpoint_url_is_used_for_cloudtrail(self):
     endpoint_url = "https://mycloudtrail.aws.amazon.com/"
     session = Mock()
     command = CloudTrailValidateLogs(session)
     parsed_globals = Mock(region="foo", verify_ssl=None, endpoint_url=endpoint_url)
     command.setup_services(None, parsed_globals)
     create_client_calls = session.create_client.call_args_list
     self.assertEqual(
         create_client_calls, [call("cloudtrail", verify=None, region_name="foo", endpoint_url=endpoint_url)]
     )
 def test_initializes_args(self):
     session = Mock()
     command = CloudTrailValidateLogs(session)
     start_date = START_DATE.strftime(DATE_FORMAT)
     args = Namespace(
         trail_arn="abc", verbose=True, start_time=start_date, s3_bucket="bucket", s3_prefix="prefix", end_time=None
     )
     command.handle_args(args)
     self.assertEqual("abc", command.trail_arn)
     self.assertEqual(True, command.is_verbose)
     self.assertEqual("bucket", command.s3_bucket)
     self.assertEqual("prefix", command.s3_prefix)
     self.assertEqual(start_date, command.start_time.strftime(DATE_FORMAT))
     self.assertIsNotNone(command.end_time)
     self.assertGreater(command.end_time, command.start_time)
Exemple #5
0
 def test_endpoint_url_is_used_for_cloudtrail(self):
     endpoint_url = 'https://mycloudtrail.aws.amazon.com/'
     session = Mock()
     command = CloudTrailValidateLogs(session)
     parsed_globals = Mock(region='foo',
                           verify_ssl=None,
                           endpoint_url=endpoint_url)
     command.setup_services(parsed_globals)
     create_client_calls = session.create_client.call_args_list
     self.assertEqual(create_client_calls, [
         call('cloudtrail',
              verify=None,
              region_name='foo',
              endpoint_url=endpoint_url)
     ])
 def test_initializes_args(self):
     session = Mock()
     command = CloudTrailValidateLogs(session)
     start_date = START_DATE.strftime(DATE_FORMAT)
     args = Namespace(trail_arn='abc', verbose=True,
                      start_time=start_date, s3_bucket='bucket',
                      s3_prefix='prefix', end_time=None)
     command.handle_args(args)
     self.assertEqual('abc', command.trail_arn)
     self.assertEqual(True, command.is_verbose)
     self.assertEqual('bucket', command.s3_bucket)
     self.assertEqual('prefix', command.s3_prefix)
     self.assertEqual(start_date, command.start_time.strftime(DATE_FORMAT))
     self.assertIsNotNone(command.end_time)
     self.assertGreater(command.end_time, command.start_time)
Exemple #7
0
 def test_endpoint_url_is_used_for_cloudtrail(self):
     endpoint_url = 'https://mycloudtrail.aws.amazon.com/'
     session = mock.Mock()
     command = CloudTrailValidateLogs(session)
     parsed_globals = mock.Mock(region='foo',
                                verify_ssl=None,
                                endpoint_url=endpoint_url)
     command.setup_services(parsed_globals)
     create_client_calls = session.create_client.call_args_list
     self.assertEqual(
         create_client_calls,
         [
             mock.call('organizations', verify=None, region_name='foo'),
             # Here we should inject the endpoint_url only for cloudtrail.
             mock.call('cloudtrail',
                       verify=None,
                       region_name='foo',
                       endpoint_url=endpoint_url)
         ])