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

Feature/adding location #129

Merged
merged 33 commits into from
Oct 16, 2024
Merged

Feature/adding location #129

merged 33 commits into from
Oct 16, 2024

Conversation

delcroip
Copy link
Member

No description provided.

weilu and others added 24 commits September 5, 2024 11:35
to facilitate row security
Also refactor individual mutation & query test to extract setup code
* Fix perforamnce for individual data update

* added saving in bulk way validation errors

* removed redundant print

---------

Co-authored-by: sniedzielski <sniedzielski@soldevelo.com>
@delcroip delcroip changed the base branch from develop to release/24.10 October 11, 2024 18:05
Copy link
Contributor

@weilu weilu left a comment

Choose a reason for hiding this comment

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

@delcroip The change to use LocationManager.is_allowed instead of Location.get_queryset introduces the following issues:

  1. it no longer considers and respects settings.ROW_SECURITY,
  2. users with user.is_imis_admin = True now is not permitted to mutate any individual or group with location. Case 2 is actually covered by a test case you removed (see my comment in code).

In other words, Location.get_queryset offers more functionalities needed than that LocationManager.is_allowed is currently offering. In the spirit of DRY, I'd suggest not replicating the checks inside is_allowed, but considering pushing the caching logic into LocationManager.allowed which is used by Location.get_queryset and keep using Location.get_queryset for location authorization checking.

Comment on lines 616 to 617
id = content['data']['editIndividualInGroup']['internalId']
self.assert_mutation_error(id, 'mutation.individual_group_village_mismatch')
Copy link
Contributor

Choose a reason for hiding this comment

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

@delcroip This test case shouldn't have been deleted as it catches the case that an imis admin user can manipulate any individual's group assignment but we should validate to ensure the individual and their assigned group's locations are consistent.

Comment on lines 183 to 185
content = json.loads(response.content)
internal_id = content['data']['updateGroup']['internalId']
self.assert_mutation_error(internal_id, 'mutation.authentication_required')
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be necessary as the anonymous user case is already tested in the test above. I see why you added them – probably due to the extraneous line I have above where the response was not checked. I'll push a change to remove this and similar changes below.

Copy link
Member Author

@delcroip delcroip Oct 15, 2024

Choose a reason for hiding this comment

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

I added it to force the execution of the mutation, if not error could happen later in the process, if we remove the get_mutation_result we should also remove the query

Copy link
Contributor

@weilu weilu Oct 15, 2024

Choose a reason for hiding this comment

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

Yes, I removed the query in 324c578

weilu and others added 4 commits October 11, 2024 15:22
- Also modify existing cases to ensure imis admin can modify individual
and group with location
- Show error message when assert_mutation_success fails
@@ -474,7 +474,7 @@ def test_add_individual_to_group_row_security(self):
)
content = json.loads(response.content)
internal_id = content['data']['addIndividualToGroup']['internalId']
self.assert_mutation_error(internal_id, _('unauthorized.location'))
self.assert_mutation_success(internal_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

@delcroip why has this been changed to success? Shouldn't we prevent such a scenario to keep location data consistent between individual and their group?

Copy link

sonarcloud bot commented Oct 15, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
75.3% Coverage on New Code (required ≥ 80%)
5.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@delcroip delcroip merged commit 74f2d1c into release/24.10 Oct 16, 2024
11 of 14 checks passed
@delcroip delcroip deleted the feature/adding-location branch October 16, 2024 08:15
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