Skip to content

Commit

Permalink
Default to MISSING for GroupPolicies ha timeout
Browse files Browse the repository at this point in the history
By defaulting to `MISSING`, we make it possible to treat an explicit
`None` as a request for `null` in the payload.
  • Loading branch information
sirosen committed Oct 25, 2023
1 parent de90985 commit 53009d9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog.d/20231025_125551_sirosen_introduce_missingtype.rst
Original file line number Diff line number Diff line change
@@ -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`)
6 changes: 4 additions & 2 deletions src/globus_sdk/services/groups/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
28 changes: 28 additions & 0 deletions tests/unit/helpers/test_groups.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 53009d9

Please sign in to comment.