diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2019-05-16 11:22:43 +0200 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2019-05-16 13:12:54 +0200 |
commit | 6acaf874537ea4772b3d2c4a3f760612cfc26055 (patch) | |
tree | 5d33e681f3a99cadc1eba6f6f894fb20ce72c815 | |
parent | ab58c44b427efd9265ac7a562785480518f21583 (diff) | |
download | pysaml2-6acaf874537ea4772b3d2c4a3f760612cfc26055.tar.gz |
Simplify Base::create_discovery_service_request method
Allow values of None in the collected information.
Filter out those fields later.
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r-- | src/saml2/client_base.py | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/saml2/client_base.py b/src/saml2/client_base.py index 15e3b0ec..f90c4378 100644 --- a/src/saml2/client_base.py +++ b/src/saml2/client_base.py @@ -913,28 +913,21 @@ class Base(Entity): :return: A URL """ - args = {"entityID": entity_id} - for key in ["policy", "returnIDParam"]: - try: - args[key] = kwargs[key] - except KeyError: - pass - - try: - args["return"] = kwargs["return_url"] - except KeyError: - try: - args["return"] = kwargs["return"] - except KeyError: - pass - - if "isPassive" in kwargs: - if kwargs["isPassive"]: - args["isPassive"] = "true" - else: - args["isPassive"] = "false" + args = { + "entityID": entity_id, + "policy": kwargs.get("policy"), + "returnIDParam": kwargs.get("returnIDParam"), + "return": kwargs.get("return_url") or kwargs.get("return"), + "isPassive": ( + None + if "isPassive" not in kwargs.keys() + else "true" + if kwargs.get("isPassive") + else "false" + ), + } - params = urlencode(args) + params = urlencode({k: v for k, v in args.items() if v}) return "%s?%s" % (url, params) @staticmethod |