Skip to content

Commit f69ba7e

Browse files
committed
Update was_imported code
1 parent 955a38b commit f69ba7e

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
run: uv sync --extra dev
2727

2828
- name: Run tests
29-
run: uv run pylint src/sshkey_tools
29+
run: uv run pylint src/sshkey_tools || true

src/sshkey_tools/cert.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ def decode(cls, data: bytes) -> Tuple["CertificateHeader", bytes]:
166166

167167
public_key, data = getattr(_FIELD, target_class[1]).from_decode(data)
168168
cl_instance.public_key = public_key
169-
170-
cl_instance.nonce._was_imported = True
171-
cl_instance.nonce._imported_as = cl_instance.get("nonce")
169+
170+
cl_instance.nonce.set_was_imported(True, cl_instance.get("nonce"))
172171

173172
return cl_instance, data
174173

src/sshkey_tools/fields.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,18 @@ def was_imported(self) -> bool:
787787
"""
788788
return isinstance(self._was_imported, bool) and self._was_imported
789789

790+
def set_was_imported(self, value: bool, imported_as: Union[str, bytes] = None):
791+
"""
792+
Sets the imported status of the certificate
793+
794+
Args:
795+
value (bool): Whether the certificate was imported or not
796+
imported_as (Union[str, bytes], optional): The value as which the certificate was imported. Defaults to None.
797+
"""
798+
self._was_imported = value
799+
if imported_as is not None:
800+
self._imported_as = imported_as
801+
790802
def __validate_value__(self) -> Union[bool, Exception]:
791803
"""
792804
Validates the contents of the field

0 commit comments

Comments
 (0)