From 0c29f0f47ab114db707445bb447b9e43600d3bdf Mon Sep 17 00:00:00 2001 From: zarganum Date: Tue, 27 Aug 2024 19:54:13 +0000 Subject: [PATCH 1/3] set_password bytes result_string --- src/krb5/_set_password.pyi | 4 +--- src/krb5/_set_password.pyx | 12 ++++++------ tests/test_changepw.py | 8 ++++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/krb5/_set_password.pyi b/src/krb5/_set_password.pyi index 3329849..d51f45a 100644 --- a/src/krb5/_set_password.pyi +++ b/src/krb5/_set_password.pyi @@ -15,18 +15,16 @@ class SetPasswordResult(typing.NamedTuple): KRB5_KPASSWD_HARDERROR (2) - Server error\n KRB5_KPASSWD_AUTHERROR (3) - Authentication error\n KRB5_KPASSWD_SOFTERROR (4) - Password change rejected\n - Note the `result_code_string` is a byte string. The `result_string` is a server protocol response that may contain useful information about password policy violations or other errors. - It is decoded as a `string` according to ``RFC 3244`` """ result_code: int """The library result code of the password change operation.""" result_code_string: bytes """The byte string representation of the result code.""" - result_string: str + result_string: bytes """Server response string""" def set_password( diff --git a/src/krb5/_set_password.pyx b/src/krb5/_set_password.pyx index 6f114d5..722d4c6 100644 --- a/src/krb5/_set_password.pyx +++ b/src/krb5/_set_password.pyx @@ -87,16 +87,16 @@ def set_password( if length == 0: result_code_bytes = b"" else: - result_code_bytes = value[:length] + result_code_bytes = value[:length] pykrb5_get_krb5_data(&result_string, &length, &value) if length == 0: result_string_bytes = b"" else: - result_string_bytes = value[:length] + result_string_bytes = value[:length] - return SetPasswordResult(result_code, result_code_bytes, result_string_bytes.decode("utf-8")) + return SetPasswordResult(result_code, result_code_bytes, result_string_bytes) finally: pykrb5_free_data_contents(context.raw, &result_code_string) @@ -147,16 +147,16 @@ def set_password_using_ccache( if length == 0: result_code_bytes = b"" else: - result_code_bytes = value[:length] + result_code_bytes = value[:length] pykrb5_get_krb5_data(&result_string, &length, &value) if length == 0: result_string_bytes = b"" else: - result_string_bytes = value[:length] + result_string_bytes = value[:length] - return SetPasswordResult(result_code, result_code_bytes, result_string_bytes.decode("utf-8")) + return SetPasswordResult(result_code, result_code_bytes, result_string_bytes) finally: pykrb5_free_data_contents(context.raw, &result_code_string) diff --git a/tests/test_changepw.py b/tests/test_changepw.py index eb9df89..5bf47d8 100644 --- a/tests/test_changepw.py +++ b/tests/test_changepw.py @@ -45,12 +45,12 @@ def test_set_password(realm: k5test.K5Realm) -> None: (result_code, result_code_string, result_string) = krb5.set_password(ctx, creds, empty_password.encode()) assert result_code != 0 assert result_code_string.find(b"rejected") > 0 - assert result_string.find("too short") > 0 + assert result_string.find(b"too short") > 0 (result_code, result_code_string, result_string) = krb5.set_password(ctx, creds, weak_password.encode()) assert result_code != 0 assert result_code_string.find(b"rejected") > 0 - assert result_string.find("too short") > 0 + assert result_string.find(b"too short") > 0 (result_code, result_code_string, result_string) = krb5.set_password(ctx, creds, new_password.encode()) assert result_code == 0 @@ -91,14 +91,14 @@ def test_set_password(realm: k5test.K5Realm) -> None: ) assert result_code != 0 assert result_code_string.find(b"rejected") > 0 - assert result_string.find("too short") > 0 + assert result_string.find(b"too short") > 0 (result_code, result_code_string, result_string) = krb5.set_password_using_ccache( ctx, cc, weak_password.encode(), princ ) assert result_code != 0 assert result_code_string.find(b"rejected") > 0 - assert result_string.find("too short") > 0 + assert result_string.find(b"too short") > 0 (result_code, result_code_string, result_string) = krb5.set_password_using_ccache( ctx, cc, new_password.encode(), princ From f5687b7c7613c8838363195b125e34ce00023b05 Mon Sep 17 00:00:00 2001 From: zarganum Date: Tue, 27 Aug 2024 19:55:15 +0000 Subject: [PATCH 2/3] CI bump version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 88aa2b2..bb23dca 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = krb5 -version = 0.7.0 +version = 0.7.0.post51 url = https://github.com/jborean93/pykrb5 author = Jordan Borean author_email = jborean93@gmail.com From c109966352f94a65b84968b0770af517f27ddd97 Mon Sep 17 00:00:00 2001 From: zarganum Date: Tue, 27 Aug 2024 20:37:35 +0000 Subject: [PATCH 3/3] CI revert version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bb23dca..88aa2b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = krb5 -version = 0.7.0.post51 +version = 0.7.0 url = https://github.com/jborean93/pykrb5 author = Jordan Borean author_email = jborean93@gmail.com