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: Enhance feature segment permissions with tag validation #5192

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

francescolofranco
Copy link

@francescolofranco francescolofranco commented Mar 5, 2025

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

  • I have added information to docs/ if required so people know about the feature!
  • 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

This PR partially enables a check against tags for the management of segments overrides. Testing is limited as this would require the settings.IS_RBAC_INSTALLED to be true, forcing it in tests causes an obvious error.

What remains to do is some additional testing, I think.

How did you test this code?

Added a couple of automated tests, which are not really checking much of the logic, since rbac repo is needed for this.

More info

I'm afraid this PR is only partial as to fully complete this work I would need access to the private rbac repo. This PR also requires the addition of the MANAGE_SEGMENT_OVERRIDES permission to the TAG_SUPPORTED_PERMISSIONS in the common repo. PR -> Flagsmith/flagsmith-common#14

@github-actions github-actions bot added the api Issue related to the REST API label Mar 5, 2025
Copy link

vercel bot commented Mar 5, 2025

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2025 11:42am
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2025 11:42am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2025 11:42am

Copy link

vercel bot commented Mar 5, 2025

@pre-commit-ci[bot] is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@francescolofranco francescolofranco marked this pull request as ready for review March 5, 2025 21:16
@francescolofranco francescolofranco requested a review from a team as a code owner March 5, 2025 21:16
@francescolofranco francescolofranco requested review from matthewelwell and removed request for a team March 5, 2025 21:16
Copy link
Contributor

github-actions bot commented Mar 5, 2025

Uffizzi Ephemeral Environment deployment-61589

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/5192

📄 View Application Logs etc.

What is Uffizzi? Learn more!

Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 99.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.50%. Comparing base (647712c) to head (d0aca97).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
api/features/permissions.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5192      +/-   ##
==========================================
+ Coverage   97.49%   97.50%   +0.01%     
==========================================
  Files        1223     1225       +2     
  Lines       42581    42723     +142     
==========================================
+ Hits        41516    41659     +143     
+ Misses       1065     1064       -1     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Thanks @francescolofranco. I've added a couple of suggestions for code improvements, but on the whole, I think it looks good. I've also approved the linked PR in the flagsmith-common repository which we'll need to release and bump the version of here before release.

Regarding the RBAC repository, I think there are no changes actually needed. Your comment about testing though is a good one, I'm not sure how we've handled this so far - perhaps @gagantrivedi knows? Based on the testing in the RBAC repo though, I suggest we can get away with the testing you've already added here @francescolofranco. Perhaps, if we wanted to go slightly further, we could mock the call to the function in the rbac_wrapper module and verify that the tags are being correctly passed?

Copy link
Author

@francescolofranco francescolofranco left a comment

Choose a reason for hiding this comment

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

I'm interested in knowing how do you feel about these types of tests -> d0aca97 ?

I know this is a diversion from the usual way of testing in this project, so I'm ok if you decide to discard this commit.

If you find those useful, I can also cover the CreateSegmentOverridePermissions, just let me know 🙏🏻

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.

2 participants