Skip to content

Commit

Permalink
test(core): correct project tests for triage user
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Sep 11, 2024
1 parent 63146aa commit 948713d
Showing 1 changed file with 59 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2114,14 +2114,14 @@ def test_field_permission_opened_by_triage_user_allowed(self):
assert response.status_code == 200


def test_field_permission_project_triage_user_allowed(self):
def test_field_permission_subscribed_teams_triage_user_allowed(self):
""" Check correct permission for add
A standard user should not be able to edit field project.
A standard user should not be able to edit field subscribed_teams.
"""

field_name: str = 'project'
field_value = self.project.id
field_name: str = 'subscribed_teams'
field_value = [1]


client = Client(raise_request_exception=True)
Expand All @@ -2141,14 +2141,17 @@ def test_field_permission_project_triage_user_allowed(self):
assert response.status_code == 200


def test_field_permission_subscribed_users_triage_user_allowed(self):
def test_field_permission_ticket_type_triage_user_denied(self):
""" Check correct permission for add
A standard user should not be able to edit field subscribed_users.
A standard user should not be able to edit field ticket_type.
"""

field_name: str = 'subscribed_users'
field_value = [1]
field_name: str = 'ticket_type'
field_value = int(Ticket.TicketType.REQUEST.value)

if self.ticket_type_enum == int(Ticket.TicketType.REQUEST.value):
field_value = int(Ticket.TicketType.INCIDENT.value)


client = Client(raise_request_exception=True)
Expand All @@ -2160,22 +2163,38 @@ def test_field_permission_subscribed_users_triage_user_allowed(self):

data[field_name] = field_value

response = client.post(
url,
data=data
)
try:

assert response.status_code == 200
response = client.post(
url,
data=data
)

assert False, 'a ValidationError exception should have been thrown'

def test_field_permission_subscribed_teams_triage_user_allowed(self):
except ValidationError as exception:

assert exception.code == 'cant_edit_field_' + field_name

except Exception as exception:

assert False, f"reason: {exception}"



class ITSMTicketFieldPermissionsTriageUser(
TicketFieldPermissionsTriageUser
):


def test_field_permission_project_triage_user_allowed(self):
""" Check correct permission for add
A standard user should not be able to edit field subscribed_teams.
A standard user should not be able to edit field project.
"""

field_name: str = 'subscribed_teams'
field_value = [1]
field_name: str = 'project'
field_value = self.project.id


client = Client(raise_request_exception=True)
Expand All @@ -2195,17 +2214,14 @@ def test_field_permission_subscribed_teams_triage_user_allowed(self):
assert response.status_code == 200


def test_field_permission_ticket_type_triage_user_denied(self):
def test_field_permission_planned_start_date_triage_user_denied(self):
""" Check correct permission for add
A standard user should not be able to edit field ticket_type.
A standard user should not be able to edit field planned_start_date.
"""

field_name: str = 'ticket_type'
field_value = int(Ticket.TicketType.REQUEST.value)

if self.ticket_type_enum == int(Ticket.TicketType.REQUEST.value):
field_value = int(Ticket.TicketType.INCIDENT.value)
field_name: str = 'planned_start_date'
field_value = '2024-09-08T13:19:00'


client = Client(raise_request_exception=True)
Expand Down Expand Up @@ -2235,19 +2251,13 @@ def test_field_permission_ticket_type_triage_user_denied(self):
assert False, f"reason: {exception}"



class ITSMTicketFieldPermissionsTriageUser(
TicketFieldPermissionsTriageUser
):


def test_field_permission_planned_start_date_triage_user_denied(self):
def test_field_permission_planned_finish_date_triage_user_denied(self):
""" Check correct permission for add
A standard user should not be able to edit field planned_start_date.
A standard user should not be able to edit field planned_finish_date.
"""

field_name: str = 'planned_start_date'
field_name: str = 'planned_finish_date'
field_value = '2024-09-08T13:19:00'


Expand Down Expand Up @@ -2278,13 +2288,13 @@ def test_field_permission_planned_start_date_triage_user_denied(self):
assert False, f"reason: {exception}"


def test_field_permission_planned_finish_date_triage_user_denied(self):
def test_field_permission_real_start_date_triage_user_denied(self):
""" Check correct permission for add
A standard user should not be able to edit field planned_finish_date.
A standard user should not be able to edit field real_start_date.
"""

field_name: str = 'planned_finish_date'
field_name: str = 'real_start_date'
field_value = '2024-09-08T13:19:00'


Expand Down Expand Up @@ -2315,13 +2325,13 @@ def test_field_permission_planned_finish_date_triage_user_denied(self):
assert False, f"reason: {exception}"


def test_field_permission_real_start_date_triage_user_denied(self):
def test_field_permission_real_finish_date_triage_user_denied(self):
""" Check correct permission for add
A standard user should not be able to edit field real_start_date.
A standard user should not be able to edit field real_finish_date.
"""

field_name: str = 'real_start_date'
field_name: str = 'real_finish_date'
field_value = '2024-09-08T13:19:00'


Expand Down Expand Up @@ -2352,14 +2362,20 @@ def test_field_permission_real_start_date_triage_user_denied(self):
assert False, f"reason: {exception}"


def test_field_permission_real_finish_date_triage_user_denied(self):

class ProjectTicketFieldPermissionsTriageUser(
TicketFieldPermissionsTriageUser
):


def test_field_permission_project_triage_user_denied(self):
""" Check correct permission for add
A standard user should not be able to edit field real_finish_date.
A standard user should not be able to edit field project.
"""

field_name: str = 'real_finish_date'
field_value = '2024-09-08T13:19:00'
field_name: str = 'project'
field_value = self.project.id


client = Client(raise_request_exception=True)
Expand Down Expand Up @@ -2389,12 +2405,6 @@ def test_field_permission_real_finish_date_triage_user_denied(self):
assert False, f"reason: {exception}"



class ProjectTicketFieldPermissionsTriageUser(
TicketFieldPermissionsTriageUser
):


def test_field_permission_planned_start_date_triage_user_allowed(self):
""" Check correct permission for add
Expand Down

0 comments on commit 948713d

Please sign in to comment.