From 7a708ff5ad31ed9d218c286310a30a8fd2fb6527 Mon Sep 17 00:00:00 2001 From: Lars Date: Mon, 26 Aug 2024 22:38:40 +0200 Subject: [PATCH] Remove extension key validation to permit custom flags/extensions --- src/sshkey_tools/fields.py | 7 ------- tests/test_certificates.py | 21 ++------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/src/sshkey_tools/fields.py b/src/sshkey_tools/fields.py index 638c6d5..7721188 100644 --- a/src/sshkey_tools/fields.py +++ b/src/sshkey_tools/fields.py @@ -1178,13 +1178,6 @@ def __validate_value__(self) -> Union[bool, Exception]: f"{self.get_name()} Could not validate value, invalid type" ) - for item in self.value: - if item not in self.ALLOWED_VALUES: - return _EX.InvalidDataException( - f"Invalid extension '{item}'{NEWLINE}" - + f"Allowed values are: {NEWLINE.join(self.ALLOWED_VALUES)}" - ) - return True diff --git a/tests/test_certificates.py b/tests/test_certificates.py index 48bb2a5..d80fa34 100644 --- a/tests/test_certificates.py +++ b/tests/test_certificates.py @@ -482,6 +482,8 @@ def test_extensions_field(self): "permit-port-forwarding", "permit-pty", "permit-user-rc", + "test@domain.net", + "abc@def.com" ] self.assertRandomResponse( @@ -492,25 +494,6 @@ def test_extensions_field(self): ], ) - def test_invalid_extensions_field(self): - field = _FIELD.CriticalOptionsField([ValueError, "permit-pty", b"unpermit"]) - field.validate() - - self.assertFieldContainsException(field, _EX.InvalidDataException) - - field = _FIELD.CriticalOptionsField("InvalidData") - field.validate() - - self.assertFieldContainsException(field, _EX.InvalidDataException) - - field = _FIELD.CriticalOptionsField(["no-touch-required", "InvalidOption"]) - field.validate() - - self.assertFieldContainsException(field, _EX.InvalidDataException) - - with self.assertRaises(_EX.InvalidDataException): - field.encode(ValueError) - def test_reserved_field(self): self.assertExpectedResponse(_FIELD.ReservedField, "", b"\x00\x00\x00\x00")