diff --git a/changelog.d/20231025_125551_sirosen_introduce_missingtype.rst b/changelog.d/20231025_125551_sirosen_introduce_missingtype.rst new file mode 100644 index 000000000..b49eb3a1f --- /dev/null +++ b/changelog.d/20231025_125551_sirosen_introduce_missingtype.rst @@ -0,0 +1,5 @@ +Changed +~~~~~~~ + +- ``GroupPolicies`` objects now treat an explicit instantiation with + ``high_assurance_timeout=None`` as setting the timeout to ``null`` (:pr:`NUMBER`) diff --git a/src/globus_sdk/services/groups/data.py b/src/globus_sdk/services/groups/data.py index 8760c58fd..a3d3dded7 100644 --- a/src/globus_sdk/services/groups/data.py +++ b/src/globus_sdk/services/groups/data.py @@ -263,7 +263,9 @@ def __init__( group_members_visibility: _GROUP_MEMBER_VISIBILITY_T, join_requests: bool, signup_fields: t.Iterable[_GROUP_REQUIRED_SIGNUP_FIELDS_T], - authentication_assurance_timeout: int | None = None, + authentication_assurance_timeout: int + | None + | utils.MissingType = utils.MISSING, ): super().__init__() self["is_high_assurance"] = is_high_assurance @@ -273,5 +275,5 @@ def __init__( ) self["join_requests"] = join_requests self["signup_fields"] = utils.render_enums_for_api(signup_fields) - if authentication_assurance_timeout is not None: + if authentication_assurance_timeout is not utils.MISSING: self["authentication_assurance_timeout"] = authentication_assurance_timeout diff --git a/tests/unit/helpers/test_groups.py b/tests/unit/helpers/test_groups.py new file mode 100644 index 000000000..f76f74021 --- /dev/null +++ b/tests/unit/helpers/test_groups.py @@ -0,0 +1,28 @@ +from globus_sdk import GroupPolicies + + +def test_group_policies_can_explicitly_null_ha_timeout(): + # step 1: confirm that the auth assurance timeout is not in the baseline + # doc which does not specify it + kwargs = { + "is_high_assurance": True, + "group_visibility": "private", + "group_members_visibility": "members", + "join_requests": False, + "signup_fields": [], + } + baseline = GroupPolicies(**kwargs) + assert isinstance(baseline, GroupPolicies) + assert "authentication_assurance_timeout" not in baseline + + # step 2: confirm that the auth assurance timeout is in the doc when + # set to an integer value, even 0 + kwargs["authentication_assurance_timeout"] = 0 + with_falsy_timeout = GroupPolicies(**kwargs) + assert with_falsy_timeout["authentication_assurance_timeout"] == 0 + + # step 3: confirm that the auth assurance timeout is in the doc when + # set to None + kwargs["authentication_assurance_timeout"] = None + with_null_timeout = GroupPolicies(**kwargs) + assert with_null_timeout["authentication_assurance_timeout"] is None