Exemplo n.º 1
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.º 2
0
 def test_related_asmts_in_different_audits_mapped_to_mapped_controls(
         self, program, selenium):
     """Objects structure:
 Program
 -> Control-1
 -> Control-2
 Control-1 and Control-2 are mapped.
 -> Audit-1 -> Asmt-1 mapped to Control-1
 -> Audit-2 -> Asmt-2 mapped to Control-2
 As a result, assessments are related."""
     controls = [rest_facade.create_control(program) for _ in xrange(2)]
     rest_facade.map_objs(controls[0], controls[1])
     audits = [rest_facade.create_audit(program) for _ in xrange(2)]
     assessments = [
         _create_mapped_asmt(audit=audit,
                             assessment_type="Control",
                             objs_to_map=[control])
         for control, audit in zip(controls, audits)
     ]
     related_asmts_titles = [(assessments[1].title, controls[1].title,
                              audits[1].title)]
     self._assert_asmt_with_related_asmts(
         checked_asmt=assessments[0],
         related_asmts_titles=related_asmts_titles,
         selenium=selenium)
Exemplo n.º 3
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.º 4
0
def audit_w_manually_mapped_control_and_obj_mapped_to_control(
        program, control_mapped_to_program, obj_mapped_to_control):
    """"Create an audit within program and manually map it to control and
  object mapped to control."""
    audit = rest_facade.create_audit(program=program, manual_snapshots=True)
    rest_facade.map_objs(audit, control_mapped_to_program)
    rest_facade.map_objs(obj_mapped_to_control, audit)
    return audit
Exemplo n.º 5
0
def programs_with_audit_and_techenv(mapped_programs, technology_environment):
  """Creates 2 programs (the second program is a child of the first one)
  and 1 technology environment objects, then creates an Audit
  in scope of program 2 and finally maps Technology Environment object
  to Audit."""
  audit = rest_facade.create_audit(mapped_programs[1])
  rest_facade.map_objs(audit, technology_environment)
  return {'programs': mapped_programs,
          'audit': audit,
          'techenv': technology_environment}
Exemplo n.º 6
0
def programs_with_audit_and_techenv(programs, technology_environment):
    """Creates 2 programs and 1 technology environment objects, then maps second
  program to first as a child, then creates an Audit in scope of program 2
  and finally maps Technology Environment object to Audit."""
    first_program, second_program = programs
    rest_facade.map_objs(first_program, second_program)
    audit = rest_facade.create_audit(second_program)
    rest_facade.map_objs(audit, technology_environment)
    return {
        'programs': programs,
        'audit': audit,
        'techenv': technology_environment
    }
Exemplo n.º 7
0
 def test_set_comment_for_dropdown_lca(self, program,
                                       control_mapped_to_program,
                                       login_role, obj, obj_role, selenium):
     """Check evidence comment could be filled in
 via Assessment dropdown.
 Objects structure:
 Program.
 -> Control mapped to program.
 -> Audit.
   -> Asmt template with evidence comment dropdown.
     -> Autogenerated asmt.
 """
     # pylint: disable=too-many-locals
     user = rest_facade.create_user_with_role(login_role)
     obj_args = {obj_role: [user]}
     audit = rest_facade.create_audit(program,
                                      **obj_args if obj == "audit" else {})
     comment_text = entities_factory.CommentsFactory().create().description
     asmt_template_w_dropdown = rest_facade.create_asmt_template(
         audit,
         cad_type=AdminWidgetCustomAttributes.DROPDOWN,
         dropdown_types_list=["comment"],
         **obj_args if obj == "assessment" else {})
     expected_asmt = rest_facade.create_asmt_from_template(
         audit, asmt_template_w_dropdown, [control_mapped_to_program])
     dropdown = CustomAttributeDefinitionsFactory().create(
         **expected_asmt.cads_from_template()[0])
     users.set_current_user(user)
     asmt_service = webui_service.AssessmentsService(selenium)
     asmt_service.choose_and_fill_dropdown_lca(expected_asmt,
                                               dropdown,
                                               comment=comment_text)
     rest_asmt_obj = self.info_service().get_obj(obj=expected_asmt)
     expected_asmt.update_attrs(
         custom_attributes={
             dropdown.title.upper(): dropdown.multi_choice_options
         },
         updated_at=rest_asmt_obj.updated_at,
         modified_by=rest_asmt_obj.modified_by,
         mapped_objects=[control_mapped_to_program.title],
         status=object_states.IN_PROGRESS).repr_ui()
     actual_asmt = asmt_service.get_obj_from_info_page(obj=expected_asmt)
     actual_comment_texts = [
         comment["description"] for comment in actual_asmt.comments
     ]
     self.general_equal_assert(expected_asmt, actual_asmt, "audit",
                               "comments")
     assert actual_comment_texts == [comment_text]
Exemplo n.º 8
0
 def test_data(self):
     """Objects structure:
 Program
 -> Control
 -> Audit (Auditor is a user with global creator role)
 """
     editor = rest_facade.create_user_with_role(roles.EDITOR)
     creator = rest_facade.create_user_with_role(roles.CREATOR)
     users.set_current_user(editor)
     program = rest_facade.create_program()
     control = rest_facade.create_control(program=program)
     audit = rest_facade.create_audit(program, auditors=[creator])
     return {
         "editor": editor,
         "creator": creator,
         "program": program,
         "audit": audit,
         "control": control
     }
Exemplo n.º 9
0
 def test_data(self):
   """Objects structure:
   Program
   -> Control
   -> Audit (Auditor is a user with global creator role)
   """
   editor = rest_facade.create_user_with_role(roles.EDITOR)
   creator = rest_facade.create_user_with_role(roles.CREATOR)
   users.set_current_user(editor)
   program = rest_facade.create_program()
   control = rest_facade.create_control(program=program)
   audit = rest_facade.create_audit(program, auditors=[creator])
   return {
       "editor": editor,
       "creator": creator,
       "program": program,
       "audit": audit,
       "control": control
   }
Exemplo n.º 10
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.º 11
0
 def test_set_url_for_dropdown_lca(self, program, control_mapped_to_program,
                                   login_role, obj, obj_role, selenium):
     """Check evidence url could be filled in
 via Assessment dropdown.
 Objects structure:
 Program.
 -> Control mapped to program.
 -> Audit.
   -> Asmt template with evidence url dropdown.
     -> Autogenerated asmt.
 """
     user = rest_facade.create_user_with_role(login_role)
     obj_args = {obj_role: [user]}
     audit = rest_facade.create_audit(program,
                                      **obj_args if obj == "audit" else {})
     url = StringMethods.random_string()
     asmt_template_w_dropdown = rest_facade.create_asmt_template(
         audit,
         cad_type=AdminWidgetCustomAttributes.DROPDOWN,
         dropdown_types_list=["url"],
         **obj_args if obj == "assessment" else {})
     expected_asmt = rest_facade.create_asmt_from_template(
         audit, asmt_template_w_dropdown, [control_mapped_to_program])
     dropdown = CustomAttributeDefinitionsFactory().create(
         **expected_asmt.cads_from_template()[0])
     users.set_current_user(user)
     asmt_service = webui_service.AssessmentsService(selenium)
     asmt_service.choose_and_fill_dropdown_lca(expected_asmt,
                                               dropdown,
                                               url=url)
     rest_asmt_obj = self.info_service().get_obj(expected_asmt)
     expected_asmt.update_attrs(
         custom_attributes={
             dropdown.title.upper(): dropdown.multi_choice_options
         },
         updated_at=rest_asmt_obj.updated_at,
         modified_by=rest_asmt_obj.modified_by,
         evidence_urls=[url],
         mapped_objects=[control_mapped_to_program.title],
         status=object_states.IN_PROGRESS)
     _assert_asmt(asmt_service, expected_asmt)
Exemplo n.º 12
0
 def test_related_asmts_in_different_audits_mapped_to_mapped_controls(
     self, program, selenium
 ):
   """Objects structure:
   Program
   -> Control-1
   -> Control-2
   Control-1 and Control-2 are mapped.
   -> Audit-1 -> Asmt-1 mapped to Control-1
   -> Audit-2 -> Asmt-2 mapped to Control-2
   As a result, assessments are related."""
   controls = [rest_facade.create_control(program) for _ in xrange(2)]
   rest_facade.map_objs(controls[0], controls[1])
   audits = [rest_facade.create_audit(program) for _ in xrange(2)]
   assessments = [_create_mapped_asmt(
       audit=audit, assessment_type="Control", objs_to_map=[control])
       for control, audit in zip(controls, audits)]
   related_asmts_titles = [
       (assessments[1].title, controls[1].title, audits[1].title)]
   self._assert_asmt_with_related_asmts(
       checked_asmt=assessments[0],
       related_asmts_titles=related_asmts_titles,
       selenium=selenium)
Exemplo n.º 13
0
def audits(program):
  """Create 2 audits mapped to the program"""
  return [rest_facade.create_audit(program) for _ in xrange(2)]
Exemplo n.º 14
0
def audits(program):
    """Create 2 audits mapped to the program"""
    return [rest_facade.create_audit(program) for _ in xrange(2)]
Exemplo n.º 15
0
def audit(program):
    """Create an audit within program"""
    return rest_facade.create_audit(program)
Exemplo n.º 16
0
def audit_w_auditor(program, second_creator):
  """Create an audit within program and set a user with global creator role as
  an auditor."""
  return rest_facade.create_audit(program, auditors=second_creator)
Exemplo n.º 17
0
def audit(program):
    return rest_facade.create_audit(program)
Exemplo n.º 18
0
def audits(program):
    return [rest_facade.create_audit(program) for _ in xrange(2)]
Exemplo n.º 19
0
def audits(program):
  return [rest_facade.create_audit(program) for _ in xrange(2)]
Exemplo n.º 20
0
def audit(program):
  return rest_facade.create_audit(program)
Exemplo n.º 21
0
def audit(program):
  """Create an audit within program"""
  return rest_facade.create_audit(program)