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

feat: Add permission for manage segments overrides #2919

Merged
merged 23 commits into from
Nov 14, 2023

Conversation

zachaysan
Copy link
Contributor

@zachaysan zachaysan commented Nov 2, 2023

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Segment overrides allows release of a specific feature to broader set of users, with this change Flagsmith users are able to have a specialized permission for managing segment overrides as an environment role. See this for more information.

Most of the work in this PR involved trying to understand the surrounding approach and replace permission checks as needed.

I also added django_extensions for local development ergonomics as well.

How did you test this code?

I relied on the existing tests, following the convention of relying on admin_master_api_key_client, but this means that we're not really testing the new permission since it's an admin api key, not a user with the permission.

I would like to test this locally with the interface to verify that the permission checks work properly, but I'm opening the PR first to get feedback before setting that all up.

I have fully tested this code through a locally running webserver and caught and debugged a few small issues. This PR must wait for merge until the frontend is ready.

Copy link

vercel bot commented Nov 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2023 3:27pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2023 3:27pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2023 3:27pm

@github-actions github-actions bot added the api Issue related to the REST API label Nov 2, 2023
Copy link
Contributor

github-actions bot commented Nov 2, 2023

Uffizzi Preview deployment-40008 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (b18e4a6) 95.54% compared to head (f49a46d) 95.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2919      +/-   ##
==========================================
+ Coverage   95.54%   95.56%   +0.01%     
==========================================
  Files        1012     1013       +1     
  Lines       29329    29419      +90     
==========================================
+ Hits        28023    28114      +91     
+ Misses       1306     1305       -1     
Files Coverage Δ
api/conftest.py 98.87% <100.00%> (+0.03%) ⬆️
...environments/migrations/0010_auto_20200219_2343.py 100.00% <100.00%> (ø)
api/environments/permissions/constants.py 100.00% <100.00%> (ø)
api/features/feature_segments/permissions.py 90.00% <100.00%> (ø)
api/features/feature_segments/serializers.py 95.58% <100.00%> (ø)
api/features/feature_segments/tests/test_views.py 100.00% <100.00%> (ø)
api/features/feature_segments/views.py 97.77% <ø> (ø)
api/features/permissions.py 86.04% <100.00%> (+3.69%) ⬆️
api/features/tests/test_views.py 100.00% <100.00%> (ø)
api/features/views.py 86.49% <100.00%> (ø)
... and 4 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see a couple more tests here - perhaps just some unit test coverage of the permission class, or an API test with a user that has the correct permission.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor tweak to a copypasta error. It would also be good to add some typing to the test fixtures 🙏

@zachaysan zachaysan changed the title feat: Add permission for manage segments overrides feat: DO NOT MERGE BLOCKED BY FRONTEND Add permission for manage segments overrides Nov 13, 2023
@zachaysan zachaysan changed the title feat: DO NOT MERGE BLOCKED BY FRONTEND Add permission for manage segments overrides feat: (DO NOT MERGE) Add permission for manage segments overrides Nov 13, 2023
@zachaysan zachaysan changed the title feat: (DO NOT MERGE) Add permission for manage segments overrides feat: Add permission for manage segments overrides Nov 14, 2023
@zachaysan zachaysan added this pull request to the merge queue Nov 14, 2023
Merged via the queue into main with commit 716f6a9 Nov 14, 2023
@zachaysan zachaysan deleted the feat/add_permission_for_manage_segments_overrides branch November 14, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants