From 653aa4373a76546a96a3086e762f7808750594d1 Mon Sep 17 00:00:00 2001 From: Sophie Depassio Date: Wed, 18 Sep 2024 11:41:20 +0200 Subject: [PATCH] split test to have one test per mode --- ...loudtrail.robot => checktrailstatus.robot} | 0 tests/cloud/aws/cloudtrail/countevents.robot | 53 +++++++++++++++++++ 2 files changed, 53 insertions(+) rename tests/cloud/aws/cloudtrail/{cloud-aws-cloudtrail.robot => checktrailstatus.robot} (100%) create mode 100644 tests/cloud/aws/cloudtrail/countevents.robot diff --git a/tests/cloud/aws/cloudtrail/cloud-aws-cloudtrail.robot b/tests/cloud/aws/cloudtrail/checktrailstatus.robot similarity index 100% rename from tests/cloud/aws/cloudtrail/cloud-aws-cloudtrail.robot rename to tests/cloud/aws/cloudtrail/checktrailstatus.robot diff --git a/tests/cloud/aws/cloudtrail/countevents.robot b/tests/cloud/aws/cloudtrail/countevents.robot new file mode 100644 index 0000000000..53fbda1aef --- /dev/null +++ b/tests/cloud/aws/cloudtrail/countevents.robot @@ -0,0 +1,53 @@ +*** Settings *** +Documentation AWS CloudTrail plugin + +Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource + +Suite Setup Start Mockoon ${MOCKOON_JSON} +Suite Teardown Stop Mockoon +Test Timeout 120s + + +*** Variables *** +${MOCKOON_JSON} ${CURDIR}${/}cloud-aws-cloudtrail.json + +${CMD} ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtrail::plugin --custommode=paws --region=eu-west --aws-secret-key=secret --aws-access-key=key + + +*** Test Cases *** +AWS CloudTrail check trail status + [Documentation] Check AWS CloudTrail trail status + [Tags] cloud aws cloudtrail + + ${command} Catenate + ... ${CMD} + ... --mode=checktrailstatus + ... --endpoint=http://${HOSTNAME}:${APIPORT}/cloudtrail/gettrailstatus/${trailstatus} + ... --trail-name=trailname + Ctn Run Command And Check Result As Strings ${command} ${expected_result} + + Examples: tc trailstatus expected_result -- + ... 1 true OK: Trail is logging: 1 | 'trail_is_logging'=1;;;0; + ... 2 false CRITICAL: Trail is logging: 0 | 'trail_is_logging'=0;;;0; + +AWS CloudTrail count events + [Documentation] Check AWS CloudTrail count events + [Tags] cloud aws cloudtrail + + ${command} Catenate + ... ${CMD} + ... --mode=countevents + ... --endpoint=http://localhost:3000/cloudtrail/events/AwsApiCall/${AwsApiCall}/AwsServiceEvent/${AwsServiceEvent}/AwsConsoleAction/${AwsConsoleAction}/AwsConsoleSignIn/${AwsConsoleSignIn}/NextToken/${NextToken} + ... ${extraoptions} + Ctn Run Command And Check Result As Strings ${command} ${expected_result} + + Examples: tc AwsApiCall AwsServiceEvent AwsConsoleAction AwsConsoleSignIn NextToken extraoptions expected_result -- + ... 1 4 2 1 3 false ${EMPTY} OK: Number of events: 10.00 | 'events_count'=10.00;;;0; + ... 2 4 2 1 3 true ${EMPTY} OK: Number of events: 20.00 | 'events_count'=20.00;;;0; + ... 3 4 2 1 3 false --event-type=AwsApiCall OK: Number of events: 4.00 | 'events_count'=4.00;;;0; + ... 4 4 2 1 3 false --event-type=AwsServiceEvent OK: Number of events: 2.00 | 'events_count'=2.00;;;0; + ... 5 4 2 1 3 false --delta=10 OK: Number of events: 10.00 | 'events_count'=10.00;;;0; + ... 6 4 2 1 3 false --error-message='Login error' OK: Number of events: 3.00 | 'events_count'=3.00;;;0; + ... 7 4 2 1 3 false --error-message='.*error' OK: Number of events: 4.00 | 'events_count'=4.00;;;0; + ... 8 4 2 1 3 false --warning-count=3 WARNING: Number of events: 10.00 | 'events_count'=10.00;;;0; + ... 9 4 2 1 3 false --critical-count=5 CRITICAL: Number of events: 10.00 | 'events_count'=10.00;;;0;