8000 Unit tests for the check method in PermissionsService · Issue #595 · gitroomhq/postiz-app · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Unit tests for the check method in PermissionsService #595

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

Closed
1 task done
rafgpereira opened this issue Feb 7, 2025 · 1 comment
Closed
1 task done

Unit tests for the check method in PermissionsService #595

rafgpereira opened this issue Feb 7, 2025 · 1 comment
Labels
type: feature-request New feature or request

Comments

@rafgpereira
Copy link

🔖 Feature description

This issue aims to implement unit tests for the “check” method of the PermissionsService class, using Jest with coverage reporting generation. The method is central to defining authorization rules and covers several permission validation scenarios. Due to its complexity, it is essential to test all conditions and flows to ensure the robustness of the system.

🎤 Why is this feature needed ?

  • The “check” method determines access based on multiple parameters and rules, such as checking limits (number of channels, posts per month, webhooks) and special permissions (ADMIN, SUPERADMIN, etc.).
  • Lack of testing can cause failures in validating permissions, leading to security problems and the introduction of bugs in future changes or refactorings.
  • Covering logic flows with unit tests will allow for early detection of regressions and ensure that future changes do not compromise the integrity of the system.
    Implementation with Jest integrating a code coverage threshold (through CI) will ensure a minimum level of quality and reliability in the code.
  • Implementation with Jest integrating a code coverage threshold (through CI) will ensure a minimum level of quality and reliability in the code.

✌️ How do you aim to achieve this?

  • Create scenarios where the list of requested permissions is empty or when the STRIPE_PUBLISHABLE_KEY variable is not defined, to validate the initial flow of the method.
    Simulate cases for each condition evaluated:
  • CHANNEL: Check the channel count and whether validation logic (using options and the integration signature) is applied correctly.
  • WEBHOOKS: Simulate conditions where the total number of webhooks is less than the limit defined in the options.
  • POSTS_PER_MONTH: Test the post count based on a base date and comparison with the monthly limit.
  • TEAM_MEMBERS, ADMIN, COMMUNITY_FEATURES, FEATURED_BY_GITROOM, AI and IMPORT_FROM_CHANNELS: Analyze whether the permission logic is correctly triggered according to specific conditions.
  • Generate coverage reports:
    Configure Jest to run with the coverage flag, ensuring that all “check” method routes are exercised.

🔄️ Additional Information

Implementing these tests not only improves the reliability of the permissions system but also encourages a culture of testing in the project, facilitating early detection of failures and community collaboration for future improvements.

👀 Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

Yes I am willing to submit a PR!

@rafgpereira rafgpereira added the type: feature-request New feature or request label Feb 7, 2025
@egelhaus egelhaus linked a pull request Feb 7, 2025 that will close this issue
3 tasks
@egelhaus egelhaus closed this as completed May 5, 2025
@egelhaus
Copy link
Collaborator
egelhaus commented May 5, 2025

Has been implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants
0