Skip to content

Commit

Permalink
Remove extension key validation to permit custom flags/extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibling committed Aug 26, 2024
1 parent ec38993 commit 7a708ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
7 changes: 0 additions & 7 deletions src/sshkey_tools/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
21 changes: 2 additions & 19 deletions tests/test_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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")

Expand Down

0 comments on commit 7a708ff

Please sign in to comment.