Skip to content

Commit

Permalink
Merge pull request #406 from OpenIDC/405-endpoint_urls
Browse files Browse the repository at this point in the history
Fix generation of endpoint urls
  • Loading branch information
tpazderka authored Aug 11, 2017
2 parents 58a8097 + dddd054 commit cc9368d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ The format is based on the [KeepAChangeLog] project.

[KeepAChangeLog]: http://keepachangelog.com/

## 0.11.1.0 [Unreleased]

### Fixed
- [#405]: Fix generation of endpoint urls

[#405]: https://github.com.OpenIDC/pyoidc/issues/405

## 0.11.0.0 [2017-07-07]

### Changed
Expand Down
8 changes: 5 additions & 3 deletions src/oic/oic/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,11 @@ def create_providerinfo(self, pcr_class=ProviderConfigurationResponse,

for endp in self.endp:
# _log_info("# %s, %s" % (endp, endp.name))
_provider_info['{}_endpoint'.format(endp.etype)] = '{}/{}'.format(
self.baseurl,
endp.url)
if not self.baseurl.endswith('/'):
baseurl = self.baseurl + '/'
else:
baseurl = self.baseurl
_provider_info['{}_endpoint'.format(endp.etype)] = urljoin(baseurl, endp.url)

if setup and isinstance(setup, dict):
for key in pcr_class.c_param.keys():
Expand Down
10 changes: 10 additions & 0 deletions tests/test_oic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ def create_provider(self, session_db_factory):
"request_object_signing_alg": DEF_SIGN_ALG["openid_request_object"]}
self.cons.keyjar[""] = KC_RSA

def test_providerinfo(self):
self.provider.baseurl = 'http://example.com/path1/path2'
resp = self.provider.create_providerinfo()
assert resp.to_dict()['authorization_endpoint'] == 'http://example.com/path1/path2/authorization'

def test_providerinfo_trailing(self):
self.provider.baseurl = 'http://example.com/path1/path2/'
resp = self.provider.create_providerinfo()
assert resp.to_dict()['authorization_endpoint'] == 'http://example.com/path1/path2/authorization'

def test_authorization_endpoint(self):
bib = {"scope": ["openid"],
"state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
Expand Down

0 comments on commit cc9368d

Please sign in to comment.