Skip to content

Conversation

@HasiniSama
Copy link
Contributor

Purpose

Issue: wso2/product-is#21100

Ported the implementation from: #512

Additional changes introduced:

  • Update the /share GET API to return the sharingInitiationMode.
  • /share POST API requests now doesn't require the complete hierarchy to be sent in the payload. However the application should be already shared with the parent org.
  • Fixed the bug on getting the roles shared overridden by the parent's roles shared.
  • If shareWithAllChildren property is set to true, it will be treated same as the ALL_EXISTING_AND_FUTURE_ORGS and the sharingInitiationMode will be sent in the GET API.
  • An application cannot be unshared from a child organization if there's parent organization that enforces a future policy.
  • Fixed the error in the PATCH API when having both add/remove share for a single organization.
  • sharingInitiationMode is only included if it's sent in the 'attributes' query param.
  • Update the roles list limit returned in GET API to 100.
  • Fix the pagination bug on href link.

Related PR(s)

wso2/identity-api-server#929

- Provide the support to get application with filtering option.
- Add new error message for application sharing
- Moved application share operations models to a new package
# Conflicts:
#	components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/OrgApplicationManagerImpl.java
#	components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/constant/OrgApplicationMgtConstants.java
#	components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/internal/OrgApplicationMgtDataHolder.java
#	components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/internal/OrgApplicationMgtServiceComponent.java
- Convert logs to debug
- Convert the ShareRoleMgt behaviour to previous behavior
- Improve logging
- Add unit tests
- Reduce using start tenant flows
- Optimize to execute less DB queries
@AnuradhaSK AnuradhaSK requested a review from Copilot July 9, 2025 11:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for selective role sharing within application-sharing flows, ports existing logic from the organization-management extension, and extends resource sharing to include applications.

  • Introduce getResourceSharingPolicyByInitiatingOrgId methods in DAO, service interface, and service impl
  • Extend ResourceType and PolicyEnum to include APPLICATION resources
  • Add new SQL constant and update POM version for organization-management core
  • Implement comprehensive application share handlers and utility classes (e.g., hierarchy processing, SCIM filter parsing, filter builders)

Reviewed Changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pom.xml Bump <identity.organization.management.core.version> to 1.1.33
ResourceSharingPolicyHandlerDAOImpl.java Implement getResourceSharingPolicyByInitiatingOrgId
ResourceSharingSQLConstants.java Add GET_RESOURCE_SHARING_POLICIES_WITH_INITIATING_ORG_ID SQL template
ResourceType.java & PolicyEnum.java Add APPLICATION as a valid resource type and include in all policies
FilterQueriesUtil.java Introduce generic SCIM filter-to-query builder with various operations
SharedRoleMgtHandler.java / SharedRoleMgtListener.java / SharedRoleMgtHandlerTest.java Enhance event handling for application share and selective role updates
OrgApplicationShareProcessor.java Add BFS-based priority sorting for selective organization shares
Comments suppressed due to low confidence (2)

components/org.wso2.carbon.identity.organization.resource.sharing.policy.management/src/main/java/org/wso2/carbon/identity/organization/resource/sharing/policy/management/dao/ResourceSharingPolicyHandlerDAOImpl.java:476

  • The new getResourceSharingPolicyByInitiatingOrgId method is not covered by unit tests. Please add tests for this DAO method to verify grouping logic and empty-case behavior.
            return result.stream().collect(Collectors.groupingBy(

components/org.wso2.carbon.identity.organization.resource.sharing.policy.management/src/main/java/org/wso2/carbon/identity/organization/resource/sharing/policy/management/constant/ResourceSharingSQLConstants.java:73

  • The SQL string includes semicolons before the AND clauses, which will break the query. Remove the semicolons so that it reads ... = :INITIATING_ORG_ID AND ... = :RESOURCE_TYPE AND ... = :RESOURCE_ID.
                    "WHERE rsp.UM_INITIATING_ORG_ID = :" + SQLPlaceholders.DB_SCHEMA_COLUMN_NAME_INITIATING_ORG_ID


String filter = RoleConstants.AUDIENCE_ID + " " + RoleConstants.EQ + " " + appId;
return getRoleManagementServiceV2().getRoles(filter, null, 0, null, null, tenantDomain);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactor the code to the role handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check the role amount returned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add pagination here. Same as the listener.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check whether the roles get unshared.

@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 24.71910% with 804 lines in your changes missing coverage. Please review.

Project coverage is 52.90%. Comparing base (ab592a4) to head (127d210).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
...ation/management/handler/SharedRoleMgtHandler.java 35.90% 199 Missing and 42 partials ⚠️
...application/util/OrgApplicationShareProcessor.java 33.54% 93 Missing and 14 partials ⚠️
...lication/listener/OrganizationCreationHandler.java 0.00% 92 Missing ⚠️
...management/application/util/FilterQueriesUtil.java 0.00% 79 Missing ⚠️
...istener/ApplicationSharingManagerListenerImpl.java 0.00% 40 Missing ⚠️
...application/dao/impl/OrgApplicationMgtDAOImpl.java 0.00% 39 Missing ⚠️
...ement/dao/ResourceSharingPolicyHandlerDAOImpl.java 14.70% 27 Missing and 2 partials ⚠️
...plication/util/OrgApplicationScimFilterParser.java 0.00% 24 Missing ⚠️
...ation/model/SharedApplicationOrganizationNode.java 0.00% 22 Missing ⚠️
...del/operation/ApplicationShareUpdateOperation.java 0.00% 19 Missing ⚠️
... and 14 more

❌ Your patch status has failed because the patch coverage (24.71%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #525      +/-   ##
============================================
- Coverage     56.18%   52.90%   -3.28%     
- Complexity     1988     2002      +14     
============================================
  Files           186      199      +13     
  Lines         10977    12505    +1528     
  Branches       1640     1947     +307     
============================================
+ Hits           6167     6616     +449     
- Misses         4269     5255     +986     
- Partials        541      634      +93     
Flag Coverage Δ
unit 36.74% <24.71%> (-1.16%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HasiniSama
Copy link
Contributor Author

Unit test to improve coverage will be tracked via: wso2/product-is#24757

@jenkins-is-staging
Copy link

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/16434336417
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/16434336417

SujanSanjula96
SujanSanjula96 previously approved these changes Jul 22, 2025
sahandilshan
sahandilshan previously approved these changes Jul 22, 2025
@HasiniSama HasiniSama dismissed stale reviews from sahandilshan and SujanSanjula96 via ef355ce July 22, 2025 06:46
@HasiniSama HasiniSama force-pushed the sahandilshan branch 2 times, most recently from ef355ce to 4f6a010 Compare July 22, 2025 06:48
@HasiniSama HasiniSama merged commit 8874c87 into wso2-extensions:main Jul 22, 2025
2 of 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.

4 participants