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_assessment(
      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)
  return assessment
Beispiel #2
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_assessment(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)
    return assessment
Beispiel #3
0
 def test_auditor_can_edit_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 edit new asmt in audit."""
     creator = test_data["creator"]
     users.set_current_user(creator)
     audit = test_data["audit"]
     expected_asmt = rest_facade.create_assessment(audit)
     webui_facade.assert_can_edit_asmt(selenium, expected_asmt)
Beispiel #4
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")
 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")
Beispiel #6
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")
Beispiel #7
0
 def test_auditor_can_edit_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 edit new asmt in audit."""
   creator = test_data["creator"]
   users.set_current_user(creator)
   audit = test_data["audit"]
   expected_asmt = rest_facade.create_assessment(audit)
   webui_facade.assert_can_edit_asmt(
       selenium, expected_asmt)
 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")
 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")
Beispiel #10
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")
Beispiel #11
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)
Beispiel #12
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")
Beispiel #13
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)
Beispiel #14
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")