Skip to content

Replace partyId with partyUuid for systemuser #1405

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

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

Conversation

mgunnerud
Copy link
Contributor

@mgunnerud mgunnerud commented Apr 9, 2025

Description

  • We should use uuid for party instead of int
  • Remove some occurences where the same partyUuid in route would be set twice

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • Refactor

    • Standardized party identifiers across backend APIs and UI components by switching from integer types to GUIDs.
    • Removed redundant parameters to simplify endpoint signatures and improve consistency.
    • Updated variable retrieval in UI components to use AltinnPartyUuid instead of AltinnPartyId.
  • Tests

    • Updated test methods to reflect the new GUID-based party identifiers.
    • Modified test data to utilize the new UUID format for party identifiers.
  • Chore

    • Enhanced test setup to include both AltinnPartyId and AltinnPartyUuid cookies for consistency.

These improvements enhance type safety, streamline API interactions, and simplify system user management.

Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

📝 Walkthrough

Walkthrough

The changes update many API interfaces, services, clients, controllers, and UI components by replacing the integer-based party identifiers with GUIDs. Redundant parameters such as facilitatorId and partyUuid have been removed from method signatures and service calls. In addition, JSON test data and cookie key lookups have been revised to reflect the new GUID values. Overall, the modifications standardize party identification across the codebase.

Changes

File(s) Change Summary
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/ClientInterfaces/ISystemUserAgentDelegationClient.cs, .../ISystemUserAgentRequestClient.cs, .../ISystemUserChangeRequestClient.cs, .../ISystemUserClient.cs, .../ISystemUserRequestClient.cs Changed partyId parameter from int to Guid; removed facilitatorId where applicable; updated documentation.
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Models/SystemUser/AgentDelegationRequest.cs Removed the FacilitatorId property.
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Services/Interfaces/* (e.g., ISystemUserAgentDelegationService.cs, ISystemUserAgentRequestService.cs, ISystemUserChangeRequestService.cs, ISystemUserRequestService.cs, ISystemUserService.cs) Updated method signatures to use Guid for partyId and removed redundant partyUuid parameters.
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Services/* (e.g., SystemUserAgentDelegationService.cs, SystemUserAgentRequestService.cs, SystemUserChangeRequestService.cs, SystemUserRequestService.cs, SystemUserService.cs) Adjusted implementations to pass Guid for partyId; removed unnecessary parameters such as partyUuid and facilitatorId in service calls.
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Integration/Clients/* (e.g., SystemUserAgentDelegationClient.cs, SystemUserAgentRequestClient.cs, SystemUserChangeRequestClient.cs, SystemUserClient.cs, SystemUserRequestClient.cs) Updated HTTP client method signatures to accept Guid for partyId and removed facilitatorId from endpoints and parameters.
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Mocks/Mocks/* (e.g., SystemUserAgentDelegationClientMock.cs, SystemUserAgentRequestClientMock.cs, SystemUserChangeRequestClientMock.cs, SystemUserClientMock.cs, SystemUserRequestClientMock.cs) Standardized method parameter types from int to Guid and removed redundant parameters.
JSON files in .../UI.Mocks/Data/SystemUser/* and .../UI.Tests/Data/ExpectedResults/SystemUser/* Updated partyId or partyOrgNo values from "51329012" to "cd35779b-b174-4ecc-bbef-ece13611be7f".
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI/Controllers/* (e.g., SystemUserAgentDelegationController.cs, SystemUserAgentRequestController.cs, SystemUserChangeRequestController.cs, SystemUserController.cs, SystemUserRequestController.cs) Modified API endpoint parameters to use Guid for partyId and removed the partyUuid and facilitatorId parameters.
UI components in src/features/amUI/systemUser/* (e.g., CreateSystemUserPage, SystemUserAgentDelegationPage, SystemUserDetailsPage, SystemUserRequestPage, SystemUsersOverviewPage) Changed cookie retrieval from 'AltinnPartyId' to 'AltinnPartyUuid' and removed usages of partyUuid in API calls.
src/rtk/features/systemUserApi.ts Removed the partyUuid field from mutation and query parameters, now relying only on partyId and other essential identifiers.

Possibly related PRs

  • Add endpoint for delete agent system user #1370: The changes in the main PR, which involve modifying method signatures in the ISystemUserAgentDelegationClient interface, are related to the changes in the retrieved PR that adds a new method for deleting an agent system user in the ISystemUserClient interface, as both involve modifications to the partyId parameter type from int to Guid in their respective methods.
  • Send partyUuid as query param instead of looking up partyuuid from partyid in registry #1389: The changes in the main PR, which involve modifying method signatures to replace int with Guid for the partyId parameter and removing the facilitatorId, are related to the retrieved PR, which also discusses the transition to using partyUuid instead of looking up partyId, indicating a direct connection in the context of parameter handling and method signatures.
  • Add endpoints for customer delegation to agent systemuser  #1347: The changes in the main PR, which involve modifying method signatures in the ISystemUserAgentDelegationClient interface, are related to the changes in the retrieved PR, which introduces a new interface ISystemUserAgentDelegationClient with similar method signatures for managing agent delegations. Both PRs focus on the same methods and parameters, specifically concerning the partyId and systemUserGuid.

Suggested labels

kind/bug, bugfix

Poem

In our code, numbers take their leave,
GUIDs now sparkle and beautifully weave.
Redundant tokens vanish into the night,
Our APIs now gleam with type-safe light.
A cleaner path for parties we embrace,
Code sings a rhythmic, robust grace.
🚀✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b40894 and d0496ef.

📒 Files selected for processing (1)
  • tests/setupTests.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/setupTests.ts (1)
tests/consts.ts (2)
  • TEST_PARTY_ID (2-2)
  • TEST_PARTY_UUID (3-3)
🪛 GitHub Check: CodeQL
tests/setupTests.ts

[warning] 42-42: Clear text transmission of sensitive cookie
Sensitive cookie sent without enforcing SSL encryption.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Continous Integration / Analyze
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (1)
tests/setupTests.ts (1)

7-7: Import for UUID is properly added.

The import statement correctly adds TEST_PARTY_UUID from the consts file, which aligns with the PR objective of transitioning from party IDs to UUIDs.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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 to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai 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.

@github-actions github-actions bot added the kind/feature-request Used when issue is a new feature or request label Apr 9, 2025
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

🔭 Outside diff range comments (1)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserControllerTest.cs (1)

264-269: 💡 Verification agent

🧩 Analysis chain

Consider if partyUuid query parameter is still needed

Now that partyId is a Guid with the same value as partyUuid, it seems redundant to pass the partyUuid as a query parameter. Is this parameter still required by the controller? If not, consider removing it to simplify the API calls.

Also applies to: 284-289


🏁 Script executed:

#!/bin/bash
# Check if the controller still requires partyUuid as a query parameter
rg -A 5 "DeleteAgentSystemUser" backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI/Controllers/

Length of output: 1340


Remove Redundant partyUuid Query Parameter

The controller’s DeleteAgentSystemUser method is defined to accept only partyId and systemUserGuid as route parameters—there’s no indication that a partyUuid query parameter is needed. Since partyUuid duplicates the value already in partyId, please remove this parameter from the test calls (e.g., lines 264-269 and 284-289 in SystemUserControllerTest.cs) to simplify the API usage.

🧹 Nitpick comments (3)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserRequestControllerTest.cs (1)

123-123: Method name appears inconsistent with its purpose

The test method name RejectSystemUserRequest_ApproveOk should probably be RejectSystemUserRequest_RejectOk since it's testing the rejection functionality, not approval.

-public async Task RejectSystemUserRequest_ApproveOk()
+public async Task RejectSystemUserRequest_RejectOk()
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserAgentRequestControllerTest.cs (2)

84-84: Indentation needs adjustment

The line has an extra space at the beginning compared to other similar declarations in the file.

-           Guid partyId = Guid.Parse("cd35779b-b174-4ecc-bbef-ece13611be7f");
+            Guid partyId = Guid.Parse("cd35779b-b174-4ecc-bbef-ece13611be7f");

123-137: Method naming inconsistency

The method name RejectSystemUserAgentRequest_RejectOk doesn't follow the same pattern as ApproveSystemUserAgentRequest_ApproveOk. Consider renaming for consistency.

-    public async Task RejectSystemUserAgentRequest_RejectOk()
+    public async Task RejectSystemUserAgentRequest_ApproveOk()
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d9578c and 40aec3e.

📒 Files selected for processing (5)
  • backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserAgentDelegationControllerTest.cs (14 hunks)
  • backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserAgentRequestControllerTest.cs (6 hunks)
  • backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserChangeRequestControllerTest.cs (6 hunks)
  • backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserControllerTest.cs (12 hunks)
  • backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserRequestControllerTest.cs (6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserAgentDelegationControllerTest.cs (3)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Services/SystemUserAgentDelegationService.cs (1)
  • List (124-135)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Models/SystemUser/Frontend/CustomerPartyFE.cs (1)
  • CustomerPartyFE (6-22)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Models/SystemUser/Frontend/AgentDelegationFE.cs (1)
  • AgentDelegationFE (6-22)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Continous Integration / Analyze
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (9)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserControllerTest.cs (1)

44-44: Consistent type conversion from int to Guid for partyId

All instances of partyId have been properly converted from int to Guid, using the same consistent UUID value. This change aligns with the PR objective of replacing integer identifiers with UUIDs.

Also applies to: 65-65, 87-87, 106-106, 125-125, 144-144, 172-172, 200-200, 221-221, 243-243, 262-262, 282-282

backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserAgentDelegationControllerTest.cs (1)

46-52: Improved API design by consolidating partyId and partyUuid

The changes successfully:

  1. Convert partyId from int to Guid
  2. Remove redundant partyUuid query parameters from URLs

This simplifies the API by using a single identifier (partyId as Guid) instead of duplicating the same value in different parameters. The endpoint URLs are now cleaner and more maintainable.

Also applies to: 68-74, 90-96, 112-118, 134-140, 156-162, 178-197, 212-231, 246-260, 274-281, 297-304

backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserRequestControllerTest.cs (1)

41-41: Consistent type conversion from int to Guid for partyId

All instances of partyId have been properly converted from int to Guid across all test methods. The same UUID value is used consistently throughout the file.

Also applies to: 63-63, 84-84, 105-105, 126-126, 147-147

backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserChangeRequestControllerTest.cs (1)

41-41: Consistent type conversion from int to Guid for partyId

All partyId variables have been properly converted from int to Guid, using the same UUID value consistently throughout all test methods.

Also applies to: 63-63, 84-84, 105-105, 126-126, 147-147

backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Controllers/SystemUserAgentRequestControllerTest.cs (5)

41-41: Type change from int to Guid looks good

The change from int to Guid for partyId aligns with the PR objective to replace integer identifiers with UUIDs for party identification.


63-63: Type change consistently applied

The type change is correctly applied in this error test case, ensuring consistent parameter types across all test scenarios.


105-105: Type change consistently applied

The type change is correctly applied in this error test case.


126-126: Type change consistently applied

The type change is correctly applied in the reject test case.


147-147: Type change consistently applied

The type change is correctly applied in this error test case.

… of sensitive cookie

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d394a42 and e04bf38.

📒 Files selected for processing (3)
  • src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.test.tsx (3 hunks)
  • tests/consts.ts (1 hunks)
  • tests/setupTests.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.test.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/setupTests.ts (1)
tests/consts.ts (2)
  • TEST_PARTY_ID (2-2)
  • TEST_PARTY_UUID (3-3)
🪛 GitHub Check: CodeQL
tests/setupTests.ts

[warning] 42-42: Clear text transmission of sensitive cookie
Sensitive cookie sent without enforcing SSL encryption.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Continous Integration / Analyze
🔇 Additional comments (2)
tests/consts.ts (1)

3-3: Addition of TEST_PARTY_UUID constant looks good.

This new constant aligns with the PR objective to replace party IDs with UUIDs throughout the system. The UUID format is valid and will provide better uniqueness guarantees than the numeric ID.

tests/setupTests.ts (1)

7-7: Import of TEST_PARTY_UUID is appropriate.

The addition of TEST_PARTY_UUID to the import statement correctly brings in the new constant needed for the test setup.

Copy link

sonarqubecloud bot commented Apr 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature-request Used when issue is a new feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant