From 7b458bef0ca7625d09a87bde5e906b50a66a59a2 Mon Sep 17 00:00:00 2001 From: tpazderka Date: Thu, 7 Dec 2017 16:44:51 +0100 Subject: [PATCH] Fix creation of error on client registration (#450) Close #449 --- CHANGELOG.md | 2 ++ src/oic/oic/provider.py | 2 +- tests/test_oic_provider.py | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04a7e0642..89d0ed626 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on the [KeepAChangeLog] project. - [#399] Matching response_types for authz requests is too strict - [#436] Fixed client.read_registration - [#446] Fixed provider.read_registration +- [#449] Fixed creation of error_response on client registration [#430]: https://github.com/OpenIDC/pyoidc/pull/430 [#427]: https://github.com/OpenIDC/pyoidc/pull/427 @@ -23,6 +24,7 @@ The format is based on the [KeepAChangeLog] project. [#436]: https://github.com/OpenIDC/pyoidc/pull/436 [#443]: https://github.com/OpenIDC/pyoidc/pull/443 [#446]: https://github.com/OpenIDC/pyoidc/issues/446 +[#449]: https://github.com/OpenIDC/pyoidc/issues/449 ## 0.12.0 [2017-09-25] diff --git a/src/oic/oic/provider.py b/src/oic/oic/provider.py index 7f83f4ebe..b3f124cc2 100644 --- a/src/oic/oic/provider.py +++ b/src/oic/oic/provider.py @@ -1356,7 +1356,7 @@ def do_client_registration(self, request, client_id, ignore=None): try: _cinfo["si_redirects"], _cinfo["sector_id"] = self._verify_sector_identifier(request) except InvalidSectorIdentifier as err: - return error_response("invalid_configuration_parameter", descr=err) + return error_response("invalid_configuration_parameter", descr=str(err)) elif "redirect_uris" in request: if len(request["redirect_uris"]) > 1: # check that the hostnames are the same diff --git a/tests/test_oic_provider.py b/tests/test_oic_provider.py index 4d7119599..8d7e70241 100644 --- a/tests/test_oic_provider.py +++ b/tests/test_oic_provider.py @@ -799,6 +799,18 @@ def test_registration_endpoint_unicode(self): 'client_id', 'client_secret', 'client_id_issued_at', 'response_types']) + def test_do_client_registration_invalid_sector_uri(self): + rr = RegistrationRequest(operation='register', sector_identifier_uri='https://example.com', + redirect_uris=['http://example.com/changed']) + redirects = ['http://example.com/present'] + with responses.RequestsMock() as rsps: + rsps.add(rsps.GET, 'https://example.com', body=json.dumps(redirects)) + resp = self.provider.do_client_registration(rr, 'client0') + + assert resp.status == '400 Bad Request' + error = json.loads(resp.message) + assert error['error'] == 'invalid_configuration_parameter' + def test_registration_endpoint_with_non_https_redirect_uri_implicit_flow( self): params = {"application_type": "web",