Skip to content
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
3 changes: 2 additions & 1 deletion oauthlib/oauth2/rfc6749/endpoints/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def create_metadata_response(self, uri, http_method='GET', body=None,
"""Create metadata response
"""
headers = {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
}
return headers, json.dumps(self.claims), 200

Expand Down
15 changes: 15 additions & 0 deletions tests/oauth2/rfc6749/endpoints/test_metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from oauthlib.oauth2 import MetadataEndpoint, Server, TokenEndpoint

import json
from tests.unittest import TestCase


Expand Down Expand Up @@ -37,6 +38,20 @@ def test_openid_oauth2_preconfigured(self):
self.maxDiff = None
self.assertEqual(openid_claims, oauth2_claims)

def test_create_metadata_response(self):
endpoint = TokenEndpoint(None, None, grant_types={"password": None})
metadata = MetadataEndpoint([endpoint], {
"issuer": 'https://foo.bar',
"token_endpoint": "https://foo.bar/token"
})
headers, body, status = metadata.create_metadata_response('/', 'GET')
assert headers == {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
}
claims = json.loads(body)
assert claims['issuer'] == 'https://foo.bar'

def test_token_endpoint(self):
endpoint = TokenEndpoint(None, None, grant_types={"password": None})
metadata = MetadataEndpoint([endpoint], {
Expand Down