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

fix: program validation for related program property [DHIS2-15952] #15885

Merged
merged 2 commits into from
Dec 11, 2023

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Dec 11, 2023

Summary

It was possible to set the relatedProgram property to the program itself. This then is a circular reference which causes all kinds of errors in other places but also in the app.

In addition I found that following the app UI it seems that only tracker programs should have this property but it was possible to set it for event programs as well. So an additional validation was added to prevent this.

Automatic Testing

New scenario was added to verify that a program cannot reference itself as related program.

Manual Testing

UI

  • open maintenance app
  • edit a tracker program, try to select itself as the related program (2nd tab on enrollment details)
  • try to save, check an error message is shown
  • now try to select another program and save, check this works
  • now try to clear the related program and save, check this works

REST API

  • find a program to test with using the maintenance app or /api/programs
  • try to update the program with PUT to update the relatedProgram property to itself relatedProgram: { "id": "<uid>"}
  • check this gives error E6022 for tracker programs and error E4023 for event programs
  • try to update the property to any other program and check it works
  • try to clear the property and check it works

@jbee jbee self-assigned this Dec 11, 2023
Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Merging #15885 (e28348e) into master (a01b627) will decrease coverage by 0.01%.
Report is 1 commits behind head on master.
The diff coverage is 40.00%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #15885      +/-   ##
============================================
- Coverage     66.38%   66.37%   -0.01%     
+ Complexity    31473    31472       -1     
============================================
  Files          3494     3494              
  Lines        130141   130149       +8     
  Branches      15191    15193       +2     
============================================
  Hits          86391    86391              
- Misses        36674    36678       +4     
- Partials       7076     7080       +4     
Flag Coverage Δ
integration 50.07% <30.00%> (-0.01%) ⬇️
integration-h2 32.32% <40.00%> (+<0.01%) ⬆️
unit 30.39% <30.00%> (-0.01%) ⬇️

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

Files Coverage Δ
...rc/main/java/org/hisp/dhis/feedback/ErrorCode.java 100.00% <100.00%> (ø)
...c/main/java/org/hisp/dhis/program/ProgramType.java 66.66% <33.33%> (-15.16%) ⬇️
...ta/objectbundle/hooks/ProgramObjectBundleHook.java 87.71% <33.33%> (-6.40%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a01b627...e28348e. Read the comment docs.

@jbee jbee marked this pull request as ready for review December 11, 2023 13:28
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@jbee jbee enabled auto-merge (squash) December 11, 2023 14:17
@jbee jbee merged commit 9733914 into dhis2:master Dec 11, 2023
18 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