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

Improve action management service to manage actions with rules. #6269

Merged
merged 6 commits into from
Jan 9, 2025

Conversation

malithie
Copy link
Member

@malithie malithie commented Jan 7, 2025

Proposed changes in this pull request

Resolves wso2/product-is#22185

When it comes to extensions it should be possible to let to invoke extensions conditionally based on some rule applicable to the context.
This PR introduce the capability to manage such extensions (actions) with rules improving the action management service component to add/update actions with rules using rule management service.

Note audit logs for rule update in actions will be done in a future iteration: wso2/product-is#22186

@malithie malithie changed the title Support managing rules for actions. Improve action management service to manage actions with rules. Jan 7, 2025
@malithie
Copy link
Member Author

malithie commented Jan 7, 2025

2 New issues

These issues are not quite valid

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 84.74576% with 27 lines in your changes missing coverage. Please review.

Project coverage is 45.71%. Comparing base (3178e6e) to head (0d58c41).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...n/management/dao/impl/ActionManagementDAOImpl.java 85.48% 7 Missing and 2 partials ⚠️
...n/identity/action/management/model/ActionRule.java 72.00% 4 Missing and 3 partials ⚠️
...management/internal/ActionMgtServiceComponent.java 0.00% 6 Missing ⚠️
...management/dao/impl/ActionManagementDAOFacade.java 92.06% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6269      +/-   ##
============================================
+ Coverage     45.25%   45.71%   +0.45%     
- Complexity    14339    14363      +24     
============================================
  Files          1633     1655      +22     
  Lines        104178   103542     -636     
  Branches      18740    18165     -575     
============================================
+ Hits          47145    47331     +186     
+ Misses        50181    49367     -814     
+ Partials       6852     6844       -8     
Flag Coverage Δ
unit 29.00% <84.74%> (+0.55%) ⬆️

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.

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

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

if (existingActionDTO.getActionRule() == null && updatingActionDTOBuilder.getActionRule() != null) {
// This means a new action rule is added when updating the action.
addActionRule(updatingActionDTOBuilder, tenantDomain);
} else if (existingActionDTO.getActionRule() != null && updatingActionDTOBuilder.getActionRule() == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently we follow the json patch operation for action update. In that case, attributes can be null in the action update payload.
As we checked the updatingActionDTOBuilder.getActionRule() == null condition in here, we may need to send the rule object everytime in the update payload, even if it is not updating.

Are there any other options we can use to delete the rule from the action update api ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't get you. This doesn't check other attributes. This just check for rule. So, rule doesn't need to be there in payload always

Copy link
Contributor

@ashanthamara ashanthamara Jan 7, 2025

Choose a reason for hiding this comment

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

With current approach for updating action, some respective attributes in the payload can be null when they are not updating(Eg: When only the action name is updating, payload only contains the name; others are null).

Let's say we have a rule configured in the action, and we are updating the action name. In that case, rule will be null in the payload. Due to that, this condition(updatingActionDTOBuilder.getActionRule() == null) will be true and it will delete the rule.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok so it's not a put and a patch. Then we have to think of a different way. Good catch

Copy link
Member Author

Choose a reason for hiding this comment

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

This is fixed as below.

  • Current patching capability is preserved
  • When a rule is not updated as the action updates, the payload should not include the rule object.
  • When rule is added or updated, it should send the rule object with it's expressions and other rules
  • When rule is removed, the payload should include an empty rule object. e.g., rule:{}

@malithie malithie force-pushed the rules-management branch 2 times, most recently from fa24ffe to a2e9b6c Compare January 8, 2025 08:33
Copy link

sonarqubecloud bot commented Jan 8, 2025

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

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

@malithie
Copy link
Member Author

malithie commented Jan 9, 2025

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

Failing test case here is actually passing locally

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

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

@malithie malithie merged commit d4667b2 into wso2:master Jan 9, 2025
3 checks passed
@malithie
Copy link
Member Author

malithie commented Jan 9, 2025

Merged as the failing test case is passing locally supposing it's an intermittent failure.

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.

Improve action management service to manage actions with rules
3 participants