Skip to content

Commit

Permalink
feat(#3341): Add remove_from_bucket test
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-stefani committed Feb 14, 2023
1 parent 59d7fcd commit 9b2db42
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions deps/wazuh_testing/wazuh_testing/modules/aws/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
KMS_TYPE = 'kms'
MACIE_TYPE = 'macie'
KMS_TYPE = 'kms'
TRUSTED_ADVISOR_TYPE = 'trusted'
CUSTOM_TYPE = 'custom'
53 changes: 53 additions & 0 deletions deps/wazuh_testing/wazuh_testing/modules/aws/data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,58 @@ def get_data_sample(self) -> str:
)


class TrustedAdvisorDataGenerator(DataGenerator):
BASE_PATH = ''
BASE_FILE_NAME = f'firehose_trustedadvisor-1-'

def get_filename(self) -> str:
"""Return the filename in the Trusted Advisor format.
Example:
<prefix>/<year>/<month>/<day>
Returns:
str: Synthetic filename.
"""
now = datetime.utcnow()
path = join(self.BASE_PATH, now.strftime(cons.PATH_DATE_FORMAT))
name = f"{self.BASE_FILE_NAME}{now.strftime(cons.FILENAME_DATE_FORMAT)}{cons.JSON_EXT}"

return join(path, name)

def get_data_sample(self) -> str:
"""Returns a sample of data according to the Trusted Advisor format.
Returns:
str: Synthetic data.
"""
return json.dumps(
{
'version': '0',
'id': get_random_string(26),
'detail-type': 'Trusted Advisor Check Item Refresh Notification',
'source': 'aws.trustedadvisor',
'account': cons.RANDOM_ACCOUNT_ID,
'time': datetime.utcnow().strftime(cons.FILENAME_DATE_FORMAT),
'region': 'us-east-1',
'resources': [],
'detail': {
'check-name': 'IAM Group',
'check-item-detail': {
'Status': 'Green',
'Current Usage': '1',
'Limit Name': 'Groups',
'Region': '-',
'Service': 'IAM',
'Limit Amount': '300'
},
'status': 'OK',
'resource_id': '',
'uuid': str(uuid4())
}
}
)


# Maps bucket type with corresponding data generator
buckets_data_mapping = {
cons.CLOUD_TRAIL_TYPE: CloudTrailDataGenerator,
Expand All @@ -614,6 +666,7 @@ def get_data_sample(self) -> str:
cons.NLB_TYPE: NLBDataGenerator,
cons.KMS_TYPE: KMSDataGenerator,
cons.MACIE_TYPE: MacieDataGenerator,
cons.TRUSTED_ADVISOR_TYPE: TrustedAdvisorDataGenerator,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@
metadata:
bucket_type: custom
bucket_name: wazuh-macie-integration-tests

- name: trusted_advisor_remove_from_bucket
description: Trusted Advisor remove from bucket configurations
configuration_parameters:
BUCKET_TYPE: custom
BUCKET_NAME: wazuh-trusted-advisor-integration-tests
metadata:
bucket_type: custom
bucket_name: wazuh-trusted-advisor-integration-tests

0 comments on commit 9b2db42

Please sign in to comment.