diff --git a/scubagoggles/Testing/RegoTests/chat/chat01_test.rego b/scubagoggles/Testing/RegoTests/chat/chat01_test.rego deleted file mode 100644 index 3e419310..00000000 --- a/scubagoggles/Testing/RegoTests/chat/chat01_test.rego +++ /dev/null @@ -1,627 +0,0 @@ -package chat - -import future.keywords -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CHAT.1.1 -#-- -test_History_Correct_V1 if { - # Test history setting when there's only one event - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_History_Correct_V2 if { - # Test history setting when there's multiple events and the most most recent is correct - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"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": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_History_Correct_V3 if { - # Test history setting when there's multiple OUs - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"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": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_History_Correct_V4 if { - # Test history setting when there's multiple OUs and an older event non-compliant - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2020-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"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": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_History_Correct_V5 if { - # Test history setting when set to inherit from parent - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2020-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "DELETE_APPLICATION_SETTING", - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "ORG_UNIT_NAME", "value": "Test Second-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Second-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_History_Incorrect_V1 if { - # Test history setting when there are no relevant events - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_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_History_Incorrect_V2 if { - # Test history setting when there's only one event and it's wrong - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_1("OFF")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_History_Incorrect_V3 if { - # Test history setting when there are multiple events and the most recent is wrong - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"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": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_1("OFF")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_History_Incorrect_V4 if { - # Test history setting when there is no event for the Top-level OU but there is one for a different OU - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} -#-- - -test_History_Incorrect_V5 if { - # Test history setting when the Top-level OU is compliant but a secondary OU is non-compliant - PolicyId := ChatId1_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "ChatArchivingProto chatsDefaultToOffTheRecord"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Secondary OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Secondary OU", - "Value": NonComplianceMessage1_1("OFF")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- - -# -# GWS.CHAT.1.2 -#-- -test_Change_History_Setting_Correct_V1 if { - # Test allow user to change history setting when there's only one event - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Change_History_Setting_Correct_V2 if { - # Test allow user to change history setting when there's multiple events and the most most recent is correct - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"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": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Change_History_Setting_Correct_V3 if { - # Test history setting when set to inherit from parent - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2020-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "DELETE_APPLICATION_SETTING", - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "ORG_UNIT_NAME", "value": "Test Second-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Second-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Change_History_Setting_Incorrect_V1 if { - # Test allow user to change history setting when there are no relevant events - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_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", false) -} - -test_Change_History_Setting_Incorrect_V2 if { - # Test allow user to change history setting when there's only one event and it's wrong - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_2("Yes")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Change_History_Setting_Incorrect_V3 if { - # Test allow user to change history setting when there are multiple events and the most recent is wrong - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"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": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage1_2("Yes")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- - -test_Change_History_Setting_Incorrect_V4 if { - # Test allow user to change history setting when there are multiple OU and a secondary OU is wrong - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Test Secondary OU", - "Value": NonComplianceMessage1_2("Yes")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- - -test_Change_History_Setting_Incorrect_V5 if { - # Test allow user to change history setting when the primary OU is missing but a different one is present - PolicyId := ChatId1_2 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "ChatArchivingProto allow_chat_archiving_setting_modification" - }, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Secondary OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", false) -} -#-- diff --git a/scubagoggles/Testing/RegoTests/chat/chat02_test.rego b/scubagoggles/Testing/RegoTests/chat/chat02_test.rego deleted file mode 100644 index edadfd01..00000000 --- a/scubagoggles/Testing/RegoTests/chat/chat02_test.rego +++ /dev/null @@ -1,366 +0,0 @@ -package chat - -import future.keywords -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CHAT.2.1 -#-- -test_External_File_Sharing_Correct_V1 if { - # Test users are not allowed to share files externally when there's only one event - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_External_File_Sharing_Correct_V2 if { - # Test users are not allowed to share files externally when there's multiple events - # and the most most recent is correct - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "ALLOW_ALL_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_External_File_Sharing_Correct_V3 if { - # Test OU inheriting from parent - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2020-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "ALLOW_ALL_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Second-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "name": "DELETE_APPLICATION_SETTING", - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "ORG_UNIT_NAME", "value": "Test Second-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - } - } - - PassTestResult(PolicyId, Output) -} - -test_External_File_Sharing_Incorrect_V1 if { - # Test no relevant events - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", false) -} - -test_External_File_Sharing_Incorrect_V2 if { - # Test all allowed - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "ALL_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage2_1("Allow all files")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_External_File_Sharing_Incorrect_V3 if { - # Test images allowed - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "IMAGES_ONLY"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage2_1("Images only")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_External_File_Sharing_Incorrect_V4 if { - # Test sharing allowed when there are multiple events - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "ALL_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage2_1("Allow all files")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_External_File_Sharing_Incorrect_V5 if { - # Test allowing images, multiple events - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "IMAGES_ONLY"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage2_1("Images only")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_External_File_Sharing_Incorrect_V6 if { - # Test there's one event for a secondary OU but none for the primary OU - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", false) -} - -test_External_File_Sharing_Incorrect_V7 if { - # Test there's multiple OUs - PolicyId := ChatId2_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "ALL_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - { - "name": "SETTING_NAME", - "value": "DynamiteFileSharingSettingsProto external_file_sharing_setting" - }, - {"name": "NEW_VALUE", "value": "NO_FILES"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Some other OU", - "Value": NonComplianceMessage2_1("Allow all files")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- diff --git a/scubagoggles/Testing/RegoTests/chat/chat03_test.rego b/scubagoggles/Testing/RegoTests/chat/chat03_test.rego deleted file mode 100644 index 5f3800ca..00000000 --- a/scubagoggles/Testing/RegoTests/chat/chat03_test.rego +++ /dev/null @@ -1,336 +0,0 @@ -package chat - -import future.keywords -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CHAT.3.1 -#-- -test_Space_History_Setting_Correct_V1 if { - # Test space history setting when there's only one event - use case #1 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "DEFAULT_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Space_History_Setting_Correct_V2 if { - # Test space history setting when there's only one event - use case #2 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Space_History_Setting_Correct_V3 if { - # Test space history setting when there's multiple events and the most most recent is correct - use case #1 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "DEFAULT_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "DEFAULT_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Space_History_Setting_Correct_V4 if { - # Test space history setting when there's multiple events and the most most recent is correct - use case #2 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_Space_History_Setting_Incorrect_V1 if { - # Test space history setting when there are no relevant events - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "ALWAYS_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} - -test_Space_History_Setting_Incorrect_V2 if { - # Test space history setting when there's only one event and it's wrong - use case #1 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage3_1("ALWAYS OFF")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Space_History_Setting_Incorrect_V3 if { - # Test space history setting when there's only one event and it's wrong - use case #2 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "DEFAULT_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage3_1("OFF by default")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Space_History_Setting_Incorrect_V4 if { - # Test space history setting when there are multiple events and the most recent is wrong - use case #1 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "DEFAULT_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "DEFAULT_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage3_1("OFF by default")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Space_History_Setting_Incorrect_V5 if { - # Test space history setting when there are multiple events and the most recent is wrong - use case #2 - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": NonComplianceMessage3_1("ALWAYS OFF")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_Space_History_Setting_Incorrect_V6 if { - # Test there's an event for a secondary OU but not the top-level OU - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", true) -} - -test_Space_History_Setting_Incorrect_V7 if { - # Test multiple OUs - PolicyId := ChatId3_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RoomOtrSettingsProto otr_state"}, - {"name": "NEW_VALUE", "value": "ALWAYS_OFF_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Some other OU", - "Value": NonComplianceMessage3_1("ALWAYS OFF")}, - {"Name": "Test Top-Level OU", - "Value": NonComplianceMessage3_1("ALWAYS OFF")}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- diff --git a/scubagoggles/Testing/RegoTests/chat/chat04_test.rego b/scubagoggles/Testing/RegoTests/chat/chat04_test.rego deleted file mode 100644 index e096e713..00000000 --- a/scubagoggles/Testing/RegoTests/chat/chat04_test.rego +++ /dev/null @@ -1,395 +0,0 @@ -package chat - -import future.keywords -import data.utils.FailTestNoEvent -import data.utils.FailTestOUNonCompliant -import data.utils.PassTestResult - -# -# GWS.CHAT.4.1 -#-- -test_External_Chat_Sharing_Setting_Correct_V1 if { - # Test external chat sharing setting when there's only one event - use case #1 - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "TRUSTED_DOMAINS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_External_Chat_Sharing_Setting_Correct_V2 if { - # Test external chat sharing setting when there's only one event - use case #2 - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "TRUSTED_DOMAINS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_External_Chat_Sharing_Setting_Correct_V3 if { - # Test external chat sharing setting when there's multiple events and the most most recent is correct - use case #1 - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-21T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "TRUSTED_DOMAINS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-22T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "true"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-24T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "NO_RESTRICTION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_External_Chat_Sharing_Setting_Correct_V4 if { - # Test external chat sharing setting when there's multiple events and the most most recent is correct - use case #2 - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"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": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "TRUSTED_DOMAINS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-23T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-24T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "NO_RESTRICTION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - PassTestResult(PolicyId, Output) -} - -test_External_Chat_Sharing_Setting_Incorrect_V1 if { - # Test external chat sharing setting when there are no relevant events - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "Something else"}, - {"name": "NEW_VALUE", "value": "ALWAYS_ON_THE_RECORD"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - } - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", false) -} - -test_External_Chat_Sharing_Setting_Incorrect_V2 if { - # Test external chat sharing setting when there's only one event and it's wrong - use case #1 - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"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": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "NO_RESTRICTION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "" - } - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": "External chat is enabled for all domains"}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_External_Chat_Sharing_Setting_Incorrect_V3 if { - # Test external chat sharing setting when there are multiple events and the most recent is wrong - use case #1 - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "NO_RESTRICTION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"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": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "TRUSTED_DOMAINS"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "" - }, - } - - failedOU := [{"Name": "Test Top-Level OU", - "Value": "External chat is enabled for all domains"}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} - -test_External_Chat_Sharing_Setting_Incorrect_V4 if { - # Test there's an event for a secondary OU but not the top-level OU - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "NO_RESTRICTION"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - }, - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - FailTestNoEvent(PolicyId, Output, "Test Top-Level OU", false) -} - -test_External_Chat_Sharing_Setting_Incorrect_V5 if { - # Test multiple OUs - PolicyId := ChatId4_1 - Output := tests with input as { - "chat_logs": {"items": [ - { - "id": {"time": "2022-12-21T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-21T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "NO_RESTRICTION"}, - {"name": "ORG_UNIT_NAME", "value": "Test Top-Level OU"}, - ] - }] - }, - { - "id": {"time": "2022-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto restrictChatToOrganization"}, - {"name": "NEW_VALUE", "value": "false"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - }, - { - "id": {"time": "2021-12-20T00:02:28.672Z"}, - "events": [{ - "parameters": [ - {"name": "SETTING_NAME", "value": "RestrictChatProto externalChatRestriction"}, - {"name": "NEW_VALUE", "value": "NO_RESTRICTION"}, - {"name": "ORG_UNIT_NAME", "value": "Some other OU"}, - ] - }] - }, - - ]}, - "tenant_info": { - "topLevelOU": "Test Top-Level OU" - }, - } - - failedOU := [{"Name": "Some other OU", - "Value": "External chat is enabled for all domains"}, - {"Name": "Test Top-Level OU", - "Value": "External chat is enabled for all domains"}] - FailTestOUNonCompliant(PolicyId, Output, failedOU) -} -#-- diff --git a/scubagoggles/Testing/RegoTests/chat/chat_api01_test.rego b/scubagoggles/Testing/RegoTests/chat/chat_api01_test.rego index 94a7a9f5..9602eef5 100644 --- a/scubagoggles/Testing/RegoTests/chat/chat_api01_test.rego +++ b/scubagoggles/Testing/RegoTests/chat/chat_api01_test.rego @@ -52,7 +52,7 @@ test_ChatAPI_History_Incorrect_1 if { Output := tests with input as BadChatApi01 failedOU := [{"Name": "topOU", - "Value": NonComplianceMessage1_1("OFF")}] + "Value": NonComplianceMessage1_1("disabled")}] FailTestOUNonCompliant(PolicyId, Output, failedOU) } @@ -68,6 +68,6 @@ test_ChatAPI_Change_History_Incorrect_1 if { Output := tests with input as BadChatApi01 failedOU := [{"Name": "topOU", - "Value": NonComplianceMessage1_2("Yes")}] + "Value": NonComplianceMessage1_2("are")}] FailTestOUNonCompliant(PolicyId, Output, failedOU) } diff --git a/scubagoggles/rego/Chat.rego b/scubagoggles/rego/Chat.rego index d16e2859..071bb12b 100644 --- a/scubagoggles/rego/Chat.rego +++ b/scubagoggles/rego/Chat.rego @@ -2,7 +2,6 @@ package chat import future.keywords import data.utils -import data.utils.PolicyApiInUse LogEvents := utils.GetEvents("chat_logs") @@ -18,45 +17,12 @@ ChatEnabled(orgunit) := utils.AppEnabled(input.policies, "chat", orgunit) ChatId1_1 := utils.PolicyIdWithSuffix("GWS.CHAT.1.1") -LogMessage1_1 := "ChatArchivingProto chatsDefaultToOffTheRecord" - -Check1_1_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage1_1, utils.TopLevelOU) - count(events) > 0 -} - -Check1_1_OK if {PolicyApiInUse} - -# This is a weird one - for logging, history is off if the value is -# "true" (string), but for the policy API history is off if the value -# is false (boolean). - -GetFriendlyValue1_1(Value) := "OFF" if { - Value in {false, "true"} -} else := "ON" if { - Value in {true, "false"} -} else := Value - -NonComplianceMessage1_1(value) := sprintf("Default conversation history is set to: %s", +NonComplianceMessage1_1(value) := sprintf("Default conversation history is %s", [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) - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue == "true" -} - -NonCompliantOUs1_1 contains { - "Name": OU, - "Value": NonComplianceMessage1_1(GetFriendlyValue1_1(chatHistory)) + "Value": NonComplianceMessage1_1(utils.GetFriendlyEnabledValue(chatHistory)) } if { some OU, settings in input.policies ChatEnabled(OU) @@ -67,29 +33,12 @@ NonCompliantOUs1_1 contains { tests contains { "PolicyId": ChatId1_1, "Criticality": "Shall", - "ReportDetails": utils.NoSuchEventDetails(DefaultSafe, utils.TopLevelOU), - "ActualValue": "No relevant event in the current logs", - "RequirementMet": DefaultSafe, - "NoSuchEvent": true -} -if { - not PolicyApiInUse - DefaultSafe := true - not Check1_1_OK -} - -tests contains { - "PolicyId": ChatId1_1, - "Criticality": "Shall", - # Empty list in next line for non compliant groups, as this setting can't - # be changed at the group level "ReportDetails": utils.ReportDetails(NonCompliantOUs1_1, []), "ActualValue": {"NonCompliantOUs": NonCompliantOUs1_1}, "RequirementMet": Status, "NoSuchEvent": false } if { - Check1_1_OK Status := count(NonCompliantOUs1_1) == 0 } #-- @@ -97,40 +46,18 @@ if { # # Baseline GWS.CHAT.1.2 #-- -ChatId1_2 := utils.PolicyIdWithSuffix("GWS.CHAT.1.2") - -LogMessage1_2 := "ChatArchivingProto allow_chat_archiving_setting_modification" - -Check1_2_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage1_2, utils.TopLevelOU) - count(events) > 0 -} -Check1_2_OK if {PolicyApiInUse} +ChatId1_2 := utils.PolicyIdWithSuffix("GWS.CHAT.1.2") -GetFriendlyValue1_2(Value) := "Yes" if { - Value in {true, "true"} -} else := "No" if { - Value in {false, "false"} +GetFriendlyValue1_2(Value) := "are" if { + Value == true +} else := "are not" if { + Value == false } else := Value -NonComplianceMessage1_2(value) := sprintf("Allow users to change their history setting is set to: %s", +NonComplianceMessage1_2(value) := sprintf("Users %s allowed to change their history setting", [value]) -NonCompliantOUs1_2 contains { - "Name": OU, - "Value": NonComplianceMessage1_2(GetFriendlyValue1_2(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - some OU in utils.OUsWithEvents - Events := utils.FilterEventsOU(LogEvents, LogMessage1_2, OU) - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue == "true" -} - NonCompliantOUs1_2 contains { "Name": OU, "Value": NonComplianceMessage1_2(GetFriendlyValue1_2(changeHistory)) @@ -141,20 +68,6 @@ NonCompliantOUs1_2 contains { changeHistory != false } -tests contains { - "PolicyId": ChatId1_2, - "Criticality": "Shall", - "ReportDetails": utils.NoSuchEventDetails(DefaultSafe, utils.TopLevelOU), - "ActualValue": "No relevant event in the current logs", - "RequirementMet": DefaultSafe, - "NoSuchEvent": true -} -if { - not PolicyApiInUse - DefaultSafe := false - not Check1_2_OK -} - tests contains { "PolicyId": ChatId1_2, "Criticality": "Shall", @@ -164,7 +77,6 @@ tests contains { "NoSuchEvent": false } if { - Check1_2_OK Status := count(NonCompliantOUs1_2) == 0 } #-- @@ -179,16 +91,6 @@ if { ChatId2_1 := utils.PolicyIdWithSuffix("GWS.CHAT.2.1") -LogMessage2_1 := "DynamiteFileSharingSettingsProto external_file_sharing_setting" - -Check2_1_OK if { - not PolicyApiInUse - events := utils.FilterEventsOU(LogEvents, LogMessage2_1, utils.TopLevelOU) - count(events) > 0 -} - -Check2_1_OK if {PolicyApiInUse} - GetFriendlyValue2_1(Value) := "Allow all files" if { Value == "ALL_FILES" } else := "Images only" if { @@ -200,20 +102,6 @@ GetFriendlyValue2_1(Value) := "Allow all files" if { NonComplianceMessage2_1(value) := sprintf("External file sharing is set to: %s", [value]) -NonCompliantOUs2_1 contains { - "Name": OU, - "Value": NonComplianceMessage2_1(GetFriendlyValue2_1(LastEvent.NewValue)) -} -if { - not PolicyApiInUse - some OU in utils.OUsWithEvents - Events := utils.FilterEventsOU(LogEvents, LogMessage2_1, OU) - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - LastEvent.NewValue != "NO_FILES" - LastEvent.NewValue != "DELETE_APPLICATION_SETTING" -} - NonCompliantOUs2_1 contains { "Name": OU, "Value": NonComplianceMessage2_1(GetFriendlyValue2_1(allowSharing)) @@ -224,20 +112,6 @@ NonCompliantOUs2_1 contains { allowSharing != "NO_FILES" } -tests contains { - "PolicyId": ChatId2_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 := false - not Check2_1_OK -} - tests contains { "PolicyId": ChatId2_1, "Criticality": "Shall", @@ -247,7 +121,6 @@ tests contains { "NoSuchEvent": false } if { - Check2_1_OK Status := count(NonCompliantOUs2_1) == 0 } #-- @@ -262,21 +135,11 @@ if { ChatId3_1 := utils.PolicyIdWithSuffix("GWS.CHAT.3.1") -LogMessage3_1 := "RoomOtrSettingsProto otr_state" - -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("Conversation history settings for spaces is set to: %s", [value]) GetFriendlyValue3_1(Value) := "OFF by default" if { - Value in {"DEFAULT_HISTORY_OFF", "DEFAULT_OFF_THE_RECORD"} + Value == "DEFAULT_HISTORY_OFF" } else := "ON by default" if { Value == "DEFAULT_HISTORY_ON" } else := "ALWAYS ON" if { @@ -284,21 +147,9 @@ GetFriendlyValue3_1(Value) := "OFF by default" if { } else := "Unspecified" if { Value == "HISTORY_STATE_UNSPECIFIED" } else := "ALWAYS OFF" if { - Value in {"HISTORY_ALWAYS_OFF", "ALWAYS_OFF_THE_RECORD"} + Value == "HISTORY_ALWAYS_OFF" } else := Value -NonCompliantOUs3_1 contains { - "Name": OU, - "Value": NonComplianceMessage3_1(GetFriendlyValue3_1(LastEvent.NewValue)) -} if { - not PolicyApiInUse - some OU in utils.OUsWithEvents - Events := utils.FilterEventsOU(LogEvents, LogMessage3_1, OU) - count(Events) > 0 - LastEvent := utils.GetLastEvent(Events) - not contains("DEFAULT_ON_THE_RECORD ALWAYS_ON_THE_RECORD", LastEvent.NewValue) -} - NonCompliantOUs3_1 contains { "Name": OU, "Value": NonComplianceMessage3_1(GetFriendlyValue3_1(spaceHistory)) @@ -309,20 +160,6 @@ NonCompliantOUs3_1 contains { not spaceHistory in ["DEFAULT_HISTORY_ON", "HISTORY_ALWAYS_ON"] } -tests contains { - "PolicyId": ChatId3_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": ChatId3_1, "Criticality": "Should", @@ -332,7 +169,6 @@ tests contains { "NoSuchEvent": false } if { - Check3_1_OK Status := count(NonCompliantOUs3_1) == 0 } #-- @@ -347,29 +183,6 @@ if { ChatId4_1 := utils.PolicyIdWithSuffix("GWS.CHAT.4.1") -LogMessage4_1 := "RestrictChatProto restrictChatToOrganization" - -default NoSuchEvent4_1(_) := false - -NoSuchEvent4_1(TopLevelOU) := true if { - Events := utils.FilterEventsOU(LogEvents, LogMessage4_1, TopLevelOU) - count(Events) == 0 -} - -NoSuchEvent4_1(TopLevelOU) := true if { - Events := utils.FilterEventsOU(LogEvents, - "RestrictChatProto externalChatRestriction", - TopLevelOU) - count(Events) == 0 -} - -Check4_1_OK if { - not PolicyApiInUse - not NoSuchEvent4_1(utils.TopLevelOU) -} - -Check4_1_OK if {PolicyApiInUse} - GetFriendlyValue4_1(Value) := "all domains" if { Value == "NO_RESTRICTION" } else := "Unspecified" if { @@ -379,27 +192,6 @@ GetFriendlyValue4_1(Value) := "all domains" if { NonComplianceMessage4_1(value) := sprintf("Allow external chat within: %s", [value]) -NonCompliantOUs4_1 contains { - "Name": OU, - "Value": "External chat is enabled for all domains" -} - if { - not PolicyApiInUse - some OU in utils.OUsWithEvents - Events_A := utils.FilterEventsOU(LogEvents, LogMessage4_1, OU) - count(Events_A) > 0 - LastEvent_A := utils.GetLastEvent(Events_A) - LastEvent_A.NewValue != "DELETE_APPLICATION_SETTING" - - Events_B := utils.FilterEventsOU(LogEvents, "RestrictChatProto externalChatRestriction", OU) - count(Events_B) > 0 - LastEvent_B := utils.GetLastEvent(Events_B) - LastEvent_B.NewValue != "DELETE_APPLICATION_SETTING" - - LastEvent_A.NewValue == "false" - LastEvent_B.NewValue != "TRUSTED_DOMAINS" -} - NonCompliantOUs4_1 contains { "Name": OU, "Value": NonComplianceMessage4_1(GetFriendlyValue4_1(externalRestrict)) @@ -412,20 +204,6 @@ NonCompliantOUs4_1 contains { externalRestrict != "TRUSTED_DOMAINS" } -tests contains { - "PolicyId": ChatId4_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 := false - not Check4_1_OK -} - tests contains { "PolicyId": ChatId4_1, "Criticality": "Shall", @@ -435,7 +213,6 @@ tests contains { "NoSuchEvent": false } if { - Check4_1_OK Status := count(NonCompliantOUs4_1) == 0 } #--