diff --git a/tests/Backup/Intune/test_backup_apns.py b/tests/Backup/Intune/test_backup_apns.py index e2706476..4bae8adf 100644 --- a/tests/Backup/Intune/test_backup_apns.py +++ b/tests/Backup/Intune/test_backup_apns.py @@ -44,15 +44,41 @@ def setUp(self): "certificateSerialNumber": "11000000000000", "certificate": None, } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.makeapirequest_patch = patch( "src.IntuneCD.backup.Intune.backup_apns.makeapirequest" ) self.makeapirequest = self.makeapirequest_patch.start() + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_apns.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_apns.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() + def tearDown(self): self.directory.cleanup() self.makeapirequest_patch.stop() + self.makeAuditRequest_patch.stop() + self.process_audit_data_patch.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -88,6 +114,19 @@ def test_backup_with_no_return_data(self): self.count = savebackup(self.directory.path, "json", False, self.token) self.assertEqual(0, self.count["config_count"]) + def test_backup_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + + self.makeapirequest.return_value = self.apns + self.count = savebackup(self.directory.path, "json", True, self.token) + + with open(self.saved_path + "json", "r", encoding="utf-8") as f: + saved_data = json.load(f) + + self.assertTrue(Path(f"{self.directory.path}/Apple Push Notification").exists()) + self.assertEqual(self.expected_data, saved_data) + self.assertEqual(1, self.count["config_count"]) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_appConfiguration.py b/tests/Backup/Intune/test_backup_appConfiguration.py index 768d03b8..8d5abac3 100644 --- a/tests/Backup/Intune/test_backup_appConfiguration.py +++ b/tests/Backup/Intune/test_backup_appConfiguration.py @@ -33,6 +33,7 @@ def setUp(self): "@odata.type": "#microsoft.graph.iosMobileAppConfiguration", "assignments": [{"target": {"groupName": "Group1"}}], "displayName": "test", + "scopeTagIds": ["0"], "settings": [ { "appConfigKey": "sharedDevice", @@ -54,6 +55,7 @@ def setUp(self): "id": "0", "targetedMobileApps": ["0"], "displayName": "test", + "scopeTagIds": ["0"], "settings": [ { "appConfigKey": "sharedDevice", @@ -74,6 +76,19 @@ def setUp(self): "applicableDeviceType": {"iPhoneAndIPod": True}, "revokeLicenseActionResults": [], } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.batch_assignment_patch = patch( "src.IntuneCD.backup.Intune.backup_appConfiguration.batch_assignment" @@ -93,11 +108,18 @@ def setUp(self): self.makeapirequest = self.makeapirequest_patch.start() self.makeapirequest.side_effect = self.app_config, self.app_data + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_appConfiguration.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + def tearDown(self): self.directory.cleanup() self.batch_assignment.stop() self.object_assignment.stop() self.makeapirequest.stop() + self.makeAuditRequest.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -110,6 +132,7 @@ def test_backup_yml(self): "", self.append_id, False, + [{"id": 0, "displayName": "default"}], ) with open(self.saved_path + "yaml", "r", encoding="utf-8") as f: @@ -131,6 +154,7 @@ def test_backup_json(self): "", self.append_id, False, + None, ) with open(self.saved_path + "json", "r", encoding="utf-8") as f: @@ -151,6 +175,7 @@ def test_backup_with_no_returned_data(self): "", self.append_id, False, + None, ) self.assertEqual(0, self.count["config_count"]) @@ -165,6 +190,7 @@ def test_backup_with_prefix(self): "test1", self.append_id, False, + None, ) self.assertEqual(0, self.count["config_count"]) @@ -173,7 +199,7 @@ def test_backup_append_id(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" self.count = savebackup( - self.directory.path, "yaml", self.exclude, self.token, "", True, False + self.directory.path, "yaml", self.exclude, self.token, "", True, False, None ) self.assertTrue( @@ -182,6 +208,27 @@ def test_backup_append_id(self): ).exists() ) + def test_backup_scope_tag_and_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + self.count = savebackup( + self.directory.path, + "yaml", + self.exclude, + self.token, + "", + self.append_id, + True, + [{"id": 0, "displayName": "default"}], + ) + + with open(self.saved_path + "yaml", "r", encoding="utf-8") as f: + data = json.dumps(yaml.safe_load(f)) + saved_data = json.loads(data) + + self.assertTrue(Path(f"{self.directory.path}/App Configuration").exists()) + self.assertEqual(self.expected_data, saved_data) + self.assertEqual(1, self.count["config_count"]) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_appleEnrollmentProfile.py b/tests/Backup/Intune/test_backup_appleEnrollmentProfile.py index 17efeea3..0c524350 100644 --- a/tests/Backup/Intune/test_backup_appleEnrollmentProfile.py +++ b/tests/Backup/Intune/test_backup_appleEnrollmentProfile.py @@ -62,6 +62,19 @@ def setUp(self): ] } ] + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.patch_makeapirequest = patch( "src.IntuneCD.backup.Intune.backup_appleEnrollmentProfile.makeapirequest" @@ -73,10 +86,23 @@ def setUp(self): ) self.batch_request = self.patch_batch_request.start() + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_appleEnrollmentProfile.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_appleEnrollmentProfile.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() + def tearDown(self): self.directory.cleanup() self.patch_batch_request.stop() self.patch_makeapirequest.stop() + self.makeAuditRequest_patch.stop() + self.process_audit_data_patch.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -149,6 +175,19 @@ def test_backup_append_id(self): ).exists() ) + def test_backup_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + self.makeapirequest.return_value = self.token_response + self.batch_request.return_value = self.batch_intune + + self.count = savebackup(self.directory.path, "json", self.token, "", True, True) + + self.assertTrue( + Path( + f"{self.directory.path}/Enrollment Profiles/Apple/test__0.json" + ).exists() + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_compliancePartner.py b/tests/Backup/Intune/test_backup_compliancePartner.py index 16a487ed..b7f98f70 100644 --- a/tests/Backup/Intune/test_backup_compliancePartner.py +++ b/tests/Backup/Intune/test_backup_compliancePartner.py @@ -55,6 +55,19 @@ def setUp(self): } ] } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.patch_makeapirequest = patch( "src.IntuneCD.backup.Intune.backup_compliancePartner.makeapirequest", @@ -62,9 +75,22 @@ def setUp(self): ) self.makeapirequest = self.patch_makeapirequest.start() + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_compliancePartner.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_compliancePartner.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() + def tearDown(self): self.directory.cleanup() self.makeapirequest.stop() + self.makeAuditRequest_patch.stop() + self.process_audit_data_patch.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -135,6 +161,19 @@ def test_backup_exclude_lastHeartbeatDateTime(self): self.assertNotIn("lastHeartbeatDateTime", saved_data) + def test_backup_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + + self.count = savebackup( + self.directory.path, "json", self.exclude, self.token, True, True + ) + + self.assertTrue( + Path( + f"{self.directory.path}/Partner Connections/Compliance/test__0.json" + ).exists() + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_deviceManagementSettings.py b/tests/Backup/Intune/test_backup_deviceManagementSettings.py index 7086fdfb..93e2e0d1 100644 --- a/tests/Backup/Intune/test_backup_deviceManagementSettings.py +++ b/tests/Backup/Intune/test_backup_deviceManagementSettings.py @@ -58,9 +58,35 @@ def setUp(self): "enableEnhancedTroubleshootingExperience": False, "enableDeviceGroupMembershipReport": False, } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } + + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_deviceManagementSettings.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_deviceManagementSettings.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() def tearDown(self): self.directory.cleanup() + self.makeAuditRequest_patch.stop() + self.process_audit_data_patch.stop() def test_backup_yml(self, _, __): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -91,6 +117,20 @@ def test_backup_json(self, _, __): self.assertEqual(self.expected_data, self.saved_data) self.assertEqual(1, self.count["config_count"]) + def test_backup_audit(self, _, __): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + + self.count = savebackup(self.directory.path, "json", True, self.token) + + with open(self.saved_path + "json", "r", encoding="utf-8") as f: + self.saved_data = json.load(f) + + self.assertTrue( + Path(f"{self.directory.path}/Device Management Settings").exists() + ) + self.assertEqual(self.expected_data, self.saved_data) + self.assertEqual(1, self.count["config_count"]) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_managedGPlay.py b/tests/Backup/Intune/test_backup_managedGPlay.py index 9223fcb1..cfdc5ba8 100644 --- a/tests/Backup/Intune/test_backup_managedGPlay.py +++ b/tests/Backup/Intune/test_backup_managedGPlay.py @@ -39,6 +39,19 @@ def setUp(self): "lastAppSyncStatus": "success", "ownerUserPrincipalName": "awesome@gmail.com", } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.patch_makeapirequest = patch( "src.IntuneCD.backup.Intune.backup_managedGPlay.makeapirequest", @@ -46,9 +59,22 @@ def setUp(self): ) self.makeapirequest = self.patch_makeapirequest.start() + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_managedGPlay.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_managedGPlay.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() + def tearDown(self): self.directory.cleanup() self.makeapirequest.stop() + self.makeAuditRequest_patch.stop() + self.process_audit_data_patch.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -114,6 +140,19 @@ def test_backup_exclude_lastAppSyncDateTime(self): self.assertNotIn("lastAppSyncDateTime", saved_data) + def test_backup_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + + self.count = savebackup( + self.directory.path, "json", self.exclude, self.token, True, True + ) + + self.assertTrue( + Path( + f"{self.directory.path}/Managed Google Play/awesome@gmail.com__0.json" + ).exists() + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_managementPartner.py b/tests/Backup/Intune/test_backup_managementPartner.py index d4a537ff..62b59fbc 100644 --- a/tests/Backup/Intune/test_backup_managementPartner.py +++ b/tests/Backup/Intune/test_backup_managementPartner.py @@ -38,6 +38,19 @@ def setUp(self): } ] } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.patch_makeapirequest = patch( "src.IntuneCD.backup.Intune.backup_managementPartner.makeapirequest", @@ -45,9 +58,22 @@ def setUp(self): ) self.makeapirequest = self.patch_makeapirequest.start() + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_managementPartner.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_managementPartner.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() + def tearDown(self): self.directory.cleanup() self.makeapirequest.stop() + self.makeAuditRequest_patch.stop() + self.process_audit_data_patch.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -102,6 +128,17 @@ def test_backup_append_id(self): ).exists() ) + def test_backup_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + + self.count = savebackup(self.directory.path, "json", self.token, True, True) + + self.assertTrue( + Path( + f"{self.directory.path}/Partner Connections/Management/test__0.json" + ).exists() + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_remoteAssistancePartner.py b/tests/Backup/Intune/test_backup_remoteAssistancePartner.py index cca81796..2a92c45a 100644 --- a/tests/Backup/Intune/test_backup_remoteAssistancePartner.py +++ b/tests/Backup/Intune/test_backup_remoteAssistancePartner.py @@ -31,6 +31,19 @@ def setUp(self): {"id": "0", "onboardingStatus": "onboarded", "displayName": "test"} ] } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.patch_makeapirequest = patch( "src.IntuneCD.backup.Intune.backup_remoteAssistancePartner.makeapirequest", @@ -38,9 +51,22 @@ def setUp(self): ) self.makeapirequest = self.patch_makeapirequest.start() + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_remoteAssistancePartner.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_remoteAssistancePartner.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() + def tearDown(self): self.directory.cleanup() self.makeapirequest.stop() + self.makeAuditRequest_patch.stop() + self.process_audit_data_patch.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -110,6 +136,17 @@ def test_backup_append_id(self): ).exists() ) + def test_backup_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + + self.count = savebackup(self.directory.path, "json", self.token, True, True) + + self.assertTrue( + Path( + f"{self.directory.path}/Partner Connections/Remote Assistance/test__0.json" + ).exists() + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/Backup/Intune/test_backup_scopeTags.py b/tests/Backup/Intune/test_backup_scopeTags.py index 846e398f..5d1433f7 100644 --- a/tests/Backup/Intune/test_backup_scopeTags.py +++ b/tests/Backup/Intune/test_backup_scopeTags.py @@ -44,6 +44,19 @@ def setUp(self): } ], } + self.audit_data = { + "value": [ + { + "resources": [ + {"resourceId": "0", "auditResourceType": "MagicResource"} + ], + "activityDateTime": "2021-01-01T00:00:00Z", + "activityOperationType": "Patch", + "activityResult": "Success", + "actor": [{"auditActorType": "ItPro"}], + } + ] + } self.batch_assignment_patch = patch( "src.IntuneCD.backup.Intune.backup_scopeTags.batch_assignment" @@ -63,11 +76,24 @@ def setUp(self): self.makeapirequest = self.makeapirequest_patch.start() self.makeapirequest.return_value = self.scope_tag + self.makeAuditRequest_patch = patch( + "src.IntuneCD.backup.Intune.backup_scopeTags.makeAuditRequest" + ) + self.makeAuditRequest = self.makeAuditRequest_patch.start() + self.makeAuditRequest.return_value = self.audit_data + + self.process_audit_data_patch = patch( + "src.IntuneCD.backup.Intune.backup_scopeTags.process_audit_data" + ) + self.process_audit_data = self.process_audit_data_patch.start() + def tearDown(self): self.directory.cleanup() self.batch_assignment.stop() self.object_assignment.stop() self.makeapirequest.stop() + self.makeAuditRequest.stop() + self.process_audit_data.stop() def test_backup_yml(self): """The folder should be created, the file should have the expected contents, and the count should be 1.""" @@ -116,6 +142,15 @@ def test_backup_append_id(self): self.assertTrue(Path(f"{self.directory.path}/Scope Tags/test__1.json").exists()) + def test_backup_audit(self): + """The folder should be created, the file should have the expected contents, and the count should be 1.""" + + self.count = savebackup( + self.directory.path, "json", self.exclude, self.token, True, True + ) + + self.assertTrue(Path(f"{self.directory.path}/Scope Tags/test__1.json").exists()) + if __name__ == "__main__": unittest.main() diff --git a/tests/Update/Intune/test_update_appConfiguration.py b/tests/Update/Intune/test_update_appConfiguration.py index bcd39f15..afdb35a9 100644 --- a/tests/Update/Intune/test_update_appConfiguration.py +++ b/tests/Update/Intune/test_update_appConfiguration.py @@ -188,6 +188,21 @@ def test_remove_config(self): self.assertEqual(self.makeapirequestDelete.call_count, 1) + def test_update_scope_tags(self): + """The count should be 1 and the post_assignment_update and makeapirequestPatch should be called.""" + + self.count = update( + self.directory.path, + self.token, + assignment=True, + remove=False, + scope_tags=["test"], + ) + + self.assertEqual(self.count[0].count, 1) + self.assertEqual(self.makeapirequestPatch.call_count, 1) + self.assertEqual(self.post_assignment_update.call_count, 1) + if __name__ == "__main__": unittest.main() diff --git a/tests/Update/Intune/test_update_appProtection.py b/tests/Update/Intune/test_update_appProtection.py index df55f16e..0b41cf45 100644 --- a/tests/Update/Intune/test_update_appProtection.py +++ b/tests/Update/Intune/test_update_appProtection.py @@ -466,6 +466,21 @@ def test_remove_config(self): self.assertEqual(self.makeapirequestDelete.call_count, 1) + def test_update_scope_tags(self): + """The count should be 1 and the post_assignment_update and makeapirequestPatch should be called.""" + + self.count = update( + self.directory.path, + self.token, + assignment=True, + remove=False, + scope_tags=["test"], + ) + + self.assertEqual(self.count[0].count, 1) + self.assertEqual(self.makeapirequestPatch.call_count, 1) + self.assertEqual(self.post_assignment_update.call_count, 1) + if __name__ == "__main__": unittest.main() diff --git a/tests/Update/Intune/test_update_assignmentFilter.py b/tests/Update/Intune/test_update_assignmentFilter.py index f1c5a777..ab4a0c87 100644 --- a/tests/Update/Intune/test_update_assignmentFilter.py +++ b/tests/Update/Intune/test_update_assignmentFilter.py @@ -67,7 +67,9 @@ def tearDown(self): def test_update_with_diffs(self): """The count should be 1 and makeapirequestPatch should be called.""" - self.count = update(self.directory.path, self.token, report=False) + self.count = update( + self.directory.path, self.token, report=False, scope_tags=[] + ) self.assertEqual(self.count[0].count, 1) self.assertEqual(self.makeapirequestPatch.call_count, 1) @@ -80,7 +82,9 @@ def test_update_with_multiple_diffs(self): self.mem_data["value"][0]["testvalue"] = "test" self.mem_data["value"][0]["testvalue2"] = "test1" - self.count = update(self.directory.path, self.token, report=False) + self.count = update( + self.directory.path, self.token, report=False, scope_tags=[] + ) self.assertEqual(self.count[0].count, 2) self.assertEqual(self.makeapirequestPatch.call_count, 1) @@ -90,7 +94,9 @@ def test_update_with_no_diffs(self): """The count should be 0 and makeapirequestPatch should not be called.""" self.mem_data["value"][0]["testvalue"] = "test1" - self.count = update(self.directory.path, self.token, report=False) + self.count = update( + self.directory.path, self.token, report=False, scope_tags=[] + ) self.assertEqual(self.count[0].count, 0) self.assertEqual(self.makeapirequestPatch.call_count, 0) @@ -100,11 +106,26 @@ def test_update_config_not_found(self): """The count should be 0 and makeapirequestPost should be called.""" self.mem_data["value"][0]["displayName"] = "test1" - self.count = update(self.directory.path, self.token, report=False) + self.count = update( + self.directory.path, self.token, report=False, scope_tags=[] + ) self.assertEqual(self.count, []) self.assertEqual(self.makeapirequestPost.call_count, 1) + def test_update_scope_tags(self): + """The count should be 1 and the post_assignment_update and makeapirequestPatch should be called.""" + + self.count = update( + self.directory.path, + self.token, + report=False, + scope_tags=["test"], + ) + + self.assertEqual(self.count[0].count, 1) + self.assertEqual(self.makeapirequestPatch.call_count, 1) + if __name__ == "__main__": unittest.main() diff --git a/tests/Update/Intune/test_update_configurationPolicies.py b/tests/Update/Intune/test_update_configurationPolicies.py index 59fa29c3..3376d563 100644 --- a/tests/Update/Intune/test_update_configurationPolicies.py +++ b/tests/Update/Intune/test_update_configurationPolicies.py @@ -200,6 +200,19 @@ def test_remove_config(self): self.assertEqual(self.makeapirequestDelete.call_count, 1) + def test_update_scope_tags(self): + """The count should be 1 and the post_assignment_update and makeapirequestPatch should be called.""" + + self.count = update( + self.directory.path, + self.token, + remove=False, + scope_tags=["test"], + ) + + self.assertEqual(self.count[0].count, 1) + self.assertEqual(self.makeapirequestPatch.call_count, 1) + if __name__ == "__main__": unittest.main() diff --git a/tests/Update/Intune/test_update_enrollmentConfigurations.py b/tests/Update/Intune/test_update_enrollmentConfigurations.py index ce98e59d..5726474a 100644 --- a/tests/Update/Intune/test_update_enrollmentConfigurations.py +++ b/tests/Update/Intune/test_update_enrollmentConfigurations.py @@ -226,6 +226,21 @@ def test_remove_config(self): self.assertEqual(self.makeapirequestDelete.call_count, 1) + def test_update_scope_tags(self): + """The count should be 1 and the post_assignment_update and makeapirequestPatch should be called.""" + + self.count = update( + self.directory.path, + self.token, + assignment=True, + remove=False, + scope_tags=["test"], + ) + + self.assertEqual(self.count[0].count, 1) + self.assertEqual(self.makeapirequestPatch.call_count, 1) + self.assertEqual(self.post_assignment_update.call_count, 1) + if __name__ == "__main__": unittest.main() diff --git a/tests/Update/Intune/test_update_groupPolicyConfiguration.py b/tests/Update/Intune/test_update_groupPolicyConfiguration.py index 5a2a651f..3bd8819e 100644 --- a/tests/Update/Intune/test_update_groupPolicyConfiguration.py +++ b/tests/Update/Intune/test_update_groupPolicyConfiguration.py @@ -441,6 +441,21 @@ def test_remove_config(self): self.assertEqual(self.makeapirequestDelete.call_count, 1) + def test_update_scope_tags(self): + """The count should be 1 and the post_assignment_update and makeapirequestPatch should be called.""" + + self.count = update( + self.directory.path, + self.token, + assignment=True, + remove=False, + scope_tags=[{"displayName": "test"}], + ) + + self.assertEqual(self.count[0].count, 3) + self.assertEqual(self.makeapirequestPatch.call_count, 1) + self.assertEqual(self.post_assignment_update.call_count, 1) + if __name__ == "__main__": unittest.main()