Example #1
0
 def test_extracts_dates_from_digest_keys(self):
     arn = (
         "AWSLogs/{account}/CloudTrail-Digest/us-east-1/2015/08/"
         "16/{account}_CloudTrail-Digest_us-east-1_foo_us-east-1_"
         "20150816T230550Z.json.gz"
     ).format(account=TEST_ACCOUNT_ID)
     self.assertEqual("20150816T230550Z", extract_digest_key_date(arn))
Example #2
0
 def create_link(key, next_key, next_bucket, position, action, logs, bucket):
     """Creates a link in a digest chain for testing."""
     digest_logs = []
     if len(logs) > position:
         digest_logs = logs[position]
     end_date = parse_date(extract_digest_key_date(key))
     # gap actions have no previous link.
     if action == "gap":
         digest = MockDigestProvider.create_digest(
             key=key, bucket=bucket, fingerprint=str(position), start_date=end_date, logs=digest_logs
         )
     else:
         digest = MockDigestProvider.create_digest(
             key=key,
             bucket=bucket,
             fingerprint=str(position),
             start_date=end_date,
             next_bucket=next_bucket,
             next_key=next_key,
             logs=digest_logs,
         )
         # Mark the digest as invalid if specified in the action.
         if action == "invalid":
             digest["_invalid"] = True
     return digest, json.dumps(digest)
Example #3
0
 def create_link(key, next_key, next_bucket, position, action, logs,
                 bucket):
     """Creates a link in a digest chain for testing."""
     digest_logs = []
     if len(logs) > position:
         digest_logs = logs[position]
     end_date = parse_date(extract_digest_key_date(key))
     # gap actions have no previous link.
     if action == 'gap':
         digest = MockDigestProvider.create_digest(
             key=key,
             bucket=bucket,
             fingerprint=str(position),
             start_date=end_date,
             logs=digest_logs)
     else:
         digest = MockDigestProvider.create_digest(
             key=key,
             bucket=bucket,
             fingerprint=str(position),
             start_date=end_date,
             next_bucket=next_bucket,
             next_key=next_key,
             logs=digest_logs)
         # Mark the digest as invalid if specified in the action.
         if action == 'invalid':
             digest['_invalid'] = True
     return digest, json.dumps(digest)
Example #4
0
 def test_extracts_dates_from_digest_keys(self):
     arn = ('AWSLogs/{account}/CloudTrail-Digest/us-east-1/2015/08/'
            '16/{account}_CloudTrail-Digest_us-east-1_foo_us-east-1_'
            '20150816T230550Z.json.gz').format(account=TEST_ACCOUNT_ID)
     self.assertEqual('20150816T230550Z', extract_digest_key_date(arn))