Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove at-least-one-field-must-be-set restriction #989

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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() == {}