From c70374deb3b47f9ee04486f981d06cae245a1276 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 27 Nov 2025 17:44:45 +0000 Subject: [PATCH 1/2] Initial plan From 7e02051d0c2ff14348a716c7837de4aab8e38b97 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 27 Nov 2025 17:50:18 +0000 Subject: [PATCH 2/2] Add enforce_handoff property to SdkConfig with tests Co-authored-by: mehmet-yoti <111424390+mehmet-yoti@users.noreply.github.com> --- .../doc_scan/session/create/sdk_config.py | 29 +++++++++++++ .../session/create/test_sdk_config.py | 42 +++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/yoti_python_sdk/doc_scan/session/create/sdk_config.py b/yoti_python_sdk/doc_scan/session/create/sdk_config.py index 37cde6b5..a8ef7ef0 100644 --- a/yoti_python_sdk/doc_scan/session/create/sdk_config.py +++ b/yoti_python_sdk/doc_scan/session/create/sdk_config.py @@ -23,6 +23,7 @@ def __init__( error_url, allow_handoff=None, privacy_policy_url=None, + enforce_handoff=None, ): """ :param allowed_capture_methods: the allowed capture methods @@ -45,6 +46,8 @@ def __init__( :type privacy_policy_url: str :param allow_handoff: boolean flag for allow_handoff :type allow_handoff: bool + :param enforce_handoff: boolean flag for enforce_handoff + :type enforce_handoff: bool """ self.__allowed_capture_methods = allowed_capture_methods self.__primary_colour = primary_colour @@ -56,6 +59,7 @@ def __init__( self.__error_url = error_url self.__privacy_policy_url = privacy_policy_url self.__allow_handoff = allow_handoff + self.__enforce_handoff = enforce_handoff @property def allowed_capture_methods(self): @@ -148,6 +152,16 @@ def allow_handoff(self): """ return self.__allow_handoff + @property + def enforce_handoff(self): + """ + Flag to enforce handoff when allow_handoff is enabled. + Cannot be true if allow_handoff is false. + + :return: the enforce_handoff + """ + return self.__enforce_handoff + def to_json(self): return remove_null_values( { @@ -161,6 +175,7 @@ def to_json(self): "error_url": self.error_url, "privacy_policy_url": self.privacy_policy_url, "allow_handoff": self.allow_handoff, + "enforce_handoff": self.enforce_handoff, } ) @@ -181,6 +196,7 @@ def __init__(self): self.__error_url = None self.__privacy_policy_url = None self.__allow_handoff = None + self.__enforce_handoff = None def with_allowed_capture_methods(self, allowed_capture_methods): """ @@ -320,6 +336,18 @@ def with_allow_handoff(self, flag): self.__allow_handoff = flag return self + def with_enforce_handoff(self, flag): + """ + Sets the enforce handoff flag + + :param flag: boolean value for flag + :type flag: bool + :return: the builder + :rtype: SdkConfigBuilder + """ + self.__enforce_handoff = flag + return self + def build(self): return SdkConfig( self.__allowed_capture_methods, @@ -332,4 +360,5 @@ def build(self): self.__error_url, self.__allow_handoff, self.__privacy_policy_url, + self.__enforce_handoff, ) diff --git a/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py b/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py index d621a441..65d39685 100644 --- a/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py +++ b/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py @@ -16,6 +16,7 @@ class SdkConfigTest(unittest.TestCase): SOME_ERROR_URL = "https://mysite.com/yoti/error" SOME_PRIVACY_POLICY_URL = "https://mysite.com/privacy" SOME_ALLOW_HANDOFF = True + SOME_ENFORCE_HANDOFF = True def test_should_build_correctly(self): result = ( @@ -30,6 +31,7 @@ def test_should_build_correctly(self): .with_error_url(self.SOME_ERROR_URL) .with_privacy_policy_url(self.SOME_PRIVACY_POLICY_URL) .with_allow_handoff(self.SOME_ALLOW_HANDOFF) + .with_enforce_handoff(self.SOME_ENFORCE_HANDOFF) .build() ) @@ -44,6 +46,7 @@ def test_should_build_correctly(self): assert result.error_url is self.SOME_ERROR_URL assert result.privacy_policy_url is self.SOME_PRIVACY_POLICY_URL assert result.allow_handoff is True + assert result.enforce_handoff is True def test_should_allows_camera(self): result = SdkConfigBuilder().with_allows_camera().build() @@ -60,6 +63,45 @@ def test_passing_allow_handoff_false_value(self): assert result.allow_handoff is False + def test_not_passing_enforce_handoff(self): + result = SdkConfigBuilder().with_allows_camera().build() + + assert result.enforce_handoff is None + + def test_passing_enforce_handoff_true_value(self): + result = SdkConfigBuilder().with_enforce_handoff(True).build() + + assert result.enforce_handoff is True + + def test_passing_enforce_handoff_false_value(self): + result = SdkConfigBuilder().with_enforce_handoff(False).build() + + assert result.enforce_handoff is False + + def test_enforce_handoff_with_allow_handoff_both_true(self): + result = ( + SdkConfigBuilder() + .with_allow_handoff(True) + .with_enforce_handoff(True) + .build() + ) + + assert result.allow_handoff is True + assert result.enforce_handoff is True + + def test_enforce_handoff_serializes_to_json(self): + result = ( + SdkConfigBuilder() + .with_allows_camera() + .with_allow_handoff(True) + .with_enforce_handoff(True) + .build() + ) + + json_data = result.to_json() + assert json_data["allow_handoff"] is True + assert json_data["enforce_handoff"] is True + def test_should_serialize_to_json_without_error(self): result = ( SdkConfigBuilder()