Skip to content

Commit

Permalink
rename replace_lock to replace_locked
Browse files Browse the repository at this point in the history
  • Loading branch information
helylle committed Nov 28, 2024
1 parent 2bb01ed commit 89fea9e
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/eduid/userdb/proofing/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@


class ProofingUser(User):
replace_lock: IdentityType | None = None
replace_locked: IdentityType | None = None
pass
2 changes: 1 addition & 1 deletion src/eduid/webapp/common/api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def verify_nin_for_user(
and proofing_user.locked_identity.nin is not None
and proofing_user.locked_identity.nin.number == reference_nin
):
proofing_user.replace_lock = IdentityType.NIN
proofing_user.replace_locked = IdentityType.NIN

# Update users name
proofing_user = set_user_names_from_nin_proofing(user=proofing_user, proofing_log_entry=proofing_log_entry)
Expand Down
10 changes: 5 additions & 5 deletions src/eduid/webapp/common/api/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ def request_user_sync(self, private_user: User, app_name_override: str | None =

central_user = self.app.central_userdb.get_user_by_id(private_user.user_id)
private_user_dict = private_user.to_dict()
replace_lock: IdentityType | None = None
replace_locked: IdentityType | None = None
# fix signup_user data
if "proofing_reference" in private_user_dict:
del private_user_dict["proofing_reference"]

if "replace_lock" in private_user_dict:
replace_lock = private_user_dict["replace_lock"]
del private_user_dict["replace_lock"]
if "replace_locked" in private_user_dict:
replace_locked = private_user_dict["replace_locked"]
del private_user_dict["replace_locked"]

if central_user is None:
# This is a new user, create a new user in the central db
Expand Down Expand Up @@ -309,7 +309,7 @@ def request_user_sync(self, private_user: User, app_name_override: str | None =
identity.created_by = "test"
user.locked_identity.add(identity)
continue
if replace_lock is locked_identity.identity_type:
if replace_locked is locked_identity.identity_type:
# replace the locked identity with the new verified identity
if identity.created_by is None:
identity.created_by = "test"
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/webapp/common/api/tests/test_nin_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def test_verify_changed_nin_for_user_existing_not_verified(self, mock_reference_
assert user.identities.nin is not None
assert user.identities.nin.number == self.test_user_nin
# NIN should be updated by am when saving to main DB
assert user.replace_lock is IdentityType.NIN
assert user.replace_locked is IdentityType.NIN

def test_verify_nin_for_user_existing_verified(self) -> None:
user = self.insert_verified_user()
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/webapp/eidas/proofing.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def verify_identity(self, user: User) -> VerifyUserResult:
return VerifyUserResult(error=CommonMsg.locked_identity_not_matching)
# replace the locked identity as the users asserted prid has changed,
# and we are sure enough that it is the same person
proofing_user.replace_lock = new_identity.identity_type
proofing_user.replace_locked = new_identity.identity_type

# the existing identity is not verified, just remove it
if existing_identity is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/webapp/freja_eid/proofing.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _verify_foreign_identity(self, user: User) -> VerifyUserResult:
return VerifyUserResult(error=CommonMsg.locked_identity_not_matching)
# replace the locked identity as the users asserted prid has changed,
# and we are sure enough that it is the same person
proofing_user.replace_lock = new_identity.identity_type
proofing_user.replace_locked = new_identity.identity_type

# the existing identity is not verified, just remove it
if existing_identity is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/webapp/svipe_id/proofing.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _verify_foreign_identity(self, user: User) -> VerifyUserResult:
return VerifyUserResult(error=CommonMsg.locked_identity_not_matching)
# replace the locked identity as the users asserted prid has changed,
# and we are sure enough that it is the same person
proofing_user.replace_lock = new_identity.identity_type
proofing_user.replace_locked = new_identity.identity_type

# the existing identity is not verified, just remove it
if existing_identity is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/eduid/workers/am/ams/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def fetch_attrs(self, user_id: bson.ObjectId) -> dict[str, Any]:

return attributes

def get_replace_lock(self, user_id: bson.ObjectId) -> IdentityType | None:
def get_replace_locked(self, user_id: bson.ObjectId) -> IdentityType | None:
"""
Get the identity type of the lock to be replaced or None if no lock should be replaced.
"""
Expand All @@ -93,4 +93,4 @@ def get_replace_lock(self, user_id: bson.ObjectId) -> IdentityType | None:
logger.debug("Not a proofing user, returning None.")
return None

return user.replace_lock
return user.replace_locked
4 changes: 2 additions & 2 deletions src/eduid/workers/am/consistency_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def unverify_identities(userdb: AmDB, user_id: ObjectId, identities: list[dict[s


def check_locked_identity(
userdb: AmDB, user_id: ObjectId, attributes: dict, app_name: str, replace_lock: IdentityType | None = None
userdb: AmDB, user_id: ObjectId, attributes: dict, app_name: str, replace_locked: IdentityType | None = None
) -> dict:
"""
:param userdb: Central userdb
Expand Down Expand Up @@ -187,7 +187,7 @@ def check_locked_identity(
updated = True
continue

if replace_lock is locked_identity.identity_type:
if replace_locked is locked_identity.identity_type:
# replace the locked identity with the new verified identity
if identity.created_by is None:
identity.created_by = app_name
Expand Down
4 changes: 2 additions & 2 deletions src/eduid/workers/am/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def update_attributes_keep_result(self: AttributeManager, app_name: str, user_id

try:
attributes = attribute_fetcher.fetch_attrs(_id)
replace_lock = attribute_fetcher.get_replace_lock(_id)
replace_locked = attribute_fetcher.get_replace_locked(_id)
except UserDoesNotExist as e:
logger.error(f"The user {_id} does not exist in the database for plugin {app_name}: {e}")
raise e
Expand All @@ -81,7 +81,7 @@ def update_attributes_keep_result(self: AttributeManager, app_name: str, user_id

try:
logger.debug(f"Checking locked identity during sync attempt from {app_name}")
attributes = check_locked_identity(self.userdb, _id, attributes, app_name, replace_lock)
attributes = check_locked_identity(self.userdb, _id, attributes, app_name, replace_locked)
except LockedIdentityViolation as e:
logger.error(e)
raise e
Expand Down
4 changes: 2 additions & 2 deletions src/eduid/workers/am/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_check_locked_identity_wrong_nin(self) -> None:
with self.assertRaises(EduIDUserDBError):
check_locked_identity(self.amdb, user_id, attributes, "test")

def test_check_locked_identity_replace_lock(self) -> None:
def test_check_locked_identity_replace_locked(self) -> None:
user_id = ObjectId("901234567890123456789012") # [email protected] / babba-labba
user = self.amdb.get_user_by_id(user_id)
assert user
Expand All @@ -255,7 +255,7 @@ def test_check_locked_identity_replace_lock(self) -> None:
"identities": [{"identity_type": IdentityType.NIN.value, "verified": True, "number": "200506076789"}]
}
}
new_attributes = check_locked_identity(self.amdb, user_id, attributes, "test", replace_lock=IdentityType.NIN)
new_attributes = check_locked_identity(self.amdb, user_id, attributes, "test", replace_locked=IdentityType.NIN)

# check_locked_identity should replace locked identity with new identity
locked_nin = NinIdentity(number="200506076789", created_by="test", is_verified=True)
Expand Down

0 comments on commit 89fea9e

Please sign in to comment.