diff --git a/scubagoggles/Testing/RegoTests/calendar/calendar01_test.rego b/scubagoggles/Testing/RegoTests/calendar/calendar01_test.rego deleted file mode 100644 index 702e7cd7..00000000 --- a/scubagoggles/Testing/RegoTests/calendar/calendar01_test.rego +++ /dev/null @@ -1,634 +0,0 @@ -package calendar - -import future.keywords -import data.utils.FailTestBothNonCompliant -import data.utils.FailTestGroupNonCompliant -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CALENDAR.1.1 -#-- - -test_ExtSharingPrimaryCal_Correct_V1 if { - # Test external sharing for primary calendars when there's only one event - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingPrimaryCal_Correct_V2 if { - # Test external sharing for primary calendars when there's multiple events and the most most recent is correct - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingPrimaryCal_Correct_V3 if { - # Test external sharing for primary calendars when there's multiple OUs - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingPrimaryCal_Correct_V4 if { - # Test external sharing for primary calendars when there's multiple OUs, and an older event is non-compliant - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2020-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingPrimaryCal_Correct_V5 if { - # Test external sharing for primary, inherit from parent - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2020-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "something else"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "INHERIT_FROM_PARENT"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingPrimaryCal_Correct_V6 if { - # Test group - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU OU"}, - {"name": "GROUP_EMAIL", "value": "group1@example.com"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingPrimaryCal_Incorrect_V1 if { - # Test external sharing for primary calendars when there are no relevant events - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "SAME_DOMAIN"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} - -test_ExtSharingPrimaryCal_Incorrect_V2 if { - # Test external sharing for primary calendars when there's only one event and it's wrong - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_1("Share all information, but outsiders cannot change calendars")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_ExtSharingPrimaryCal_Incorrect_V3 if { - # Test external sharing for primary calendars when there are multiple events and the most recent is wrong - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_1("Share all information, but outsiders cannot change calendars")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_ExtSharingPrimaryCal_Incorrect_V4 if { - # Test external sharing for primary calendars when there is no event for the Top-level OU - # but there is one for a different OU - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} - -test_ExtSharingPrimaryCal_Incorrect_V5 if { - # Test external sharing for primary calendars when the Top-Level OU is compliant, - # but a secondary OU is non-compliant - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Secondary OU", - "Value": NonComplianceMessage1_1("Share all information, but outsiders cannot change calendars")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_ExtSharingPrimaryCal_Incorrect_V6 if { - # Test: top-level OU is compliant but a group is non-compliant - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "GROUP_EMAIL", "value": "group1@example.com"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - Value := "Share all information, but outsiders cannot change calendars" - failedGroup := [{"Name": "group1@example.com", - "Value": NonComplianceMessage1_1(Value)}] - FailTestGroupNonCompliant(PolicyId, Output, failedGroup) -} - -test_ExtSharingPrimaryCal_Incorrect_V if { - # Test: top-level OU and a group are non-compliant - PolicyId := CalendarId1_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "GROUP_EMAIL", "value": "group1@example.com"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - Value := "Share all information, but outsiders cannot change calendars" - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_1(Value)}] - failedGroup := [{"Name": "group1@example.com", - "Value": NonComplianceMessage1_1(Value)}] - FailTestBothNonCompliant(PolicyId, Output, failedOU, failedGroup) -} -#-- - -# -# GWS.CALENDAR.1.2 -#-- - -test_ExtSharingSecondaryCal_Correct_V1 if { - # Test external sharing for secondary calendars when there's only one event - PolicyId := CalendarId1_2 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN_FOR_SECONDARY_CALENDAR"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingSecondaryCal_Correct_V2 if { - # Test external sharing for secondary calendars when there's multiple events and the most most recent is correct - PolicyId := CalendarId1_2 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN_FOR_SECONDARY_CALENDAR"}, - {"name": "NEW_VALUE", "value": "SHOW_ONLY_FREE_BUSY_INFORMATION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN_FOR_SECONDARY_CALENDAR"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtSharingSecondaryCal_Incorrect_V1 if { - # Test external sharing for secondary calendars when there are no relevant events - PolicyId := CalendarId1_2 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "SAME_DOMAIN"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", false) -} - -test_ExtSharingSecondaryCal_Incorrect_V2 if { - # Test external sharing for secondary calendars when there's only one event and it's wrong - PolicyId := CalendarId1_2 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN_FOR_SECONDARY_CALENDAR"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_2("Share all information, but outsiders cannot change calendars")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_ExtSharingSecondaryCal_Incorrect_V3 if { - # Test external sharing for secondary calendars when there are multiple events and the most recent is wrong - PolicyId := CalendarId1_2 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN_FOR_SECONDARY_CALENDAR"}, - {"name": "NEW_VALUE", "value": "READ_ONLY_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "SHARING_OUTSIDE_DOMAIN_FOR_SECONDARY_CALENDAR"}, - {"name": "NEW_VALUE", "value": "READ_WRITE_ACCESS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_2("Share all information, but outsiders cannot change calendars")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- diff --git a/scubagoggles/Testing/RegoTests/calendar/calendar02_test.rego b/scubagoggles/Testing/RegoTests/calendar/calendar02_test.rego deleted file mode 100644 index b5e85b4f..00000000 --- a/scubagoggles/Testing/RegoTests/calendar/calendar02_test.rego +++ /dev/null @@ -1,350 +0,0 @@ -package calendar - -import future.keywords -import data.utils.FailTestBothNonCompliant -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CALENDAR.2.1 -#-- - -test_ExtInvitationsWarning_Correct_V1 if { - # Test external invitations warnings when there's only one event - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtInvitationsWarning_Correct_V2 if { - # Test external invitations warning when there's multiple events and the most most recent is correct - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtInvitationsWarning_Correct_V3 if { - # Test external invitations warning when there's multiple OUs - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtInvitationsWarning_Correct_V4 if { - # Test external invitations warning when there's multiple OUs, and an older event is non-compliant - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2020-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_ExtInvitationsWarning_Incorrect_V1 if { - # Test external invitations warning when there are no relevant events - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "SAME_DOMAIN"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} - -test_ExtInvitationsWarning_Incorrect_V2 if { - # Test external invitations warning when there's only one event and it's wrong - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage2_1("disabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_ExtInvitationsWarning_Incorrect_V3 if { - # Test external invitations warning when there are multiple events and the most recent is wrong - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage2_1("disabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_ExtInvitationsWarning_Incorrect_V4 if { - # Test external invitations warning when there is no event for the Top-level OU but there is one for a different OU - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} - -test_ExtInvitationsWarning_Incorrect_V5 if { - # Test external invitations warning when the Top-Level OU is compliant, but a secondary OU is non-compliant - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"} - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Secondary OU", - "Value": NonComplianceMessage2_1("disabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_ExtInvitationsWarning_Incorrect_V6 if { - # Test ou and group - PolicyId := CalendarId2_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EXTERNAL_GUEST_PROMPT"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "GROUP_EMAIL", "value": "group1@example.com"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage2_1("disabled")}] - failedGroup := [{"Name": "group1@example.com", - "Value": NonComplianceMessage2_1("disabled")}] - FailTestBothNonCompliant(PolicyId, Output, failedOU, failedGroup) -} -#-- diff --git a/scubagoggles/Testing/RegoTests/calendar/calendar03_test.rego b/scubagoggles/Testing/RegoTests/calendar/calendar03_test.rego deleted file mode 100644 index fa01ac37..00000000 --- a/scubagoggles/Testing/RegoTests/calendar/calendar03_test.rego +++ /dev/null @@ -1,185 +0,0 @@ -package calendar - -import future.keywords -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CALENDAR.3.1 -#-- - -test_CalInteropMan_Correct_V1 if { -# Test calendar interop management when there's only one event - PolicyId := CalendarId3_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EWS_INTEROP"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_CalInteropMan_Correct_V2 if { - # Test calendar interop management when there's multiple events and the most most recent is correct - PolicyId := CalendarId3_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EWS_INTEROP"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EWS_INTEROP"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_CalInteropMan_Incorrect_V1 if { - # Test calendar interop management when there are no relevant events - PolicyId := CalendarId3_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "SAME_DOMAIN"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} - -test_CalInteropMan_Incorrect_V2 if { - # Test calendar interop management when there's only one event and it's wrong - PolicyId := CalendarId3_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EWS_INTEROP"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage3_1("enabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_CalInteropMan_Incorrect_V3 if { - # Test calendar interop management when there are multiple events and the most recent is wrong - PolicyId := CalendarId3_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EWS_INTEROP"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ENABLE_EWS_INTEROP"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - {"name": "DOMAIN_NAME", "value": "Test Top-Level Domain"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage3_1("enabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- - -# -# GWS.CALENDAR.3.2 -#-- - -test_OAuth_Correct_V1 if { - # Not-Implemented - PolicyId := CalendarId3_2 - Output := tests with input as { - "calendar_logs": {"items": [ - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - RuleOutput := [Result | some Result in Output; Result.PolicyId == PolicyId] - count(RuleOutput) == 1 - not RuleOutput[0].RequirementMet - RuleOutput[0].NoSuchEvent - RuleOutput[0].ReportDetails == "Currently not able to be tested automatically; please manually check." -} -#-- diff --git a/scubagoggles/Testing/RegoTests/calendar/calendar04_test.rego b/scubagoggles/Testing/RegoTests/calendar/calendar04_test.rego deleted file mode 100644 index 8d38c828..00000000 --- a/scubagoggles/Testing/RegoTests/calendar/calendar04_test.rego +++ /dev/null @@ -1,250 +0,0 @@ -package calendar - -import future.keywords -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CALENDAR.4.1 -#-- -test_CalendarAppointmentSlot_Correct_V1 if { - # Test Calendar Appointment Slot when there's only one event - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"} - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_CalendarAppointmentSlot_Correct_V2 if { - # Test Calendar Appointment Slot when there's multiple events and the most recent is correct - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_CalendarAppointmentSlot_Correct_V3 if { - # Test Calendar Appointment Slot when there's correct events in multiple OUs - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-21T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_CalendarAppointmentSlot_Incorrect_V1 if { - # Test Calendar Appointment Slot when there are no relevant events - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_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", true) -} - -test_CalendarAppointmentSlot_Incorrect_V2 if { - # Test Calendar Appointment Slot when there's only one event and it's wrong - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage4_1("enabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_CalendarAppointmentSlot_Incorrect_V3 if { - # Test Calendar Appointment Slot when there are multiple events and the most recent is wrong - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage4_1("enabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_CalendarAppointmentSlot_Incorrect_V4 if { - # Test Calendar Appointment Slot when there's only one event and it's wrong - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Secondary OU", - "Value": NonComplianceMessage4_1("enabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_CalendarAppointmentSlot_Incorrect_V5 if { - # Test Calendar Appointment Slot when there are multiple events and the most recent is wrong - PolicyId := CalendarId4_1 - Output := tests with input as { - "calendar_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "CalendarAppointmentSlotAdminSettingsProto payments_enabled"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Secondary OU", - "Value": NonComplianceMessage4_1("enabled")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- diff --git a/scubagoggles/Testing/RegoTests/calendar/calendar_api03_test.rego b/scubagoggles/Testing/RegoTests/calendar/calendar_api03_test.rego index 9dc04c1b..2d3eb3bf 100644 --- a/scubagoggles/Testing/RegoTests/calendar/calendar_api03_test.rego +++ b/scubagoggles/Testing/RegoTests/calendar/calendar_api03_test.rego @@ -1,6 +1,7 @@ package calendar import future.keywords +import data.utils.FailTestNonCompliant import data.utils.FailTestOUNonCompliant import data.utils.PassTestResult @@ -47,3 +48,23 @@ test_CalendarAPI_Interoperability_Incorrect_1 if { "Value": NonComplianceMessage3_1("enabled")}] FailTestOUNonCompliant(PolicyId, Output, failedOU) } + +# +# GWS.CALENDAR.3.2 +#-- + +test_OAuth_Correct_V1 if { + # Not-Implemented + PolicyId := CalendarId3_2 + Output := tests with input as { + "calendar_logs": {"items": [ + ]}, + "tenant_info": { + "topLevelOU": "Test Top-Level OU" + } + } + + Message := "Currently not able to be tested automatically; please manually check." + FailTestNonCompliant(PolicyId, Output, Message) +} +#-- diff --git a/scubagoggles/rego/Calendar.rego b/scubagoggles/rego/Calendar.rego index 01a41e80..4348d590 100644 --- a/scubagoggles/rego/Calendar.rego +++ b/scubagoggles/rego/Calendar.rego @@ -2,9 +2,6 @@ package calendar import future.keywords import data.utils -import data.utils.PolicyApiInUse - -LogEvents := utils.GetEvents("calendar_logs") CalendarEnabled(orgunit) := utils.AppEnabled(input.policies, "calendar", orgunit) @@ -18,59 +15,17 @@ CalendarEnabled(orgunit) := utils.AppEnabled(input.policies, "calendar", orgunit CalendarId1_1 := utils.PolicyIdWithSuffix("GWS.CALENDAR.1.1") -LogMessage1_1 := "SHARING_OUTSIDE_DOMAIN" - -Check1_1_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage1_1, utils.TopLevelOU) - count(events) > 0 -} - -Check1_1_OK if {PolicyApiInUse} - GetFriendlyValue1_1(Value) := "Share all information, but outsiders cannot change calendars" if { - Value in {"EXTERNAL_ALL_INFO_READ_ONLY", "READ_ONLY_ACCESS"} + Value == "EXTERNAL_ALL_INFO_READ_ONLY" } else := "Share all information, and outsiders can change calendars" if { - Value in {"EXTERNAL_ALL_INFO_READ_WRITE", "READ_WRITE_ACCESS"} + Value == "EXTERNAL_ALL_INFO_READ_WRITE" } else := "Share all information, and allow managing of calendars" if { - Value in {"EXTERNAL_ALL_INFO_READ_WRITE_MANAGE", "MANAGE_ACCESS"} + Value == "EXTERNAL_ALL_INFO_READ_WRITE_MANAGE" } else := Value SharingFmtMsg := "External sharing options for %s calendars is set to: %s" NonComplianceMessage1_1(value) := sprintf(SharingFmtMsg, ["primary", value]) -NonCompliantOUs1_1 contains { - "Name": OU, - "Value": NonComplianceMessage1_1(GetFriendlyValue1_1(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - some OU in utils.OUsWithEvents - Events := utils.FilterEventsOU(LogEvents, LogMessage1_1, OU) - # Ignore OUs without any events. We're already asserting that the - # top-level OU has at least one event; for all other OUs we assume - # they inherit from a parent OU if they have no events. - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue != "SHOW_ONLY_FREE_BUSY_INFORMATION" - LastEvent.NewValue != "INHERIT_FROM_PARENT" -} - -NonCompliantGroups1_1 contains { - "Name": Group, - "Value": NonComplianceMessage1_1(GetFriendlyValue1_1(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - some Group in utils.GroupsWithEvents - Events := utils.FilterEventsGroup(LogEvents, LogMessage1_1, Group) - # Ignore Group without any events - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue != "SHOW_ONLY_FREE_BUSY_INFORMATION" - LastEvent.NewValue != "INHERIT_FROM_PARENT" -} - NonCompliantOUs1_1 contains { "Name": OU, "Value": NonComplianceMessage1_1(GetFriendlyValue1_1(primaryShare)) @@ -86,29 +41,13 @@ if { tests contains { "PolicyId": CalendarId1_1, "Criticality": "Shall", - "ReportDetails": utils.NoSuchEventDetails(DefaultSafe, utils.TopLevelOU), - "ActualValue": "No relevant event for the top-level OU in the current logs.", - "RequirementMet": DefaultSafe, - "NoSuchEvent": true -} -if { - not PolicyApiInUse - DefaultSafe := true - not Check1_1_OK -} - -tests contains { - "PolicyId": CalendarId1_1, - "Criticality": "Shall", - "ReportDetails": utils.ReportDetails(NonCompliantOUs1_1, NonCompliantGroups1_1), - "ActualValue": {"NonCompliantOUs": NonCompliantOUs1_1, "NonCompliantGroups": NonCompliantGroups1_1}, + "ReportDetails": utils.ReportDetails(NonCompliantOUs1_1, []), + "ActualValue": {"NonCompliantOUs": NonCompliantOUs1_1}, "RequirementMet": Status, "NoSuchEvent": false } if { - Check1_1_OK - Conditions := {count(NonCompliantOUs1_1) == 0, count(NonCompliantGroups1_1) == 0} - Status := (false in Conditions) == false + Status := count(NonCompliantOUs1_1) == 0 } #-- @@ -118,33 +57,10 @@ if { CalendarId1_2 := utils.PolicyIdWithSuffix("GWS.CALENDAR.1.2") -LogMessage1_2 := "SHARING_OUTSIDE_DOMAIN_FOR_SECONDARY_CALENDAR" - -Check1_2_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage1_2, utils.TopLevelOU) - count(events) > 0 -} - -Check1_2_OK if {PolicyApiInUse} - GetFriendlyValue1_2(Value) := GetFriendlyValue1_1(Value) NonComplianceMessage1_2(value) := sprintf(SharingFmtMsg, ["secondary", value]) -NonCompliantOUs1_2 contains { - "Name": utils.TopLevelOU, - "Value": NonComplianceMessage1_2(GetFriendlyValue1_2(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - Events := utils.FilterEventsNoOU(LogEvents, LogMessage1_2) - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue != "SHOW_ONLY_FREE_BUSY_INFORMATION" - LastEvent.NewValue != "INHERIT_FROM_PARENT" -} - NonCompliantOUs1_2 contains { "Name": OU, "Value": NonComplianceMessage1_2(GetFriendlyValue1_2(secondaryShare)) @@ -157,20 +73,6 @@ if { secondaryShare != "EXTERNAL_FREE_BUSY_ONLY" } -tests contains { - "PolicyId": CalendarId1_2, - "Criticality": "Shall", - "ReportDetails": utils.NoSuchEventDetails(DefaultSafe, utils.TopLevelOU), - "ActualValue": "No relevant event for the top-level OU in the current logs", - "RequirementMet": DefaultSafe, - "NoSuchEvent": true -} -if { - not PolicyApiInUse - DefaultSafe := false - not Check1_2_OK -} - tests contains { "PolicyId": CalendarId1_2, "Criticality": "Shall", @@ -180,7 +82,6 @@ tests contains { "NoSuchEvent": false } if { - Check1_2_OK Status := count(NonCompliantOUs1_2) == 0 } #-- @@ -195,49 +96,9 @@ if { CalendarId2_1 := utils.PolicyIdWithSuffix("GWS.CALENDAR.2.1") -LogMessage2_1 := "ENABLE_EXTERNAL_GUEST_PROMPT" - -Check2_1_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage2_1, utils.TopLevelOU) - count(events) > 0 -} - -Check2_1_OK if {PolicyApiInUse} - NonComplianceMessage2_1(value) := sprintf("External Sharing Guest Prompt is %s", [value]) -NonCompliantOUs2_1 contains { - "Name": OU, - "Value": NonComplianceMessage2_1(utils.GetFriendlyEnabledValue(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - some OU in utils.OUsWithEvents - Events := utils.FilterEventsOU(LogEvents, LogMessage2_1, OU) - # Ignore OUs without any events. We're already asserting that the - # top-level OU has at least one event; for all other OUs we assume - # they inherit from a parent OU if they have no events. - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue == "false" -} - -NonCompliantGroups2_1 contains { - "Name": Group, - "Value": NonComplianceMessage2_1(utils.GetFriendlyEnabledValue(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - some Group in utils.GroupsWithEvents - Events := utils.FilterEventsGroup(LogEvents, LogMessage2_1, Group) - # Ignore groups without any events - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue == "false" -} - NonCompliantOUs2_1 contains { "Name": OU, "Value": NonComplianceMessage2_1(utils.GetFriendlyEnabledValue(extWarnPrompt)) @@ -252,29 +113,13 @@ if { tests contains { "PolicyId": CalendarId2_1, "Criticality": "Shall", - "ReportDetails": utils.NoSuchEventDetails(DefaultSafe, utils.TopLevelOU), - "ActualValue": "No relevant event for the top-level OU in the current logs", - "RequirementMet": DefaultSafe, - "NoSuchEvent": true -} -if { - not PolicyApiInUse - DefaultSafe := true - not Check2_1_OK -} - -tests contains { - "PolicyId": CalendarId2_1, - "Criticality": "Shall", - "ReportDetails": utils.ReportDetails(NonCompliantOUs2_1, NonCompliantGroups2_1), - "ActualValue": {"NonCompliantOUs": NonCompliantOUs2_1, "NonCompliantGroups": NonCompliantGroups2_1}, + "ReportDetails": utils.ReportDetails(NonCompliantOUs2_1, []), + "ActualValue": {"NonCompliantOUs": NonCompliantOUs2_1}, "RequirementMet": Status, "NoSuchEvent": false } if { - Check2_1_OK - Conditions := {count(NonCompliantOUs2_1) == 0, count(NonCompliantGroups2_1) == 0} - Status := (false in Conditions) == false + Status := count(NonCompliantOUs2_1) == 0 } #-- @@ -288,31 +133,9 @@ if { CalendarId3_1 := utils.PolicyIdWithSuffix("GWS.CALENDAR.3.1") -LogMessage3_1 := "ENABLE_EWS_INTEROP" - -Check3_1_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage3_1, utils.TopLevelOU) - count(events) > 0 -} - -Check3_1_OK if {PolicyApiInUse} - NonComplianceMessage3_1(value) := sprintf("Calendar interoperation is %s", [value]) -NonCompliantOUs3_1 contains { - "Name": utils.TopLevelOU, - "Value": NonComplianceMessage3_1(utils.GetFriendlyEnabledValue(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - Events := utils.FilterEventsNoOU(LogEvents, LogMessage3_1) - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue != "false" -} - NonCompliantOUs3_1 contains { "Name": OU, "Value": NonComplianceMessage3_1(utils.GetFriendlyEnabledValue(interoperability)) @@ -324,20 +147,6 @@ if { interoperability != false } -tests contains { - "PolicyId": CalendarId3_1, - "Criticality": "Should", - "ReportDetails": utils.NoSuchEventDetails(DefaultSafe, utils.TopLevelOU), - "ActualValue": "No relevant event for the top-level OU in the current logs", - "RequirementMet": DefaultSafe, - "NoSuchEvent": true -} -if { - not PolicyApiInUse - DefaultSafe := true - not Check3_1_OK -} - tests contains { "PolicyId": CalendarId3_1, "Criticality": "Should", @@ -347,7 +156,6 @@ tests contains { "NoSuchEvent": false } if { - Check3_1_OK Status := count(NonCompliantOUs3_1) == 0 } #-- @@ -364,7 +172,7 @@ tests contains { "ReportDetails": "Currently not able to be tested automatically; please manually check.", "ActualValue": "", "RequirementMet": false, - "NoSuchEvent": true + "NoSuchEvent": false } #-- @@ -378,35 +186,9 @@ tests contains { CalendarId4_1 := utils.PolicyIdWithSuffix("GWS.CALENDAR.4.1") -LogMessage4_1 := "CalendarAppointmentSlotAdminSettingsProto payments_enabled" - -Check4_1_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage4_1, utils.TopLevelOU) - count(events) > 0 -} - -Check4_1_OK if {PolicyApiInUse} - NonComplianceMessage4_1(value) := sprintf("Paid calendar appointments are %s", [value]) -NonCompliantOUs4_1 contains { - "Name": OU, - "Value": NonComplianceMessage4_1(utils.GetFriendlyEnabledValue(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - some OU in utils.OUsWithEvents - Events := utils.FilterEventsOU(LogEvents, LogMessage4_1, OU) - # Ignore OUs without any events. We're already asserting that the - # top-level OU has at least one event; for all other OUs we assume - # they inherit from a parent OU if they have no events. - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue == "true" -} - NonCompliantOUs4_1 contains { "Name": OU, "Value": NonComplianceMessage4_1(utils.GetFriendlyEnabledValue(payments)) @@ -418,20 +200,6 @@ if { payments != false } -tests contains { - "PolicyId": CalendarId4_1, - "Criticality": "Shall", - "ReportDetails": utils.NoSuchEventDetails(DefaultSafe, utils.TopLevelOU), - "ActualValue": "No relevant event for the top-level OU in the current logs.", - "RequirementMet": DefaultSafe, - "NoSuchEvent": true -} -if { - not PolicyApiInUse - DefaultSafe := true - not Check4_1_OK -} - tests contains { "PolicyId": CalendarId4_1, "Criticality": "Shall", @@ -441,7 +209,6 @@ tests contains { "NoSuchEvent": false } if { - Check4_1_OK Status := count(NonCompliantOUs4_1) == 0 } #--