Exemple #1
0
 def test_destructive_obj_count(self, selenium):
     """Checks if count updates in LHN after creating new program."""
     selenium_utils.open_url(url.Urls().dashboard)
     count_before = dashboard.Header(selenium).open_lhn_menu(
     ).select_my_objects().toggle_programs.members_count
     rest_facade.create_program()
     selenium.refresh()
     count_after = dashboard.Header(selenium).open_lhn_menu(
     ).select_my_objects().toggle_programs.members_count
     assert count_after == count_before + 1
Exemple #2
0
 def test_permissions(self, users_with_all_roles, login_role, can_view,
                      can_edit, selenium):  # pylint: disable=too-many-arguments
     """Test that users have permissions to objects created by other users
 according to their global role.
 """
     objs = []
     other_roles = [role for role in self.ALL_ROLES if role != login_role]
     for role in other_roles:
         users.set_current_user(users_with_all_roles[role])
         program = rest_facade.create_program()
         control = rest_facade.create_control_mapped_to_program(program)
         objs.extend([program, control])
     users.set_current_user(users_with_all_roles[login_role])
     for obj in objs:
         if can_view:
             webui_facade.assert_can_view(selenium, obj)
             if obj.type == "Control":
                 webui_facade.assert_can_edit_control(
                     selenium, obj, can_edit)
                 webui_facade.assert_cannot_delete_control(selenium, obj)
             else:
                 webui_facade.assert_can_edit(selenium,
                                              obj,
                                              can_edit=can_edit)
                 webui_facade.assert_can_delete(selenium,
                                                obj,
                                                can_delete=can_edit)
         else:
             webui_facade.assert_cannot_view(obj)
Exemple #3
0
 def test_permissions(
     self, users_with_all_roles, login_role, can_view, can_edit, selenium
 ):  # pylint: disable=too-many-arguments
   """Test that users have permissions to objects created by other users
   according to their global role.
   """
   objs = []
   other_roles = [role for role in self.ALL_ROLES if role != login_role]
   for role in other_roles:
     users.set_current_user(users_with_all_roles[role])
     program = rest_facade.create_program()
     control = rest_facade.create_control_mapped_to_program(program)
     objs.extend([program, control])
   users.set_current_user(users_with_all_roles[login_role])
   for obj in objs:
     if can_view:
       webui_facade.assert_can_view(selenium, obj)
       if obj.type == "Control":
         webui_facade.assert_can_edit_control(selenium, obj, can_edit)
         webui_facade.assert_cannot_delete_control(selenium, obj)
       else:
         webui_facade.assert_can_edit(selenium, obj, can_edit=can_edit)
         webui_facade.assert_can_delete(selenium, obj, can_delete=can_edit)
     else:
       webui_facade.assert_cannot_view(obj)
 def program_with_assigned_reviewer(self):
     """Creates program with assigned review.
 Returns program and reviewer person."""
     reviewer = rest_facade.create_user_with_role(roles.CREATOR)
     users.set_current_user(rest_facade.create_user_with_role(
         roles.CREATOR))
     program_with_review = rest_service.ReviewService().request_review(
         rest_facade.create_program(), reviewer)
     return {"program": program_with_review, "reviewer": reviewer}
Exemple #5
0
 def test_object_creation(self, role, selenium):
     """Test that users with all global roles can create, then edit and delete
 objects.
 """
     user = rest_facade.create_user_with_role(role_name=role)
     users.set_current_user(user)
     objs = [rest_facade.create_program(), rest_facade.create_control()]
     for obj in objs:
         webui_facade.assert_can_edit(selenium, obj, can_edit=True)
         webui_facade.assert_can_delete(selenium, obj, can_delete=True)
Exemple #6
0
 def test_object_creation(self, role, selenium):
   """Test that users with all global roles can create, then edit and delete
   objects.
   """
   user = rest_facade.create_user_with_role(role_name=role)
   users.set_current_user(user)
   objs = [rest_facade.create_program(), rest_facade.create_control()]
   for obj in objs:
     webui_facade.assert_can_edit(selenium, obj, can_edit=True)
     webui_facade.assert_can_delete(selenium, obj, can_delete=True)
 def test_add_program_reviewer(self, selenium):
     """Confirm reviewer is displayed on Program Info panel."""
     creator = rest_facade.create_user_with_role(roles.CREATOR)
     reviewer = rest_facade.create_user_with_role(roles.CREATOR)
     users.set_current_user(creator)
     expected_program = rest_facade.create_program()
     webui_facade.submit_obj_for_review(selenium, expected_program,
                                        reviewer)
     actual_program = webui_facade.get_object(selenium, expected_program)
     expected_program.update_attrs(reviewers=[reviewer.email])
     assert expected_program.repr_ui() == actual_program
 def test_request_obj_review(self, selenium):
     """Confirm reviewer is displayed on Program Info panel."""
     reviewer = rest_facade.create_user_with_role(roles.CREATOR)
     users.set_current_user(rest_facade.create_user_with_role(
         roles.CREATOR))
     program = rest_facade.create_program()
     webui_facade.submit_obj_for_review(selenium, program, reviewer.email)
     actual_program = webui_facade.get_object(selenium, program)
     program.update_attrs(
         review={
             "status": ReviewStates.UNREVIEWED,
             "reviewers": [reviewer.email],
             "last_reviewed_by": ""
         })
     self.general_equal_assert(program.repr_ui(), actual_program)
Exemple #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
   }
Exemple #10
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
     }
 def test_data(self, obj_reader_role, selenium):
     """Create 2 GC users.
 GC 1 creates object and adds GC 2 as a object reader.
 """
     if not self.__class__._data:
         obj_creator = rest_facade.create_user_with_role(roles.CREATOR)
         proposal_creator = rest_facade.create_user_with_role(roles.CREATOR)
         global_reader = rest_facade.create_user_with_role(roles.READER)
         users.set_current_user(obj_creator)
         obj_custom_roles = [(obj_reader_role.name, obj_reader_role.id,
                              [proposal_creator])]
         obj = rest_facade.create_program(custom_roles=obj_custom_roles)
         users.set_current_user(proposal_creator)
         proposal_to_apply = proposal_ui_facade.create_proposal(
             selenium, obj)
         proposal_to_apply.datetime = (
             proposal_rest_service.ProposalsService(
             ).get_proposal_creation_date(obj, proposal_to_apply))
         proposal_to_decline = proposal_ui_facade.create_proposal(
             selenium, obj)
         proposal_to_decline.datetime = (
             proposal_rest_service.ProposalsService(
             ).get_proposal_creation_date(obj, proposal_to_decline))
         users.set_current_user(global_reader)
         proposal_from_gr = proposal_ui_facade.create_proposal(
             selenium, obj)
         proposal_from_gr.datetime = (
             proposal_rest_service.ProposalsService(
             ).get_proposal_creation_date(obj, proposal_from_gr))
         self.__class__._data = {
             "obj_creator": obj_creator,
             "proposal_creator": proposal_creator,
             "global_reader": global_reader,
             "obj": obj,
             "proposal_to_apply": proposal_to_apply,
             "proposal_to_decline": proposal_to_decline,
             "proposal_from_gr": proposal_from_gr
         }
     return self.__class__._data
def program():
    return rest_facade.create_program()
Exemple #13
0
def program():
  return rest_facade.create_program()
Exemple #14
0
def program():
  """Create a program"""
  return rest_facade.create_program()
Exemple #15
0
def program():
    """Create a program."""
    return rest_facade.create_program()
Exemple #16
0
def programs():
    """Create a program."""
    return [rest_facade.create_program() for _ in xrange(2)]
Exemple #17
0
def programs():
  """Create a program"""
  return [rest_facade.create_program() for _ in xrange(2)]