Skip to content

Commit

Permalink
Fix #891 - Gracefully handle auth for a mntner with no enabled methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Jan 15, 2024
1 parent c916866 commit c3ff387
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion irrd/rpsl/rpsl_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def clean(self):
)

def verify_auth(self, passwords: List[str], keycert_obj_pk: Optional[str] = None) -> Optional[str]:
return verify_auth_lines(self.parsed_data["auth"], passwords, keycert_obj_pk)
return verify_auth_lines(self.parsed_data.get("auth", []), passwords, keycert_obj_pk)

def has_dummy_auth_value(self) -> bool:
"""
Expand Down
20 changes: 20 additions & 0 deletions irrd/updates/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,26 @@ def test_valid_new_person(self, prepare_mocks):
["rpsl_pks", ({"TEST-MNT"},), {}],
]

def test_new_person_with_authless_mntner(self, prepare_mocks, config_override):
# "authless" meaning: no auth lines that are currently enabled - #891
config_override(
{
"auth": {"password_hashers": {"crypt-pw": "disabled"}},
}
)

validator, mock_dq, mock_dh = prepare_mocks
person = rpsl_object_from_text(SAMPLE_PERSON)
cryptonly_maintainer = "\n".join(line for line in SAMPLE_MNTNER.splitlines() if not line.startswith("auth:") or "CRYPT" in line)
print(cryptonly_maintainer)
mock_dh.execute_query = lambda q: [
{"object_class": "mntner", "object_text": cryptonly_maintainer},
]

validator.passwords = [SAMPLE_MNTNER_MD5]
result = validator.process_auth(person, None)
assert not result.is_valid()

def test_valid_new_person_api_key(self, prepare_mocks, monkeypatch):
validator, mock_dq, mock_dh = prepare_mocks
person = rpsl_object_from_text(SAMPLE_PERSON)
Expand Down

0 comments on commit c3ff387

Please sign in to comment.