Skip to content

Commit

Permalink
Remove at-least-one-field-must-be-set restriction
Browse files Browse the repository at this point in the history
Signed-off-by: Ada <[email protected]>
  • Loading branch information
ada-globus committed Jun 12, 2024
1 parent 461ad71 commit 6a2d8e2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Changed
~~~~~~~

- ``GlobusAuthorizationParameters`` no longer enforces that at least one
field is set. (:pr:`NUMBER`)
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@ def __init__(
self.prompt = _validators.opt_str("prompt", prompt)
self.extra = extra or {}

# Enforce that the error contains at least one of the fields we expect
requires_at_least_one = [
name for name in self._supported_fields() if name != "session_message"
]
if all(
getattr(self, field_name) is None for field_name in requires_at_least_one
):
raise _validators.ValidationError(
"Must include at least one supported authorization parameter: "
+ ", ".join(requires_at_least_one)
)


class GlobusAuthRequirementsError(_serializable.Serializable):
"""
Expand Down
12 changes: 0 additions & 12 deletions src/globus_sdk/experimental/auth_requirements_error/_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,6 @@ def __init__(
raise _validators.ValidationError("'prompt' must be 'login' or null")
self.extra = extra or {}

# Enforce that the error contains at least one of the fields we expect
requires_at_least_one = [
name for name in self._supported_fields() if name != "session_message"
]
if all(
getattr(self, field_name) is None for field_name in requires_at_least_one
):
raise _validators.ValidationError(
"Must include at least one supported authorization parameter: "
+ ", ".join(requires_at_least_one)
)

def to_authorization_parameters(
self,
) -> GlobusAuthorizationParameters:
Expand Down
10 changes: 3 additions & 7 deletions tests/unit/experimental/test_auth_requirements_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,7 @@ def test_error_from_dict_insufficient_input(target_class, data, expect_message):
_variants.LegacyAuthorizationParameters,
],
)
def test_authorization_parameters_from_dict_insufficient_input(target_class):
def test_authorization_parameters_from_empty_dict(target_class):
""" """
with pytest.raises(ValueError) as exc_info:
target_class.from_dict({})

assert "Must include at least one supported authorization parameter" in str(
exc_info.value
)
authorization_params = target_class.from_dict({})
assert authorization_params.to_dict() == {}

0 comments on commit 6a2d8e2

Please sign in to comment.