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

Add stack slug to /organization endpoint response #3644

Merged
merged 4 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Do not retry `firebase.messaging.UnregisteredError` exceptions for FCM relay tasks by @joeyorlando ([#3637](https://github.com/grafana/oncall/pull/3637))
- Decrease outgoing webhook timeouts from 10secs to 4secs by @joeyorlando ([#3639](https://github.com/grafana/oncall/pull/3639))
- Add stack slug to `/organization` endpoint response by @Ferril ([#3644](https://github.com/grafana/oncall/pull/3644))

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions engine/apps/api/serializers/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ class Meta:
fields = [
"pk",
"name",
"stack_slug",
"slack_team_identity",
"slack_channel",
"rbac_enabled",
]
read_only_fields = [
"stack_slug",
"slack_team_identity",
"rbac_enabled",
]
Expand Down
42 changes: 42 additions & 0 deletions engine/apps/api/tests/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,48 @@
from rest_framework.test import APIClient

from apps.api.permissions import LegacyAccessControlRole
from apps.api.serializers.organization import CurrentOrganizationSerializer

mock_banner = {"title": None, "body": None}
mock_env_status = {
"telegram_configured": False,
"phone_provider": {
"configured": False,
"test_sms": False,
"test_call": False,
"verification_call": False,
"verification_sms": False,
},
}


@patch.object(CurrentOrganizationSerializer, "get_banner", return_value=mock_banner)
@patch.object(CurrentOrganizationSerializer, "get_env_status", return_value=mock_env_status)
@pytest.mark.django_db
def test_get_organization(
mocked_banner,
mocked_env_status,
make_organization_and_user_with_plugin_token,
make_user_auth_headers,
):
organization, user, token = make_organization_and_user_with_plugin_token()

client = APIClient()
url = reverse("api-internal:api-organization")
expected_result = {
"pk": organization.public_primary_key,
"name": organization.org_title,
"stack_slug": organization.stack_slug,
"slack_team_identity": None,
"slack_channel": None,
"rbac_enabled": organization.is_rbac_permissions_enabled,
"is_resolution_note_required": False,
"env_status": mock_env_status,
"banner": mock_banner,
}
response = client.get(url, format="json", **make_user_auth_headers(user, token))
assert response.status_code == status.HTTP_200_OK
assert response.json() == expected_result


@pytest.mark.django_db
Expand Down
Loading