Add stack slug to /organization endpoint response (#3644)

# What this PR does
Add stack slug to /organization endpoint response

## Which issue(s) this PR fixes
https://github.com/grafana/oncall-private/issues/2444
## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
This commit is contained in:
Yulya Artyukhina 2024-01-10 13:29:43 +01:00 committed by GitHub
parent 616d474e59
commit a7d441647e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View file

@ -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))
- Moved Mobile Connection Tab to separate user profile in Grafana ([#3296](https://github.com/grafana/oncall/pull/3296)
### Fixed

View file

@ -31,11 +31,13 @@ class OrganizationSerializer(EagerLoadingMixin, serializers.ModelSerializer):
fields = [
"pk",
"name",
"stack_slug",
"slack_team_identity",
"slack_channel",
"rbac_enabled",
]
read_only_fields = [
"stack_slug",
"slack_team_identity",
"rbac_enabled",
]

View file

@ -8,6 +8,48 @@ from rest_framework.response import Response
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