-
Notifications
You must be signed in to change notification settings - Fork 429
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
fix: ensure SimpleFeatureStateViewSet uses correct permissions for segment overrides #2990
fix: ensure SimpleFeatureStateViewSet uses correct permissions for segment overrides #2990
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2990 +/- ##
==========================================
+ Coverage 95.56% 95.58% +0.01%
==========================================
Files 1014 1016 +2
Lines 29421 29526 +105
==========================================
+ Hits 28116 28222 +106
+ Misses 1305 1304 -1 ☔ View full report in Codecov by Sentry. |
|
||
def test_create_segment_override__using_simple_feature_state_viewset__allows_manage_segment_overrides( | ||
staff_client: APIClient, | ||
with_environment_permissions: Callable[[list[str], int], None], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with_environment_permissions: Callable[[list[str], int], None], | |
with_environment_permissions: Callable[[list[str]], None], |
Not precisely accurate but correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, technically, I guess it should be Callable[[list[str], int | None], None]
based on the definition:
@pytest.fixture()
def with_environment_permissions(
environment: Environment, staff_user: FFAdminUser
) -> typing.Callable[[list[str], int], None]:
"""
Add environment permissions to the staff_user fixture.
Defaults to associating to the environment fixture.
"""
def _with_environment_permissions(
permission_keys: list[str], environment_id: typing.Optional[int] = None
) -> UserEnvironmentPermission:
environment_id = environment_id or environment.id
uep, __ = UserEnvironmentPermission.objects.get_or_create(
environment_id=environment_id, user=staff_user
)
uep.permissions.add(*permission_keys)
return uep
return _with_environment_permissions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some typing nitpicks, otherwise LGTM
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingChanges
Fixes an issue found when testing the new MANAGE_SEGMENTS permission functionality. The FE uses the SimpleFeatureStateViewSet for updating segment overrides, which the new permission didn't cover. This PR ensures that this endpoint is correctly covered by the new permission for creating (although this is not used by the FE) and updating segment overrides via this API route.
How did you test this code?
Added new unit tests.