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

einhaltung der abhängigkeiten vorfälle service #1042

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

Conversation

vjohnslhm
Copy link
Contributor

@vjohnslhm vjohnslhm commented Mar 14, 2025

Beschreibung:

  • rule zur einhaltung der ahängigkeiten eingefügt
  • rule violations gefixed

Definition of Done (DoD):

Backend

Referenzen1:

Closes #1010

Summary by CodeRabbit

  • Refactor

    • Reorganized security components to streamline integration with external identity providers.
    • Updated package declarations for UserInfoAuthoritiesService and its test to reflect a more logical structure within the security context.
  • Tests

    • Expanded architectural validations to ensure improved consistency and robustness in service behavior.
    • Introduced new tests to verify architectural rules for classes without tests.

These behind-the-scenes improvements enhance system maintainability and reliability without altering any user-facing functionality.

Footnotes

  1. Nicht zutreffende Referenzen vor dem Speichern entfernen

Copy link
Contributor

coderabbitai bot commented Mar 14, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes update the security-related components of the project by reorganizing the package structure and incorporating a user authority service. The UserInfoAuthoritiesService is moved from a configuration package to a dedicated security service package. Corresponding import statements are added to both the JwtUserInfoAuthenticationConverter and SecurityConfiguration classes, enabling them to reference this service for user authority retrieval from an OIDC provider. Additionally, the architectural testing suite is expanded with a new static variable and parameterized test method to enforce architectural rules for non-test classes. These modifications prepare the project for improved security service integration and enhanced architectural compliance checks without altering the underlying business logic.


Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or `` to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or `` anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
wls-vorfaelleundvorkommnisse-service/src/test/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/archunit/ArchUnitTest.java (1)

73-100: Inconsistent access modifier for rule provider method

I noticed that allClassesWithoutTestsRulesToVerify() is declared as public while allClassesRulesToVerify() on line 65 is private. Consider using consistent access modifiers unless there's a specific reason for the difference.

-    public static Stream<Arguments> allClassesWithoutTestsRulesToVerify() {
+    private static Stream<Arguments> allClassesWithoutTestsRulesToVerify() {
wls-vorfaelleundvorkommnisse-service/src/test/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/service/security/UserInfoAuthoritiesServiceTest.java (1)

110-111: Minor Typo in Variable Name:
The variable name "expctedAuthorities" appears to be misspelled. Renaming it to "expectedAuthorities" would improve readability and consistency with naming conventions.

wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/configuration/SecurityConfiguration.java (1)

57-60: Consider Leveraging Dependency Injection for UserInfoAuthoritiesService

Currently, the code instantiates UserInfoAuthoritiesService directly within the JwtUserInfoAuthenticationConverter constructor. To fully benefit from Spring's dependency injection (including lifecycle management, proxy support, and easier testing), consider defining UserInfoAuthoritiesService as a Spring bean and then injecting it. For example, you might add a bean definition as follows:

+    @Bean
+    public UserInfoAuthoritiesService userInfoAuthoritiesService() {
+         return new UserInfoAuthoritiesService(userInfoUri, restTemplateBuilder);
+    }

And update the converter instantiation:

-    new JwtUserInfoAuthenticationConverter(new UserInfoAuthoritiesService(userInfoUri, restTemplateBuilder))
+    new JwtUserInfoAuthenticationConverter(userInfoAuthoritiesService())

This refactor will help maintain cleaner dependency management and adhere even more closely to the project’s architectural rules.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f03805f and 5df1835.

📒 Files selected for processing (5)
  • wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/configuration/JwtUserInfoAuthenticationConverter.java (1 hunks)
  • wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/configuration/SecurityConfiguration.java (1 hunks)
  • wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/service/security/UserInfoAuthoritiesService.java (1 hunks)
  • wls-vorfaelleundvorkommnisse-service/src/test/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/archunit/ArchUnitTest.java (4 hunks)
  • wls-vorfaelleundvorkommnisse-service/src/test/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/service/security/UserInfoAuthoritiesServiceTest.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/configuration/JwtUserInfoAuthenticationConverter.java (2)
Learnt from: MrSebastian
PR: it-at-m/Wahllokalsystem#603
File: wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/configuration/JwtUserInfoAuthenticationConverter.java:27-29
Timestamp: 2025-03-14T05:04:11.799Z
Learning: In the `JwtUserInfoAuthenticationConverter` class (`wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/configuration/JwtUserInfoAuthenticationConverter.java`), null checks for the `Jwt` parameter in the `convert(Jwt source)` method are unnecessary because the `Converter` interface specifies that the `source` parameter is never null.
Learnt from: MrSebastian
PR: it-at-m/Wahllokalsystem#603
File: wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/configuration/JwtUserInfoAuthenticationConverter.java:27-29
Timestamp: 2025-03-14T05:03:56.221Z
Learning: In the `JwtUserInfoAuthenticationConverter` class, the method `UserService.getUserDetails(String subject)` throws an exception if the user is not found and does not return null. Therefore, checking for a null `userDetails` is unnecessary.
🔇 Additional comments (9)
wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/configuration/JwtUserInfoAuthenticationConverter.java (2)

7-7: Updated Dependency Import Correctly

The import now fetches UserInfoAuthoritiesService from the service.security package, which aligns with the new dependency management rule and improved architectural grouping. Please ensure that the package path is correct and that all affected modules are updated accordingly.


32-35: Effective Use of the New Authority Service

The convert method is cleanly updated to call this.userInfoService.loadAuthorities(source) when constructing the JwtAuthenticationToken. This leverages the new service as intended and correctly omits any unnecessary null checks, in accordance with the guidance from previous learnings.

wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/service/security/UserInfoAuthoritiesService.java (1)

5-5: Updated Package Declaration is Correctly Implemented

The package declaration has been updated to reflect the new security service context:

package de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice.service.security;

This change aligns with the project naming conventions and supports the architectural reorganization described in the PR objectives. Please ensure that all files importing this class (e.g., JwtUserInfoAuthenticationConverter.java, SecurityConfiguration.java, and the corresponding test file) have been updated to use the new package.

wls-vorfaelleundvorkommnisse-service/src/test/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/archunit/ArchUnitTest.java (4)

21-22: Nice addition of the filter for non-test classes

The addition of allClassesWithoutTests and ignoreGeneratedCode provides a clean way to focus architectural rule validation specifically on production code while excluding test classes and generated code.


33-36: Good implementation of the ClassFileImporter

The configuration for the non-test classes importer follows the established pattern in the file and correctly applies both import options to filter out test classes and generated code.


51-55: Well-structured test method for non-test classes

The parameterized test method is appropriately named and implemented consistently with the existing test methods in the class.


73-100: Comprehensive set of architectural rules

The implementation includes a well-organized set of rules categorized by architectural layers (REST, service, domain). This comprehensive coverage will help maintain clear architectural boundaries in the codebase, which aligns with the PR objective of adding dependency management rules.

wls-vorfaelleundvorkommnisse-service/src/test/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/service/security/UserInfoAuthoritiesServiceTest.java (1)

1-1: Update of Package Declaration:
The package declaration has been updated to reflect the new reorganization — moving the security-related service from the configuration package to the service.security package. This change aligns well with the PR objectives on dependency management and architectural clarity.

wls-vorfaelleundvorkommnisse-service/src/main/java/de/muenchen/oss/wahllokalsystem/vorfaelleundvorkommnisseservice/configuration/SecurityConfiguration.java (1)

7-7: New Service Import Reflects Package Reorganization

The added import for UserInfoAuthoritiesService confirms the migration to the dedicated service package, aligning well with the dependency management and architectural guidelines specified in the PR objectives.

@vjohnslhm vjohnslhm changed the title #1010 add archrule + fix violations einhaltung der abhängigkeiten vorfälle service Mar 14, 2025
@dragonfly28 dragonfly28 self-requested a review March 14, 2025 12:32
Copy link
Contributor

@dragonfly28 dragonfly28 Mar 14, 2025

Choose a reason for hiding this comment

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

Warum wurde der hierher verschoben? Ist ja eigentlich kein "normaler" Service mit @Service Annotation und wird auch nicht vom Controller verwendet. Vielleicht würde es Sinn machen diese Klasse in "UserInfoAuthoritiesProvider" umzubenennen - das Problem haben wir nämlich bei anderen Services auch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hab in dem MR das gleiche problem gehabt. Hatte damals mit @MrSebastian besprochen, dass wir es in den Service-Ordner schieben. Die idee mit Provider statt Service find ich auch nicht schelcht. Für mich passt beides, hauptsache einheitlich. @MrSebastian, da wir es besprochen hatten, was ist deine Meinung?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vorfälle und Vorkomnisse-Service - Einhaltung der Abhängigkeiten
3 participants