Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert requiring permission on Slack direct paging #3881

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed

- Revert requiring permission on Slack direct paging ([#3881](https://github.com/grafana/oncall/pull/3881))

## v1.3.103 (2024-02-12)

### Added
Expand Down
10 changes: 0 additions & 10 deletions engine/apps/slack/scenarios/paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ def process_scenario(
slack_team_identity: "SlackTeamIdentity",
payload: EventPayload,
) -> None:
if not self.is_authorized():
self.open_unauthorized_warning(payload)
return

input_id_prefix = _generate_input_id_prefix()

try:
Expand All @@ -151,18 +147,12 @@ def process_scenario(
class FinishDirectPaging(scenario_step.ScenarioStep):
"""Handle page command dialog submit."""

REQUIRED_PERMISSIONS = [RBACPermission.Permissions.ALERT_GROUPS_DIRECT_PAGING]

def process_scenario(
self,
slack_user_identity: "SlackUserIdentity",
slack_team_identity: "SlackTeamIdentity",
payload: EventPayload,
) -> None:
if not self.is_authorized():
self.open_unauthorized_warning(payload)
return

message = _get_message_from_payload(payload)
private_metadata = json.loads(payload["view"]["private_metadata"])
channel_id = private_metadata["channel_id"]
Expand Down
29 changes: 0 additions & 29 deletions engine/apps/slack/tests/test_scenario_steps/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.utils import timezone

from apps.alerts.models import AlertReceiveChannel
from apps.api.permissions import LegacyAccessControlRole
from apps.schedules.models import CustomOnCallShift, OnCallScheduleWeb
from apps.slack.scenarios.paging import (
DIRECT_PAGING_MESSAGE_INPUT_ID,
Expand Down Expand Up @@ -76,19 +75,6 @@ def test_initial_state(
assert metadata[DataKey.USERS] == {}


@pytest.mark.parametrize("role", (LegacyAccessControlRole.VIEWER, LegacyAccessControlRole.NONE))
@pytest.mark.django_db
def test_initial_unauthorized(make_organization_and_user_with_slack_identities, role):
_, user, slack_team_identity, slack_user_identity = make_organization_and_user_with_slack_identities(role=role)
payload = {"channel_id": "123", "trigger_id": "111"}

step = StartDirectPaging(slack_team_identity, user=user)
with patch.object(step, "open_unauthorized_warning") as mock_open_unauthorized_warning:
step.process_scenario(slack_user_identity, slack_team_identity, payload)

mock_open_unauthorized_warning.assert_called_once()


@pytest.mark.django_db
def test_add_user_no_warning(make_organization_and_user_with_slack_identities, make_schedule, make_on_call_shift):
organization, user, slack_team_identity, slack_user_identity = make_organization_and_user_with_slack_identities()
Expand Down Expand Up @@ -245,21 +231,6 @@ def test_trigger_paging_no_team_or_user_selected(make_organization_and_user_with
)


@pytest.mark.parametrize("role", (LegacyAccessControlRole.VIEWER, LegacyAccessControlRole.NONE))
@pytest.mark.django_db
def test_trigger_paging_unauthorized(make_organization_and_user_with_slack_identities, role):
organization, user, slack_team_identity, slack_user_identity = make_organization_and_user_with_slack_identities(
role=role
)
payload = make_slack_payload(organization=organization)

step = FinishDirectPaging(slack_team_identity, user=user)
with patch.object(step, "open_unauthorized_warning") as mock_open_unauthorized_warning:
step.process_scenario(slack_user_identity, slack_team_identity, payload)

mock_open_unauthorized_warning.assert_called_once()


@pytest.mark.django_db
def test_trigger_paging_additional_responders(make_organization_and_user_with_slack_identities, make_team):
organization, user, slack_team_identity, slack_user_identity = make_organization_and_user_with_slack_identities()
Expand Down
Loading