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

🗃️ [#2041] Added hard database constraints on User's identifier/login_type fields #1074

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

stevenbal
Copy link
Contributor

@stevenbal stevenbal commented Mar 4, 2024

Based on #990

@stevenbal stevenbal marked this pull request as draft March 4, 2024 13:55
@stevenbal stevenbal marked this pull request as ready for review March 11, 2024 15:49
@stevenbal stevenbal force-pushed the fix/2041-user-db-constraints branch from 8b236ff to edc7d43 Compare March 11, 2024 15:50
@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.04%. Comparing base (761f3e2) to head (39a45be).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1074      +/-   ##
===========================================
+ Coverage    95.03%   95.04%   +0.01%     
===========================================
  Files          911      913       +2     
  Lines        32038    32124      +86     
===========================================
+ Hits         30446    30532      +86     
  Misses        1592     1592              

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

src/open_inwoner/accounts/models.py Outdated Show resolved Hide resolved
src/open_inwoner/openklant/tests/data.py Outdated Show resolved Hide resolved
@stevenbal stevenbal marked this pull request as draft March 12, 2024 15:06
Copy link
Contributor

@pi-sigma pi-sigma left a comment

Choose a reason for hiding this comment

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

Not sure if something needs to be done about DuplicateEmailRegistrationTest; take a quick look to confirm.

@@ -442,6 +443,9 @@ def test_form_success_with_api_eherkenning_user(self, m):
with self.subTest(
use_rsin_for_innNnpId_query_parameter=use_rsin_for_innNnpId_query_parameter
):
# FIXME for some reason creating the user outside of the loop
# makes the second iteration fail?
User.objects.filter(kvk="12345678").delete()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same/similar issue as in https://github.com/maykinmedia/open-inwoner/blob/develop/src/open_inwoner/accounts/tests/test_profile_views.py#L547, where the mock has to be recreated because it is overriden somehow? Something's up with our mock machinery that needs to be fixed, though not sure if this can be done as part of your ticket; perhaps create a new one for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree these delete()'s are a bit smelly.

Copy link
Contributor Author

@stevenbal stevenbal Mar 15, 2024

Choose a reason for hiding this comment

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

Still unsure why only the second iteration failed: apparently it wasn't due to the mocks, but it's fixed if I give the User the same email as the klant created in the mock data? 🙈

@stevenbal stevenbal force-pushed the fix/2041-user-db-constraints branch from edc7d43 to 7048b7f Compare March 15, 2024 08:41
@stevenbal stevenbal marked this pull request as ready for review March 15, 2024 08:41
@stevenbal stevenbal force-pushed the fix/2041-user-db-constraints branch from 7048b7f to 8f3f271 Compare March 15, 2024 10:21
Copy link
Contributor

@Bartvaderkin Bartvaderkin left a comment

Choose a reason for hiding this comment

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

Some small notes, and I wonder if we covered the eenmanszaken situation from an earlier comment (if we always have kvk and rsin, or if eenmanszaken can have a bsn but not kvk or rsin).

src/open_inwoner/accounts/tests/test_user_constraints.py Outdated Show resolved Hide resolved
src/open_inwoner/accounts/tests/test_profile_views.py Outdated Show resolved Hide resolved
@stevenbal stevenbal force-pushed the fix/2041-user-db-constraints branch from 8f3f271 to 67c28a6 Compare March 15, 2024 14:07
@stevenbal stevenbal requested a review from Bartvaderkin March 15, 2024 14:07
@stevenbal stevenbal force-pushed the fix/2041-user-db-constraints branch from 67c28a6 to 5508218 Compare March 18, 2024 07:57
Comment on lines 556 to 552
# reset noise from signals
m.reset_mock()
self.clearTimelineLogs()
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need these lines anymore as they were there to reset the subtests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the reset_mock, but clearTimelineLogs is actually still needed (it's also used in other tests in this file that don't have subtests)

Copy link
Contributor

Choose a reason for hiding this comment

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

Existing code may or may not be perfect.

Could be cool to see why it happens but if you tested it fails if we remove it I'll believe it (could be because the code earlier in the tests generates similar logs)

Comment on lines 593 to 588
# reset noise from signals
m.reset_mock()
self.clearTimelineLogs()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@stevenbal stevenbal force-pushed the fix/2041-user-db-constraints branch from 5508218 to 39a45be Compare March 18, 2024 11:13
@stevenbal stevenbal requested a review from Bartvaderkin March 18, 2024 11:13
@Bartvaderkin
Copy link
Contributor

@stevenbal Are we sure about the check_bsn_only_set_when_login_digid rule? In relation to the eherkenning & eenmanszaken from earlier?

@stevenbal
Copy link
Contributor Author

stevenbal commented Mar 19, 2024

Are we sure about the check_bsn_only_set_when_login_digid rule? In relation to the eherkenning & eenmanszaken from earlier?

I'll double check with Alex, apparently Groningen registers eenmanszaken bij KVK number and vestigingsnummer, but if we only allow that, it would still not work for eenmanszaken if we use Open Zaak. In case of Open Zaak we might have to force users that want to log in for an eenmanszaak to log in with DigiD

@alextreme
Copy link
Member

The suggestion (OpenZaak + RSIN + eHerkenning -> dont allow eenmanszaken to log in via eHerkenning) is sufficient for now and is already in the project. For eenmanszaken BSN == RSIN, so logging in via DigiD would give them the same information.

@stevenbal stevenbal marked this pull request as draft April 15, 2024 13:37
@stevenbal stevenbal force-pushed the fix/2041-user-db-constraints branch from 39a45be to 2b8b97c Compare April 15, 2024 13:52
@stevenbal stevenbal marked this pull request as ready for review April 15, 2024 13:53
@stevenbal
Copy link
Contributor Author

@Bartvaderkin I rebased this on master, can you re-review/approve this? :)

@alextreme alextreme requested review from swrichards and removed request for Bartvaderkin May 31, 2024 08:22
@alextreme
Copy link
Member

@swrichards could you take a look at this PR somewhere in the following weeks? No rush but now it is languishing

@swrichards
Copy link
Contributor

@swrichards could you take a look at this PR somewhere in the following weeks? No rush but now it is languishing

👍

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.

6 participants