def test_search_unified_mapper( self, create_audit_with_control_and_update_control, dynamic_object, selenium, version_of_ctrl, is_found, map_status): """Check Unified Mapper modal that Unified Mapper search not looking for snapshots for audit and search for Issues/Assessments. For audit check of snapshotable control showing control that is already mapped to audit. For Issues/Assessments origin of snapshotable control is not presented. Test parameters: "Snapshoted version is not found for audit" "Snapshoted version is found for issue" "Snapshoted version is found for assessment" "Actual snapshotable control is found and already mapped to audit" "Actual snapshotable control is not found for issue" "Actual snapshotable control is not found for asmt" """ audit_with_one_control = create_audit_with_control_and_update_control source_obj = dynamic_object[0] # due to 'actual_control.custom_attributes = {None: None}' expected_control = ( audit_with_one_control[version_of_ctrl][0].repr_ui().update_attrs( custom_attributes={None: None})) expected_map_status = MappingStatusAttrs(expected_control.title, *map_status) controls_service = webui_service.ControlsService(selenium) actual_controls, actual_map_status = ( controls_service.get_list_objs_from_mapper( src_obj=source_obj, dest_objs=[expected_control])) assert (is_found is (expected_control in actual_controls) is (expected_map_status in actual_map_status))
def test_search_unified_mapper( self, create_audit_with_control_and_update_control, dynamic_object, selenium, version_of_ctrl, is_found, map_status): """Check Unified Mapper modal that Unified Mapper search not looking for snapshots for audit and search for Issues/Assessments. For audit check of snapshotable control showing control that is already mapped to audit. For Issues/Assessments origin of snapshotable control is not presented. Test parameters: "Snapshoted version is not found for audit" "Snapshoted version is found for issue" "Snapshoted version is found for assessment" "Actual snapshotable control is found and already mapped to audit" "Actual snapshotable control is not found for issue" "Actual snapshotable control is not found for asmt" """ audit_with_one_control = create_audit_with_control_and_update_control source_obj = dynamic_object expected_control = audit_with_one_control[version_of_ctrl][0].repr_ui() expected_map_status = MappingStatusAttrs(expected_control.title, *map_status) actual_controls, actual_map_status = ( webui_service.ControlsService(selenium).get_list_objs_from_mapper( src_obj=source_obj, dest_objs=[expected_control])) # 'actual_controls': created_at, updated_at, custom_attributes (None) expected_controls, actual_controls = entity.Entity.extract_objs( [expected_control], actual_controls, *Representation.tree_view_attrs_to_exclude) expected_control = expected_controls[0] assert (is_found is (expected_control in actual_controls) is (expected_map_status in actual_map_status)), ( messages.AssertionMessages.format_err_msg_contains( expected_control, actual_controls))
def test_search_unified_mapper_and_check_mapping( self, create_audit_with_control_and_update_control, control_for_mapper, control_for_tree_view, dynamic_objects, dynamic_relationships, expected_map_statuses, expected_is_found, selenium): """Check searching of shapshotable and snapshoted objects via Unified Mapper modal and check their correct mapping. """ audit_with_one_control = create_audit_with_control_and_update_control source_obj = dynamic_objects expected_control_from_mapper = ( audit_with_one_control[control_for_mapper][0].repr_ui()) expected_control_from_tree_view = ( (expected_control_from_mapper if control_for_mapper == control_for_tree_view else audit_with_one_control[control_for_tree_view][0].repr_ui()) if control_for_tree_view else None) expected_map_status = MappingStatusAttrs( expected_control_from_mapper.title, *expected_map_statuses) controls_ui_service = webui_service.ControlsService(driver=selenium) actual_controls_from_mapper, actual_map_status = ( controls_ui_service.get_list_objs_from_mapper( src_obj=source_obj, dest_objs=[expected_control_from_mapper])) actual_controls_from_tree_view = ( controls_ui_service.get_list_objs_from_tree_view( src_obj=source_obj)) # 'actual_controls': created_at, updated_at, custom_attributes (None) expected_controls_from_mapper, actual_controls_from_mapper = ( entity.Entity.extract_objs( [expected_control_from_mapper], actual_controls_from_mapper, *Representation.tree_view_attrs_to_exclude)) expected_controls_from_tree_view = [] if expected_control_from_tree_view: expected_controls_from_tree_view, actual_controls_from_tree_view = ( entity.Entity.extract_objs( [expected_control_from_tree_view], actual_controls_from_tree_view, *Representation.tree_view_attrs_to_exclude)) assert (expected_is_found is (expected_controls_from_mapper[0] in actual_controls_from_mapper) is (expected_map_status in actual_map_status)) == ( (expected_controls_from_tree_view[0] in actual_controls_from_tree_view) if expected_control_from_tree_view else expected_controls_from_tree_view == actual_controls_from_tree_view), ( messages.AssertionMessages.format_err_msg_equal( messages.AssertionMessages.format_err_msg_contains( expected_controls_from_mapper[0], actual_controls_from_mapper), messages.AssertionMessages.format_err_msg_contains( expected_controls_from_tree_view[0], actual_controls_from_tree_view) if expected_control_from_tree_view else messages.AssertionMessages.format_err_msg_equal( expected_controls_from_tree_view, actual_controls_from_tree_view)))
def get_mapping_statuses(self): """Get list of mapping statuses by given titles""" selenium_utils.get_when_all_visible(self._driver, self.locator_titles) objs_titles = self._driver.find_elements(*self.locator_titles) objs_checkboxes = self._driver.find_elements(*self.locator_checkboxes) objs = [ MappingStatusAttrs(obj[0], obj[1][0], obj[1][1]) for obj in zip( [obj.text for obj in objs_titles], [[obj.is_selected(), not obj.is_enabled()] for obj in objs_checkboxes])] return objs
def get_mapping_statuses(self): """Get list of mapping statuses by given titles""" selenium_utils.get_when_all_visible(self._driver, self.locator_titles) objs_titles = self._driver.find_elements(*self.locator_titles) objs_checkboxes = self._driver.find_elements(*self.locator_checkboxes) objs = [ MappingStatusAttrs(obj[0], obj[1][0], obj[1][1]) for obj in zip( [obj.text for obj in objs_titles], [[string_utils.get_bool_from_string(obj.get_attribute("checked")), string_utils.get_bool_from_string(obj.get_attribute("disabled"))] for obj in objs_checkboxes])] return objs
def test_search_unified_mapper(self, create_audit_and_update_original_control, selenium, version_of_ctrl, is_found): """Check on Audit's Unified Mapper modal that Unified Mapper search not looking for snapshots. Search by actual state of snapshotable control showing control that is already mapped to audit. """ audit = create_audit_and_update_original_control["audit"] expected_ctrl = create_audit_and_update_original_control[ version_of_ctrl] expected_map_status = MappingStatusAttrs(expected_ctrl.title, True, True) ctrl_service = webui_service.ControlsService(selenium) actual_ctrls, actual_map_status = ctrl_service.get_list_objs_from_mapper( src_obj=audit, dest_objs=[expected_ctrl]) assert (((expected_ctrl in actual_ctrls) and (expected_map_status in actual_map_status)) is is_found)