Browse files

- Fix in discovery if response does not have content-type header

- Add test for assoc_type in openid2
  • Loading branch information...
1 parent 9c3c55f commit 8ced77c4d031020c61fcb5d48ea187c5f846ca1e @ziima ziima committed Mar 25, 2011
Showing with 13 additions and 1 deletion.
  1. +10 −0 openid/test/test_server.py
  2. +3 −1 openid/yadis/discover.py
View
10 openid/test/test_server.py
@@ -1781,6 +1781,16 @@ def test_missingSessionTypeOpenID2(self):
self.assertRaises(server.ProtocolError,
server.AssociateRequest.fromMessage, msg)
+ def test_missingAssocTypeOpenID2(self):
+ """Make sure assoc_type is required in OpenID 2"""
+ msg = Message.fromPostArgs({
+ 'openid.ns': OPENID2_NS,
+ 'openid.session_type': 'no-encryption',
+ })
+
+ self.assertRaises(server.ProtocolError,
+ server.AssociateRequest.fromMessage, msg)
+
def test_checkAuth(self):
request = server.CheckAuthRequest('arrrrrf', '0x3999', [])
response = self.server.openid_check_authentication(request)
View
4 openid/yadis/discover.py
@@ -127,12 +127,14 @@ def whereIsYadis(resp):
# have a whitelist or a blacklist (for detecting that it's
# HTML)?
- # decode body by encoding of file
+ # Decode body by encoding of file
+ content_type = content_type or ''
encoding = content_type.rsplit(';', 1)
if len(encoding) == 2 and encoding[1].strip().startswith('charset='):
encoding = encoding[1].split('=', 1)[1]
else:
encoding = 'UTF-8'
+
try:
content = resp.body.decode(encoding)
except UnicodeError:

0 comments on commit 8ced77c

Please sign in to comment.