diff --git a/scubagoggles/Testing/RegoTests/sites/sites01_test.rego b/scubagoggles/Testing/RegoTests/sites/sites01_test.rego deleted file mode 100644 index a67e3d36..00000000 --- a/scubagoggles/Testing/RegoTests/sites/sites01_test.rego +++ /dev/null @@ -1,474 +0,0 @@ -package sites - -import future.keywords -import data.utils.FailTestNoEvent -import data.utils.FailTestGroupNonCompliant -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -test_Sites_Disabled_Correct_V1 if { - # Test ensure Sites is disabled - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Sites_Disabled_Correct_V2 if { - # Test ensure sites is disabled when there's multiple events and the most recent is correct - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Sites_Disabled_Correct_V3 if { - # Test ensure sites is disabled when there are multiple OU's - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Sites_Disabled_Correct_V4 if { - # Test sites is disabled when there are multiple OU's and an older event is non-complaint - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Sites_Disabled_Correct_V5 if { - # Test Sites inheritance - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-10T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:29.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Second OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "INHERIT_FROM_PARENT"}, - {"name": "ORG_UNIT_NAME", "value": "Second OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Sites_Disabled_Incorrect_V1 if { - # Test sites is disabled when there is an event for a different service - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": "Service status for Sites is ON."}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Sites_Disabled_Incorrect_V2 if { - # Test Sites is disabled when there's only one event and it's wrong - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": "Service status for Sites is ON."}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Sites_Disabled_Incorrect_V3 if { - # Test sites is disabled when there are multiple events and the most recent is wrong - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": "Service status for Sites is ON."}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Sites_Disabled_Incorrect_V4 if { - # Test sites is disabled when the Top-level OU is compliant but a secondary OU is non-compliant - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Secondary OU", - "Value": "Service status for Sites is ON."}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Sites_Disabled_Incorrect_V5 if { - # Test sites is disabled when there's only one event and it's wrong - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": "Service status for Sites is ON."}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Sites_Disabled_Incorrect_V6 if { - # Test sites is disabled when there are no relevant events - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", false) -} - -test_Sites_Disabled_Incorrect_V7 if { - # Test Sites enabled in a group - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "GROUP_EMAIL", "value": "group@example.com"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedGroup := [{"Name": "group@example.com", - "Value": "Service status for Sites is ON."}] - FailTestGroupNonCompliant(PolicyId, Output, failedGroup) -} - -test_Sites_Disabled_Incorrect_V8 if { - # Test Sites enabled in a group and an ou - PolicyId := SitesId1_1 - Output := tests with input as { - "sites_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "TOGGLE_SERVICE_ENABLED", - "parameters": [ - {"name": "SERVICE_NAME", "value": "Sites"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "GROUP_EMAIL", "value": "group@example.com"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - RuleOutput := [Result | some Result in Output; Result.PolicyId == PolicyId] - count(RuleOutput) == 1 - not RuleOutput[0].RequirementMet - not RuleOutput[0].NoSuchEvent - RuleOutput[0].ReportDetails == concat("", [ - "The following OUs are non-compliant: