Beispiel #1
0
 def test_dashboard_gca(self, new_control_rest, selenium):
   # pylint: disable=anomalous-backslash-in-string
   """Check Dashboard Tab is exist if 'Dashboard' GCA filled
   with right value. Possible values match to regexp r"^https?://[^\s]+$".
   Steps:
     - Create 'Dashboard' gcas for object.
     - Fill with values
     - Check if 'Dashboard' tab exist.
     - Navigate to 'Dashboard' tab.
     - Check only GCAs filled with right values displayed on the tab.
   """
   urls = ["https://gmail.by/", "https://www.google.com/",
           environment.app_url, StringMethods.random_string(),
           "ftp://something.com/"]
   cads_rest_service = rest_service.CustomAttributeDefinitionsService()
   gca_defs = (cads_rest_service.create_dashboard_gcas(
       new_control_rest.type, count=len(urls)))
   control_rest_service = rest_service.ControlsService()
   control_rest_service.update_obj(
       obj=new_control_rest, custom_attributes=dict(
           zip([gca_def.id for gca_def in gca_defs], urls)))
   expected_dashboards_items = dict(zip(
       [gca_def.title.replace(aliases.DASHBOARD + "_", "")
        for gca_def in gca_defs], urls[:3]))
   controls_ui_service = webui_service.ControlsService(selenium)
   is_dashboard_tab_exist = (
       controls_ui_service.is_dashboard_tab_exist(new_control_rest))
   assert is_dashboard_tab_exist
   actual_dashboards_items = (
       controls_ui_service.get_items_from_dashboard_widget(new_control_rest))
   assert expected_dashboards_items == actual_dashboards_items
   cads_rest_service.delete_objs(gca_defs)
Beispiel #2
0
def create_audit_with_control_with_cas_and_delete_cas_for_controls(
    program, gcads_for_control, control_mapped_to_program, audit
):
  """Create Program and Control, map Control to Program, create Audit
  under Program, delete Control via REST API and return dictionary of executed
  fixtures.
  """
  for gca in gcads_for_control:
    rest_service.CustomAttributeDefinitionsService().delete_objs(gca)
  return {"program": program,
          "control": copy.deepcopy(control_mapped_to_program),
          "audit": audit,
          "updated_control": rest_facade.get_obj(control_mapped_to_program)}
Beispiel #3
0
def cas_dashboards(obj, *urls):
    """Creates 'Dashboard' CAs for obj and fill them with provided urls.
  Returns: dict with dashboard tab items names as a keys and urls as a values.
  """
    cads_rest_service = rest_service.CustomAttributeDefinitionsService()
    gca_defs = cads_rest_service.create_dashboard_gcas(obj.type,
                                                       count=len(urls))
    factory.get_cls_rest_service(objects.get_plural(obj.type))().update_obj(
        obj=obj,
        custom_attributes=dict(zip([gca_def.id for gca_def in gca_defs],
                                   urls)))
    valid_dashboard_url_pattern = re.compile(r"^https?://[^\s]+$")
    valid_urls = [i for i in urls if re.match(valid_dashboard_url_pattern, i)]
    return dict(
        zip([
            gca_def.title.replace(value_aliases.DASHBOARD + "_", "")
            for gca_def in gca_defs
        ], valid_urls))
Beispiel #4
0
def create_gcad(**attrs):
    """Creates global CADs for all types."""
    return rest_service.CustomAttributeDefinitionsService(
        is_external=True if (objects.get_plural(attrs["definition_type"]) in
                             objects.DISABLED_OBJECTS) else False).create_obj(
                                 factory_params=attrs)
Beispiel #5
0
def create_gcad(**attrs):
    """Creates global CADs for all types."""
    return rest_service.CustomAttributeDefinitionsService().create_obj(
        factory_params=attrs)