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

Resolve role sharing conflicts in app sharing #413

Conversation

ShanChathusanda93
Copy link
Contributor

@ShanChathusanda93 ShanChathusanda93 commented Nov 12, 2024

Purpose

  • $subject
  • From [1] role management will be enabled in the sub organization level as well.
  • With that, in the sub organization level, there will be two types of roles.
    • Shared roles from the root organization (through the application sharing)
    • Roles created inside the sub organization directly.
  • There can be conflicts when the roles are created in the sub organization level.
  • This PR contains the fixes for the following conflicting scenarios.
    • Sub organization has a role named role01 and an organization audience application will be shared from the root organization and root organization contains a role named role01
      • App sharing will be restricted to that corresponding conflicting sub organization.
    • Sub organization has a role named role01 and already an organization audienace app is shared. Now in the root organization a new organization role will be created with a name role01.
      • Root organization role will not be shared to the conflicting sub organization.
    • Sub organization has a role named role01 and already an organization audienace app is shared. Now in the root organization an existing role is renamed to role01.
      • Role name modification will not be propogated to the conflicting sub organization.

[1] wso2/product-is#21208

Goals

  • Resolving role sharing conflicts.

Approach

  • Restricting the conflicting resource or the main resource that initiated the conflicting resource sharing to the conflicting sub organization

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 63.88889% with 26 lines in your changes missing coverage. Please review.

Project coverage is 31.03%. Comparing base (c30fb79) to head (c470073).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...ation/management/handler/SharedRoleMgtHandler.java 66.66% 22 Missing and 1 partial ⚠️
...gement/handler/listener/SharedRoleMgtListener.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #413      +/-   ##
============================================
+ Coverage     29.01%   31.03%   +2.01%     
- Complexity      385      440      +55     
============================================
  Files            50       61      +11     
  Lines          4146     4386     +240     
  Branches        478      496      +18     
============================================
+ Hits           1203     1361     +158     
- Misses         2842     2913      +71     
- Partials        101      112      +11     
Flag Coverage Δ
unit 31.03% <63.88%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@AnuradhaSK
Copy link
Contributor

Add unit tests

@ShanChathusanda93 ShanChathusanda93 force-pushed the org-path-app-conflict-resolve-branch branch 3 times, most recently from c5cb4aa to e6b551c Compare November 22, 2024 04:56
@ShanChathusanda93
Copy link
Contributor Author

Unit tests added to the new improvement

Comment on lines 396 to 402
auditData.put("parentOrganizationId", parentOrganizationId);
auditData.put("parentApplicationId", parentApplicationId);
auditData.put("sharedOrganizationId", sharedOrganizationId);
auditData.put("roleId", roleId);
auditData.put("roleName", roleName);
auditData.put("failureReason", failureReason);
Copy link
Contributor

Choose a reason for hiding this comment

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

use the constant defined in role mgt side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the PR [1] is merged we can use them here

[1] wso2/carbon-identity-framework#6010

thenReturn(PARENT_ORG_USER_ID);

SharedRoleMgtHandler sharedRoleMgtHandler = new SharedRoleMgtHandler();
sharedRoleMgtHandler.handleEvent(event);
Copy link
Contributor

Choose a reason for hiding this comment

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

we are not asserting anything here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here the assertion is the exception
expectedExceptions = IdentityEventException.class

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes this is correct, wanted to add this in last test method

@ShanChathusanda93 ShanChathusanda93 force-pushed the org-path-app-conflict-resolve-branch branch 2 times, most recently from 2773ef0 to 05a5b93 Compare November 22, 2024 09:56
AnuradhaSK
AnuradhaSK previously approved these changes Nov 22, 2024
@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/11973410045

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/11973410045
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/11973410045

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/12116587383

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/12116587383
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/12116587383

@ShanChathusanda93 ShanChathusanda93 merged commit dbfb4c2 into wso2-extensions:main Dec 2, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants