@@ -46,10 +46,20 @@ def get(self):
4646
4747
4848class OpenIdServerAuthenticateHandler (RequestHandler ):
49+ flip_flop = False
50+
4951 def post (self ):
5052 if self .get_argument ("openid.mode" ) != "check_authentication" :
5153 raise Exception ("incorrect openid.mode %r" )
52- self .write ("is_valid:true" )
54+ # Cover both orderings of the response parameters if we call this handler twice.
55+ # (the flip_flop side effect is simpler than plumbing parameters around).
56+ # We check both orderings to catch mistaken uses of re.match instead of re.search
57+ # or incorrect matching of the newline characters.
58+ if type (self ).flip_flop :
59+ self .write ("is_valid:true\n ns:http://specs.openid.net/auth/2.0\n " )
60+ else :
61+ self .write ("ns:http://specs.openid.net/auth/2.0\n is_valid:true\n " )
62+ type(self ).flip_flop = not type (self ).flip_flop
5363
5464
5565class OAuth1ClientLoginHandler (RequestHandler , OAuthMixin ):
@@ -344,15 +354,17 @@ def test_openid_redirect(self):
344354 self .assertIn ("/openid/server/authenticate?" , response .headers ["Location" ])
345355
346356 def test_openid_get_user (self ):
347- response = self .fetch (
348- "/openid/client/login?openid.mode=blah"
349- "&openid.ns.ax=http://openid.net/srv/ax/1.0"
350- "&openid.ax.type.email=http://axschema.org/contact/email"
351- 352- )
353- response .rethrow ()
354- parsed = json_decode (response .body )
355- self .
assertEqual (
parsed [
"email" ],
"[email protected] " )
357+ for i in range (2 ):
358+ with self .subTest (i = i ):
359+ response = self .fetch (
360+ "/openid/client/login?openid.mode=blah"
361+ "&openid.ns.ax=http://openid.net/srv/ax/1.0"
362+ "&openid.ax.type.email=http://axschema.org/contact/email"
363+ 364+ )
365+ response .rethrow ()
366+ parsed = json_decode (response .body )
367+ self .
assertEqual (
parsed [
"email" ],
"[email protected] " )
356368
357369 def test_oauth10_redirect (self ):
358370 response = self .fetch ("/oauth10/client/login" , follow_redirects = False )
0 commit comments