Skip to content

Commit 8d6470e

Browse files
committed
Accept a list as a response
1 parent 49a0f60 commit 8d6470e

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/idpyoidc/client/service.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def get_urlinfo(info):
496496

497497
def post_parse_response(self, response, **kwargs):
498498
"""
499-
This method does post processing of the service response.
499+
This method does post-processing of the service response.
500500
Each service have their own version of this method.
501501
502502
:param response: The service response
@@ -542,6 +542,9 @@ def _do_jwt(self, info):
542542
def _do_response(self, info, sformat, **kwargs):
543543
_context = self.upstream_get("context")
544544

545+
if isinstance(info, list): # Don't have support for sformat=list
546+
return info
547+
545548
try:
546549
resp = self.response_cls().deserialize(info, sformat, iss=_context.issuer, **kwargs)
547550
except Exception as err:
@@ -569,7 +572,7 @@ def parse_response(
569572
state: Optional[str] = "",
570573
behaviour_args: Optional[dict] = None,
571574
**kwargs,
572-
):
575+
) :
573576
"""
574577
This the start of a pipeline that will:
575578
@@ -631,22 +634,27 @@ def parse_response(
631634
LOGGER.debug("response_cls: %s", self.response_cls.__name__)
632635

633636
if resp is None:
634-
if not info:
637+
if self.response_cls == list and info == []:
638+
return info
639+
elif not info:
635640
LOGGER.error("Missing or faulty response")
636641
raise ResponseError("Missing or faulty response")
637642

638643
if sformat == "text":
639644
resp = info
640645
else:
641646
resp = self._do_response(info, sformat, **kwargs)
642-
LOGGER.debug('Initial response parsing => "%s"', resp.to_dict())
647+
if isinstance(resp, Message):
648+
LOGGER.debug(f'Initial response parsing => "{resp.to_dict()}"')
649+
else:
650+
LOGGER.debug(f'Initial response parsing => "{resp}"')
643651

644652
# is this an error message
645653
if sformat == "text":
646654
pass
647655
elif is_error_message(resp):
648656
LOGGER.debug("Error response: %s", resp)
649-
else:
657+
elif isinstance(resp, Message):
650658
vargs = self.gather_verify_arguments(response=resp, behaviour_args=behaviour_args)
651659
LOGGER.debug("Verify response with %s", vargs)
652660
try:

tests/test_server_20d_client_authn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def test_jws_authn_method_aud_token_endpoint(self):
358358
def test_jws_authn_method_aud_not_me(self):
359359
client_keyjar = KeyJar()
360360
client_keyjar.import_jwks(KEYJAR.export_jwks(private=True), CONF["issuer"])
361-
# The only own key the client has a this point
361+
# The only own key the client has at this point
362362
client_keyjar.add_symmetric("", client_secret, ["sig"])
363363

364364
_jwt = JWT(client_keyjar, iss=client_id, sign_alg="HS256")

0 commit comments

Comments
 (0)