Exemplo n.º 1
0
def _create_mapped_asmt(audit, assessment_type, objs_to_map):
  """Create assessment with assessment type=`assessment_type` and
  map it to snapshots of `objs_to_map`"""
  assessment = rest_facade.create_asmt(audit, assessment_type=assessment_type)
  for obj in objs_to_map:
    rest_facade.map_to_snapshot(assessment, obj=obj, parent_obj=audit)
  assessment.update_attrs(mapped_objects=objs_to_map)
  # wait for indexing task to be completed.
  rest_facade.get_obj(assessment)
  return assessment
Exemplo n.º 2
0
 def test_fill_asmt_gcas_in_popup(
     self, program, gcads_for_asmt, obj, obj_role, selenium
 ):
   """Test for checking population of GCA from UI Edit popup.
   Preconditions:
   - Program created via REST API.
   - Audit created via REST API.
   - Global Custom Attributes for Assessment created via REST API.
   - Assessment created via REST API.
   """
   user = rest_facade.create_user_with_role(roles.CREATOR)
   obj_args = {obj_role: [user]}
   audit = rest_facade.create_audit(
       program, **obj_args if obj == "audit" else {})
   asmt = rest_facade.create_asmt(
       audit, **obj_args if obj == "assessment" else {})
   users.set_current_user(user)
   custom_attributes = CustomAttributeDefinitionsFactory(
   ).generate_custom_attributes(gcads_for_asmt)
   asmts_ui_service = webui_service.AssessmentsService(selenium)
   asmts_ui_service.fill_obj_gcas_in_popup(asmt, custom_attributes)
   act_asmt = rest_facade.get_obj(asmt)
   asmt.update_attrs(
       updated_at=act_asmt.updated_at, status=act_asmt.status,
       custom_attributes=custom_attributes)
   _assert_asmt(asmts_ui_service, asmt)
Exemplo n.º 3
0
 def test_add_evidence_url(
     self, program, login_role, obj, obj_role, selenium
 ):
   """Test that various users have possibility to add an evidence url into
   assessment.
   """
   # pylint: disable=too-many-arguments
   login_user = rest_facade.create_user_with_role(login_role)
   obj_args = {obj_role: [login_user]}
   audit = rest_facade.create_audit(
       program, **obj_args if obj == "audit" else {})
   asmt = rest_facade.create_asmt(
       audit, **obj_args if obj == "assessment" else {})
   users.set_current_user(login_user)
   url = string_utils.StringMethods.random_string()
   asmt_service = webui_service.AssessmentsService(selenium)
   asmt_service.add_evidence_urls(asmt, [url])
   actual_asmt = asmt_service.get_obj_from_info_page(obj=asmt)
   rest_asmt_obj = rest_facade.get_obj(asmt)
   asmt.update_attrs(
       updated_at=rest_asmt_obj.updated_at,
       modified_by=rest_asmt_obj.modified_by,
       status=object_states.IN_PROGRESS,
       evidence_urls=[url]).repr_ui()
   self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 4
0
def cancel_review_by_editing_obj(selenium, obj):
    """Edit obj title and revert obj review to unreviewed state.
  Returns updated obj with reverted to unreviewed status review."""
    new_title = element.Common.TITLE_EDITED_PART + obj.title
    _get_ui_service(selenium, obj).edit_obj(obj, title=new_title)
    return obj.update_attrs(title=new_title,
                            updated_at=rest_facade.get_obj(obj).updated_at,
                            modified_by=users.current_user().email,
                            review=entities_factory.ReviewsFactory().create())
Exemplo n.º 5
0
 def test_edit_program(self, program, selenium):
   """Tests if data is saved after editing program info page edit modal."""
   new_title = "[EDITED] " + program.title
   program_service = webui_service.ProgramsService(selenium)
   program_service.edit_obj(program, title=new_title)
   actual_program = program_service.get_obj_from_info_page(program)
   program.update_attrs(
       title=new_title,
       updated_at=rest_facade.get_obj(actual_program).updated_at).repr_ui()
   self.general_equal_assert(program, actual_program)
Exemplo n.º 6
0
 def test_edit_program(self, program, selenium):
     """Tests if data is saved after editing program info page edit modal."""
     new_title = "[EDITED] " + program.title
     program_service = webui_service.ProgramsService(selenium)
     program_service.edit_obj(program, title=new_title)
     actual_program = program_service.get_obj_from_info_page(program)
     program.update_attrs(title=new_title,
                          updated_at=rest_facade.get_obj(
                              actual_program).updated_at).repr_ui()
     self.general_equal_assert(program, actual_program)
Exemplo n.º 7
0
 def test_create_risk(self, selenium):
     """Tests risk creation via UI."""
     risk = entities_factory.RisksFactory().create()
     actual_risk = webui_service.RisksService(
         selenium).create_obj_and_get_obj(risk)
     rest_risk = rest_facade.get_obj(actual_risk)
     risk.update_attrs(created_at=rest_risk.created_at,
                       updated_at=rest_risk.updated_at,
                       modified_by=users.current_user(),
                       slug=rest_risk.slug,
                       url=rest_risk.url).repr_ui()
     self.general_equal_assert(risk, actual_risk, "custom_attributes")
Exemplo n.º 8
0
 def test_create_program(self, selenium):
     """Tests program creation via UI."""
     program = entities_factory.ProgramsFactory().create()
     actual_program = webui_service.ProgramsService(
         selenium).create_obj_and_get_obj(program)
     rest_program = rest_facade.get_obj(actual_program)
     program.update_attrs(created_at=rest_program.created_at,
                          updated_at=rest_program.updated_at,
                          modified_by=users.current_user(),
                          slug=rest_program.slug,
                          url=rest_program.url).repr_ui()
     self.general_equal_assert(program, actual_program, "custom_attributes")
Exemplo n.º 9
0
 def test_create_program(self, selenium):
   """Tests program creation via UI."""
   program = entities_factory.ProgramsFactory().create()
   actual_program = webui_service.ProgramsService(
       selenium).create_obj_and_get_obj(program)
   rest_program = rest_facade.get_obj(actual_program)
   program.update_attrs(
       created_at=rest_program.created_at,
       updated_at=rest_program.updated_at,
       modified_by=users.current_user(),
       slug=rest_program.slug,
       url=rest_program.url).repr_ui()
   self.general_equal_assert(program, actual_program, "custom_attributes")
Exemplo n.º 10
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_facade.delete_control_cas(gca)
  return {"program": program,
          "control": copy.deepcopy(control_mapped_to_program),
          "audit": audit,
          "updated_control": rest_facade.get_obj(control_mapped_to_program)}
Exemplo n.º 11
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_facade.delete_control_cas(gca)
  return {"program": program,
          "control": copy.deepcopy(control_mapped_to_program),
          "audit": audit,
          "updated_control": rest_facade.get_obj(control_mapped_to_program)}
Exemplo n.º 12
0
 def test_create_org_group(self, selenium):
     """Tests Org Group creation via UI."""
     org_group = entities_factory.OrgGroupsFactory().create()
     actual_org_group = webui_service.OrgGroupsService(
         selenium).create_obj_and_get_obj(org_group)
     rest_org_group = rest_facade.get_obj(actual_org_group)
     org_group.update_attrs(created_at=rest_org_group.created_at,
                            updated_at=rest_org_group.updated_at,
                            modified_by=users.current_user(),
                            slug=rest_org_group.slug,
                            url=rest_org_group.url).repr_ui()
     self.general_equal_assert(org_group, actual_org_group,
                               "custom_attributes")
Exemplo n.º 13
0
 def test_create_org_group(self, selenium):
   """Tests Org Group creation via UI."""
   org_group = entities_factory.OrgGroupsFactory().create()
   actual_org_group = webui_service.OrgGroupsService(
       selenium).create_obj_and_get_obj(org_group)
   rest_org_group = rest_facade.get_obj(actual_org_group)
   org_group.update_attrs(
       created_at=rest_org_group.created_at,
       updated_at=rest_org_group.updated_at,
       modified_by=users.current_user(),
       slug=rest_org_group.slug,
       url=rest_org_group.url).repr_ui()
   self.general_equal_assert(org_group, actual_org_group, "custom_attributes")
Exemplo n.º 14
0
 def test_create_risk(self, selenium):
   """Tests risk creation via UI."""
   risk = entities_factory.RisksFactory().create()
   actual_risk = webui_service.RisksService(
       selenium).create_obj_and_get_obj(risk)
   rest_risk = rest_facade.get_obj(actual_risk)
   risk.update_attrs(
       created_at=rest_risk.created_at,
       updated_at=rest_risk.updated_at,
       modified_by=users.current_user(),
       slug=rest_risk.slug,
       url=rest_risk.url).repr_ui()
   self.general_equal_assert(risk, actual_risk, "custom_attributes")
Exemplo n.º 15
0
 def test_create_audit(self, program, selenium):
     """Test creation of an audit via UI."""
     audit = entities_factory.AuditsFactory().create()
     audits_service = webui_service.AuditsService(selenium)
     audits_service.create_obj_via_tree_view(program, audit)
     tree_view_audit = audits_service.get_list_objs_from_tree_view(
         program)[0]
     actual_audit = audits_service.get_obj_from_info_page(tree_view_audit)
     rest_audit = rest_facade.get_obj(actual_audit)
     audit.update_attrs(created_at=rest_audit.created_at,
                        updated_at=rest_audit.updated_at,
                        modified_by=users.current_user(),
                        slug=rest_audit.slug).repr_ui()
     self.general_equal_assert(audit, actual_audit, "custom_attributes")
Exemplo n.º 16
0
 def test_create_audit(self, program, selenium):
   """Test creation of an audit via UI."""
   audit = entities_factory.AuditsFactory().create()
   audits_service = webui_service.AuditsService(selenium)
   audits_service.create_obj_via_tree_view(program, audit)
   tree_view_audit = audits_service.get_list_objs_from_tree_view(program)[0]
   actual_audit = audits_service.get_obj_from_info_page(tree_view_audit)
   rest_audit = rest_facade.get_obj(actual_audit)
   audit.update_attrs(
       created_at=rest_audit.created_at,
       updated_at=rest_audit.updated_at,
       modified_by=users.current_user(),
       slug=rest_audit.slug).repr_ui()
   self.check_ggrc_7048(audit, actual_audit)
Exemplo n.º 17
0
 def test_add_person_to_acl_list(self, program, audit, selenium):
     """Test that an assessment assignee can add a person to ACL"""
     assignee = rest_facade.create_user_with_role(roles.CREATOR)
     primary_contact = rest_facade.create_user_with_role(roles.CREATOR)
     asmt = rest_facade.create_assessment(audit, assignees=[assignee])
     users.set_current_user(assignee)
     asmt_service = webui_service.AssessmentsService(selenium)
     asmt_service.add_primary_contact(asmt, primary_contact)
     selenium.refresh()
     actual_asmt = asmt_service.get_obj_from_info_page(asmt)
     asmt.update_attrs(updated_at=rest_facade.get_obj(asmt).updated_at,
                       primary_contacts=[primary_contact],
                       modified_by=assignee).repr_ui()
     self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 18
0
 def test_view_evidence_urls_as_verifier(self, program, audit, selenium):
     """Test that an assessment verifier can see evidence urls
 on assessment page
 """
     verifier = rest_facade.create_user_with_role(roles.CREATOR)
     asmt = rest_facade.create_assessment(audit, verifiers=[verifier])
     asmt_service = webui_service.AssessmentsService(selenium)
     url = string_utils.StringMethods.random_string()
     asmt_service.add_evidence_urls(asmt, [url])
     users.set_current_user(verifier)
     actual_asmt = asmt_service.get_obj_from_info_page(asmt)
     asmt.update_attrs(status=object_states.IN_PROGRESS,
                       updated_at=rest_facade.get_obj(asmt).updated_at,
                       evidence_urls=[url]).repr_ui()
     self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 19
0
 def test_add_person_to_acl_list(self, program, audit, selenium):
   """Test that an assessment assignee can add a person to ACL"""
   assignee = rest_facade.create_user_with_role(roles.CREATOR)
   primary_contact = rest_facade.create_user_with_role(roles.CREATOR)
   asmt = rest_facade.create_assessment(audit, assignees=[assignee])
   users.set_current_user(assignee)
   asmt_service = webui_service.AssessmentsService(selenium)
   asmt_service.add_primary_contact(asmt, primary_contact)
   selenium.refresh()
   actual_asmt = asmt_service.get_obj_from_info_page(asmt)
   asmt.update_attrs(
       updated_at=rest_facade.get_obj(asmt).updated_at,
       primary_contacts=[primary_contact],
       modified_by=assignee).repr_ui()
   self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 20
0
 def test_change_asmt_state_as_verifier(
     self, program, audit, initial_state, action, end_state, selenium
 ):
   """Tests for changing assessment state as assessment verifier"""
   verifier = rest_facade.create_user_with_role(roles.CREATOR)
   asmt = rest_facade.create_assessment(
       audit, status=initial_state, verifiers=[verifier])
   users.set_current_user(verifier)
   asmt_service = webui_service.AssessmentsService(selenium)
   getattr(asmt_service, action)(asmt)
   actual_asmt = asmt_service.get_obj_from_info_page(asmt)
   asmt.update_attrs(
       updated_at=rest_facade.get_obj(asmt).updated_at,
       status=end_state,
       verified=(True if action == "verify_assessment" else False)).repr_ui()
   self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 21
0
 def test_change_asmt_state_as_verifier(
     self, program, audit, initial_state, action, end_state, selenium
 ):
   """Tests for changing assessment state as assessment verifier"""
   verifier = rest_facade.create_user_with_role(roles.CREATOR)
   asmt = rest_facade.create_asmt(audit,
                                  status=initial_state, verifiers=[verifier])
   users.set_current_user(verifier)
   asmt_service = webui_service.AssessmentsService(selenium)
   getattr(asmt_service, action)(asmt)
   actual_asmt = asmt_service.get_obj_from_info_page(asmt)
   asmt.update_attrs(
       updated_at=rest_facade.get_obj(asmt).updated_at,
       status=end_state,
       verified=(True if action == "verify_assessment" else False)).repr_ui()
   self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 22
0
 def test_asmt_creation(self, program, audit, selenium):
     """Check if Assessment can be created from Audit page via
 Assessments widget.
 Preconditions:
 - Audit created under Program via REST API.
 """
     asmt = entities_factory.AssessmentsFactory().create()
     asmts_service = webui_service.AssessmentsService(selenium)
     asmts_service.create_obj_via_tree_view(src_obj=audit, obj=asmt)
     tree_view_asmt = asmts_service.get_list_objs_from_tree_view(audit)[0]
     actual_asmt = asmts_service.get_obj_from_info_page(tree_view_asmt)
     rest_asmt = rest_facade.get_obj(actual_asmt)
     asmt.update_attrs(created_at=rest_asmt.created_at,
                       updated_at=rest_asmt.updated_at,
                       modified_by=rest_asmt.modified_by).repr_ui()
     self.general_equal_assert(asmt, actual_asmt, "custom_attributes")
Exemplo n.º 23
0
 def test_view_evidence_urls_as_verifier(self, program, audit, selenium):
   """Test that an assessment verifier can see evidence urls
   on assessment page
   """
   verifier = rest_facade.create_user_with_role(roles.CREATOR)
   asmt = rest_facade.create_assessment(audit, verifiers=[verifier])
   asmt_service = webui_service.AssessmentsService(selenium)
   url = string_utils.StringMethods.random_string()
   asmt_service.add_evidence_urls(asmt, [url])
   users.set_current_user(verifier)
   actual_asmt = asmt_service.get_obj_from_info_page(asmt)
   asmt.update_attrs(
       status=object_states.IN_PROGRESS,
       updated_at=rest_facade.get_obj(asmt).updated_at,
       evidence_urls=[url]).repr_ui()
   self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 24
0
 def test_create_and_map_control(self, program, selenium):
     """Test that control can be created and mapped using Unified mapper."""
     controls_service = webui_service.ControlsService(selenium)
     controls_service.open_widget_of_mapped_objs(
         program).tree_view.open_map().click_create_and_map_obj()
     control = entities_factory.ControlsFactory().create()
     controls_service.submit_obj_modal(control)
     tree_view_control = controls_service.get_list_objs_from_tree_view(
         program)[0]
     actual_control = controls_service.get_obj_from_info_page(
         tree_view_control)
     rest_control = rest_facade.get_obj(actual_control)
     control.update_attrs(created_at=rest_control.created_at,
                          updated_at=rest_control.updated_at,
                          modified_by=users.current_user(),
                          slug=rest_control.slug).repr_ui()
     self.general_equal_assert(control, actual_control, "custom_attributes")
Exemplo n.º 25
0
 def test_asmt_creation(self, program, audit, selenium):
   """Check if Assessment can be created from Audit page via
   Assessments widget.
   Preconditions:
   - Audit created under Program via REST API.
   """
   asmt = entities_factory.AssessmentsFactory().create()
   asmts_service = webui_service.AssessmentsService(selenium)
   asmts_service.create_obj_via_tree_view(src_obj=audit, obj=asmt)
   tree_view_asmt = asmts_service.get_list_objs_from_tree_view(audit)[0]
   actual_asmt = asmts_service.get_obj_from_info_page(tree_view_asmt)
   rest_asmt = rest_facade.get_obj(actual_asmt)
   asmt.update_attrs(
       created_at=rest_asmt.created_at,
       updated_at=rest_asmt.updated_at,
       modified_by=rest_asmt.modified_by
   ).repr_ui()
   self.general_equal_assert(asmt, actual_asmt, "custom_attributes")
Exemplo n.º 26
0
 def test_create_and_map_control(self, set_external_user_as_current_user,
                                 program, selenium):
     """Test that control can be created and mapped using Unified mapper."""
     # pylint: disable=unused-argument
     from lib.service import webui_facade
     control = webui_facade.create_control_in_program_scope(
         selenium, program)
     controls_service = webui_service.ControlsService(selenium)
     tree_view_control = controls_service.get_list_objs_from_tree_view(
         program)[0]
     actual_control = controls_service.get_obj_from_info_page(
         tree_view_control)
     rest_control = rest_facade.get_obj(actual_control)
     control.update_attrs(created_at=rest_control.created_at,
                          updated_at=rest_control.updated_at,
                          modified_by=users.current_user(),
                          slug=rest_control.slug).repr_ui()
     self.general_equal_assert(control, actual_control, "custom_attributes")
Exemplo n.º 27
0
 def test_map_snapshots_to_asmt_via_edit_modal(self, program, obj, audit,
                                               assessment, selenium):
     """Check Assessment can be mapped with snapshot via Modal Edit
 on Assessments Info Page. Additional check existing of mapped obj Titles
 on Modal Edit.
 Objects structure:
 Program
 -> Obj (control or objective)
 -> Audit
   -> Assessment
 """
     asmts_ui_service = webui_service.AssessmentsService(selenium)
     asmts_ui_service.map_objs_in_edit_modal(assessment, [obj])
     assessment.update_attrs(
         mapped_objects=[obj],
         updated_at=rest_facade.get_obj(assessment).updated_at).repr_ui()
     actual_asmt = asmts_ui_service.get_obj_from_info_page(assessment)
     self.general_equal_assert(assessment, actual_asmt, "audit")
Exemplo n.º 28
0
def create_asmt(selenium, audit):
    """Create audit via UI."""
    expected_asmt = entities_factory.AssessmentsFactory().create()
    asmts_ui_service = webui_service.AssessmentsService(selenium)
    asmts_ui_service.create_obj_via_tree_view(src_obj=audit, obj=expected_asmt)
    asmt_tree_view = generic_widget.TreeView(selenium, None,
                                             objects.ASSESSMENTS)
    expected_asmt.url = (asmt_tree_view.get_obj_url_from_tree_view_by_title(
        expected_asmt.title))
    expected_asmt.id = expected_asmt.url.split('/')[-1]
    expected_asmt_rest = rest_facade.get_obj(expected_asmt)
    expected_asmt.assignees = audit.audit_captains
    expected_asmt.creators = [users.current_user().email]
    expected_asmt.verifiers = audit.auditors
    expected_asmt.created_at = expected_asmt_rest.created_at
    expected_asmt.modified_by = users.current_user().email
    expected_asmt.updated_at = expected_asmt_rest.updated_at
    return expected_asmt
Exemplo n.º 29
0
def create_asmt(selenium, audit):
  """Create audit via UI."""
  expected_asmt = entities_factory.AssessmentsFactory().create()
  asmts_ui_service = webui_service.AssessmentsService(selenium)
  asmts_ui_service.create_obj_via_tree_view(
      src_obj=audit, obj=expected_asmt)
  asmt_tree_view = generic_widget.TreeView(
      selenium, None, objects.ASSESSMENTS)
  expected_asmt.url = (
      asmt_tree_view.get_obj_url_from_tree_view_by_title(expected_asmt.title))
  expected_asmt.id = expected_asmt.url.split('/')[-1]
  expected_asmt_rest = rest_facade.get_obj(expected_asmt)
  expected_asmt.assignees = audit.audit_captains
  expected_asmt.creators = [users.current_user().email]
  expected_asmt.verifiers = audit.auditors
  expected_asmt.created_at = expected_asmt_rest.created_at
  expected_asmt.modified_by = users.current_user().email
  expected_asmt.updated_at = expected_asmt_rest.updated_at
  return expected_asmt
Exemplo n.º 30
0
 def test_auditor_can_assign_user_to_asmt(self, selenium, test_data):
     """Preconditions:
 Global editor creates program with mapped control.
 Global editor creates audit and assigns Global Creator user as an auditor
 - log in as GC
 - navigate to audit page => Assessments tab
 Test that GC can assign user to new asmt in audit."""
     # pylint: disable=invalid-name
     creator = test_data["creator"]
     users.set_current_user(creator)
     audit = test_data["audit"]
     expected_asmt = rest_facade.create_asmt(audit)
     asmt_service = webui_service.AssessmentsService(selenium)
     asmt_service.add_asignee(expected_asmt, test_data["editor"])
     expected_asmt.update_attrs(
         updated_at=rest_facade.get_obj(expected_asmt).updated_at,
         assignees=[creator.email, test_data["editor"].email],
         modified_by=users.current_user().email)
     webui_facade.assert_can_view(selenium, expected_asmt)
Exemplo n.º 31
0
 def test_add_evidence_url(self, program, login_role, obj, obj_role,
                           selenium):
     """Test that various users have possibility to add an evidence url into
 assessment.
 """
     login_user = rest_facade.create_user_with_role(login_role)
     obj_args = {obj_role: [login_user]}
     audit = rest_facade.create_audit(program,
                                      **obj_args if obj == "audit" else {})
     asmt = rest_facade.create_assessment(
         audit, **obj_args if obj == "assessment" else {})
     users.set_current_user(login_user)
     url = string_utils.StringMethods.random_string()
     asmt_service = webui_service.AssessmentsService(selenium)
     asmt_service.add_evidence_urls(asmt, [url])
     actual_asmt = asmt_service.get_obj_from_info_page(obj=asmt)
     asmt.update_attrs(updated_at=rest_facade.get_obj(asmt).updated_at,
                       status=object_states.IN_PROGRESS,
                       evidence_urls=[url]).repr_ui()
     self.general_equal_assert(asmt, actual_asmt, "audit")
Exemplo n.º 32
0
 def test_auditor_can_assign_user_to_asmt(
     self, selenium, test_data
 ):
   """Preconditions:
   Global editor creates program with mapped control.
   Global editor creates audit and assigns Global Creator user as an auditor
   - log in as GC
   - navigate to audit page => Assessments tab
   Test that GC can assign user to new asmt in audit."""
   # pylint: disable=invalid-name
   creator = test_data["creator"]
   users.set_current_user(creator)
   audit = test_data["audit"]
   expected_asmt = rest_facade.create_assessment(audit)
   asmt_service = webui_service.AssessmentsService(selenium)
   asmt_service.add_asignee(expected_asmt, test_data["editor"])
   expected_asmt.update_attrs(
       updated_at=rest_facade.get_obj(expected_asmt).updated_at,
       assignees=[creator.email, test_data["editor"].email],
       modified_by=users.current_user().email)
   webui_facade.assert_can_view(selenium, expected_asmt)
Exemplo n.º 33
0
 def test_fill_asmt_gcas_inline(self, program, audit, assessment, attr_type,
                                selenium):
     """Test for checking population of GCA from UI inline fields.
 Preconditions:
 - Program created via REST API.
 - Audit created via REST API.
 - Global Custom Attributes for Assessment created via REST API.
 - Assessment created via REST API.
 """
     gcad = rest_facade.create_gcad(definition_type="assessment",
                                    attribute_type=attr_type)
     custom_attributes = CustomAttributeDefinitionsFactory(
     ).generate_custom_attributes([gcad])
     asmts_ui_service = webui_service.AssessmentsService(selenium)
     asmts_ui_service.fill_obj_gcas_inline(assessment, custom_attributes)
     selenium.refresh()
     actual_asmt = rest_facade.get_obj(assessment)
     assessment.update_attrs(updated_at=actual_asmt.updated_at,
                             status=actual_asmt.status,
                             custom_attributes=custom_attributes)
     _assert_asmt(asmts_ui_service, assessment)
Exemplo n.º 34
0
 def test_asmt_creation_with_mapping(self, program, obj, audit, selenium):
     """Check if Assessment can be created with mapped snapshot via
 Modal Create on Assessments TreeView.
 Objects structure:
 Program
 -> Obj (Control or Objective)
 -> Audit
 """
     expected_asmt = (entities_factory.AssessmentsFactory().create(
         mapped_objects=[obj]))
     asmts_service = webui_service.AssessmentsService(selenium)
     asmts_service.create_obj_via_tree_view(src_obj=audit,
                                            obj=expected_asmt)
     tree_view_asmt = asmts_service.get_list_objs_from_tree_view(audit)[0]
     actual_asmt = asmts_service.get_obj_from_info_page(tree_view_asmt)
     rest_asmt = rest_facade.get_obj(actual_asmt)
     expected_asmt.update_attrs(created_at=rest_asmt.created_at,
                                updated_at=rest_asmt.updated_at,
                                modified_by=users.current_user(),
                                slug=rest_asmt.slug).repr_ui()
     self.general_equal_assert(expected_asmt, actual_asmt,
                               "custom_attributes")
Exemplo n.º 35
0
 def test_asmt_creation_with_mapping(
     self, program, obj, audit, selenium
 ):
   """Check if Assessment can be created with mapped snapshot via
   Modal Create on Assessments TreeView.
   Objects structure:
   Program
   -> Obj (Control or Objective)
   -> Audit
   """
   expected_asmt = (
       entities_factory.AssessmentsFactory().create(mapped_objects=[obj]))
   asmts_service = webui_service.AssessmentsService(selenium)
   asmts_service.create_obj_via_tree_view(src_obj=audit, obj=expected_asmt)
   tree_view_asmt = asmts_service.get_list_objs_from_tree_view(audit)[0]
   actual_asmt = asmts_service.get_obj_from_info_page(tree_view_asmt)
   rest_asmt = rest_facade.get_obj(actual_asmt)
   expected_asmt.update_attrs(
       created_at=rest_asmt.created_at,
       updated_at=rest_asmt.updated_at,
       modified_by=users.current_user(),
       slug=rest_asmt.slug).repr_ui()
   self.general_equal_assert(expected_asmt, actual_asmt, "custom_attributes")
    def tested_events(self, selenium):
        """Create events to verify events functionality:
    0. Save event log count before test data creation,
    1. Create control editor role, create 2 users with global creator role
    under admin
    2. Create control#1 under global creator#1 and set global creator#2 to
    newly created control editor role
    3. Create control#2 under global creator#2 and map it control#1
    """
        if not self.__class__._data:
            # generate enough data, so test can be executed independently
            for _ in xrange(6):
                rest_facade.create_user_with_role(roles.READER)

            initial_count = self.get_event_tab().tab_events.count
            ctrl1_creator = rest_facade.create_user_with_role(roles.CREATOR)
            ctrl2_creator = rest_facade.create_user_with_role(roles.CREATOR)
            ctrl_editor_role = rest_facade.create_access_control_role(
                object_type="Control", read=True, update=True, delete=True)
            admin = users.current_user()
            users.set_current_user(ctrl1_creator)
            ctrl_custom_roles = [(ctrl_editor_role.name, ctrl_editor_role.id,
                                  [ctrl2_creator])]
            ctrl1 = rest_facade.create_control(custom_roles=ctrl_custom_roles)
            # wait until notification and acl will assigned by background task
            rest_facade.get_obj(ctrl1)

            users.set_current_user(ctrl2_creator)
            ctrl2 = rest_facade.create_control()
            rest_facade.map_objs(ctrl1, ctrl2)

            users.set_current_user(admin)
            # generate expected event data
            acl_roles_len = 7
            exp_event_data = [{
                "actions":
                sorted([
                    ctrl1_creator.email + " created", u"PersonProfile created"
                ]),
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(ctrl1_creator.updated_at)
            }, {
                "actions": ["Creator linked to " + ctrl1_creator.email],
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(ctrl1_creator.updated_at)
            }, {
                "actions":
                sorted([
                    ctrl2_creator.email + " created", u"PersonProfile created"
                ]),
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(ctrl2_creator.updated_at)
            }, {
                "actions": ["Creator linked to " + ctrl2_creator.email],
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(ctrl2_creator.updated_at)
            }, {
                "actions": [ctrl_editor_role.name + " created"],
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(
                    ctrl_editor_role.updated_at)
            }, {
                "actions": [u"AccessControlList created"] * acl_roles_len +
                [u"AccessControlPerson created"] * 2 +
                [ctrl1.title + " created", u"Security created"],
                "user_email":
                ctrl1_creator.email,
                "time":
                date_utils.iso8601_to_local_datetime(ctrl1.updated_at)
            }, {
                "actions": [u"AccessControlList created"] * acl_roles_len + [
                    u"AccessControlPerson created", ctrl2.title + " created",
                    u"Security created"
                ],
                "user_email":
                ctrl2_creator.email,
                "time":
                date_utils.iso8601_to_local_datetime(ctrl2.updated_at)
            }, {
                "actions": [
                    u"Control:{id2} linked to Control:{id1}".format(
                        id1=ctrl1.id, id2=ctrl2.id)
                ],
                "user_email":
                ctrl2_creator.email,
                "time":
                date_utils.iso8601_to_local_datetime(ctrl2.updated_at)
            }]
            exp_event_data.reverse()
            self.__class__._data = {
                "ctrl1_creator": ctrl1_creator,
                "ctrl2_creator": ctrl2_creator,
                "ctrl_editor_role": ctrl_editor_role,
                "ctrl1": ctrl1,
                "ctrl2": ctrl2,
                "exp_added_events": exp_event_data,
                "initial_count": initial_count
            }
        return self.__class__._data
Exemplo n.º 37
0
  def tested_events(self, selenium):
    """Create events to verify events functionality:
    0. Save event log count before test data creation,
    1. Create objective editor role, create 2 users with global creator role
    under admin
    2. Create objective#1 under global creator#1 and set global creator#2 to
    newly created objective editor role
    3. Create objective#2 under global objective#2 and map it objective#1
    """
    if not self.__class__._data:
      # generate enough data, so test can be executed independently
      for _ in xrange(6):
        rest_facade.create_user_with_role(roles.READER)

      initial_count = self.get_event_tab().tab_events.count
      objctv1_creator = rest_facade.create_user_with_role(roles.CREATOR)
      objctv2_creator = rest_facade.create_user_with_role(roles.CREATOR)
      objctv_editor_role = rest_facade.create_access_control_role(
          object_type="Objective", read=True, update=True, delete=True)
      admin = users.current_user()
      users.set_current_user(objctv1_creator)
      objctv_custom_roles = [
          (objctv_editor_role.name, objctv_editor_role.id, [objctv2_creator])
      ]
      objctv1 = rest_facade.create_objective(custom_roles=objctv_custom_roles)
      # wait until notification and acl will assigned by background task
      rest_facade.get_obj(objctv1_creator)

      users.set_current_user(objctv2_creator)
      objctv2 = rest_facade.create_objective()
      rest_facade.map_objs(objctv1, objctv2)

      users.set_current_user(admin)
      # generate expected event data
      from lib.constants.roles import ACLRolesIDs
      # 3 predefined program roles and 1 predefined reviewer role
      acl_roles_len = len(ACLRolesIDs.object_roles(objctv1.type)) - 4
      exp_event_data = [
          {"actions": sorted(
              [objctv1_creator.email + " created", u"PersonProfile created"]),
           "user_email": admin.email,
           "time": date_utils.iso8601_to_local_datetime(
              objctv1_creator.updated_at)},
          {"actions": ["Creator linked to " + objctv1_creator.email],
           "user_email": admin.email,
           "time": date_utils.iso8601_to_local_datetime(
              objctv1_creator.updated_at)},
          {"actions": sorted(
              [objctv2_creator.email + " created", u"PersonProfile created"]),
           "user_email": admin.email,
           "time": date_utils.iso8601_to_local_datetime(
              objctv2_creator.updated_at)},
          {"actions": ["Creator linked to " + objctv2_creator.email],
           "user_email": admin.email,
           "time": date_utils.iso8601_to_local_datetime(
              objctv2_creator.updated_at)},
          {"actions": [objctv_editor_role.name + " created"],
           "user_email": admin.email,
           "time": date_utils.iso8601_to_local_datetime(
              objctv_editor_role.updated_at)},
          {"actions": [u"AccessControlList created"] * acl_roles_len +
                      [u"AccessControlPerson created"] * 2 +
                      [objctv1.title + " created"],
           "user_email": objctv1_creator.email,
           "time": date_utils.iso8601_to_local_datetime(objctv1.updated_at)},
          {"actions": [u"AccessControlList created"] * acl_roles_len +
                      [u"AccessControlPerson created",
                       objctv2.title + " created"],
           "user_email": objctv2_creator.email,
           "time": date_utils.iso8601_to_local_datetime(objctv2.updated_at)},
          {"actions": [u"{type2}:{id2} linked to {type1}:{id1}".format(
              id1=objctv1.id, id2=objctv2.id, type1=objctv1.type,
              type2=objctv2.type)],
           "user_email": objctv2_creator.email,
           "time": date_utils.iso8601_to_local_datetime(objctv2.updated_at)}
      ]
      exp_event_data.reverse()
      self.__class__._data = {
          "objctv1_creator": objctv1_creator,
          "objctv2_creator": objctv2_creator,
          "objctv_editor_role": objctv_editor_role,
          "objctv1": objctv1,
          "objctv2": objctv2,
          "exp_added_events": exp_event_data,
          "initial_count": initial_count
      }
    return self.__class__._data
Exemplo n.º 38
0
    def tested_events(self, selenium):
        """Create events to verify events functionality:
    0. Save event log count before test data creation,
    1. Create objective editor role, create 2 users with global creator role
    under admin
    2. Create objective#1 under global creator#1 and set global creator#2 to
    newly created objective editor role
    3. Create objective#2 under global objective#2 and map it objective#1
    """
        if not self.__class__._data:
            # generate enough data, so test can be executed independently
            for _ in xrange(6):
                rest_facade.create_user_with_role(roles.READER)

            initial_count = self.get_event_tab().tab_events.count
            objctv1_creator = rest_facade.create_user_with_role(roles.CREATOR)
            objctv2_creator = rest_facade.create_user_with_role(roles.CREATOR)
            objctv_editor_role = rest_facade.create_access_control_role(
                object_type="Objective", read=True, update=True, delete=True)
            admin = users.current_user()
            users.set_current_user(objctv1_creator)
            objctv_custom_roles = [(objctv_editor_role.name,
                                    objctv_editor_role.id, [objctv2_creator])]
            objctv1 = rest_facade.create_objective(
                custom_roles=objctv_custom_roles)
            # wait until notification and acl will assigned by background task
            rest_facade.get_obj(objctv1_creator)

            users.set_current_user(objctv2_creator)
            objctv2 = rest_facade.create_objective()
            rest_facade.map_objs(objctv1, objctv2)

            users.set_current_user(admin)
            # generate expected event data
            from lib.constants.roles import ACLRolesIDs
            # 3 predefined program roles and 1 predefined reviewer role
            acl_roles_len = len(ACLRolesIDs.object_roles(objctv1.type)) - 4
            exp_event_data = [{
                "actions":
                sorted([
                    objctv1_creator.email + " created",
                    u"PersonProfile created"
                ]),
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(
                    objctv1_creator.updated_at)
            }, {
                "actions": ["Creator linked to " + objctv1_creator.email],
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(
                    objctv1_creator.updated_at)
            }, {
                "actions":
                sorted([
                    objctv2_creator.email + " created",
                    u"PersonProfile created"
                ]),
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(
                    objctv2_creator.updated_at)
            }, {
                "actions": ["Creator linked to " + objctv2_creator.email],
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(
                    objctv2_creator.updated_at)
            }, {
                "actions": [objctv_editor_role.name + " created"],
                "user_email":
                admin.email,
                "time":
                date_utils.iso8601_to_local_datetime(
                    objctv_editor_role.updated_at)
            }, {
                "actions": [u"AccessControlList created"] * acl_roles_len +
                [u"AccessControlPerson created"] * 2 +
                [objctv1.title + " created"],
                "user_email":
                objctv1_creator.email,
                "time":
                date_utils.iso8601_to_local_datetime(objctv1.updated_at)
            }, {
                "actions": [u"AccessControlList created"] * acl_roles_len +
                [u"AccessControlPerson created", objctv2.title + " created"],
                "user_email":
                objctv2_creator.email,
                "time":
                date_utils.iso8601_to_local_datetime(objctv2.updated_at)
            }, {
                "actions": [
                    u"{type2}:{id2} linked to {type1}:{id1}".format(
                        id1=objctv1.id,
                        id2=objctv2.id,
                        type1=objctv1.type,
                        type2=objctv2.type)
                ],
                "user_email":
                objctv2_creator.email,
                "time":
                date_utils.iso8601_to_local_datetime(objctv2.updated_at)
            }]
            exp_event_data.reverse()
            self.__class__._data = {
                "objctv1_creator": objctv1_creator,
                "objctv2_creator": objctv2_creator,
                "objctv_editor_role": objctv_editor_role,
                "objctv1": objctv1,
                "objctv2": objctv2,
                "exp_added_events": exp_event_data,
                "initial_count": initial_count
            }
        return self.__class__._data