@@ -609,6 +609,58 @@ def test_canonicalID(self):
609609 def test_serverURL (self ):
610610 self .failUnlessEqual (self .endpoint .server_url , self .op_endpoint_url )
611611
612+ class TestEndpointSupportsType (unittest .TestCase ):
613+ def setUp (self ):
614+ self .endpoint = discover .OpenIDServiceEndpoint ()
615+
616+ def failUnlessSupportsOnly (self , * types ):
617+ for t in [
618+ 'foo' ,
619+ discover .OPENID_1_1_TYPE ,
620+ discover .OPENID_1_0_TYPE ,
621+ discover .OPENID_2_0_TYPE ,
622+ discover .OPENID_IDP_2_0_TYPE ,
623+ ]:
624+ if t in types :
625+ self .failUnless (self .endpoint .supportsType (t ))
626+ else :
627+ self .failIf (self .endpoint .supportsType (t ))
628+
629+ def test_supportsNothing (self ):
630+ self .failUnlessSupportsOnly ()
631+
632+ def test_openid2 (self ):
633+ self .endpoint .type_uris = [discover .OPENID_2_0_TYPE ]
634+ self .failUnlessSupportsOnly (discover .OPENID_2_0_TYPE )
635+
636+ def test_openid2provider (self ):
637+ self .endpoint .type_uris = [discover .OPENID_IDP_2_0_TYPE ]
638+ self .failUnlessSupportsOnly (discover .OPENID_IDP_2_0_TYPE ,
639+ discover .OPENID_2_0_TYPE )
640+
641+ def test_openid1_0 (self ):
642+ self .endpoint .type_uris = [discover .OPENID_1_0_TYPE ]
643+ self .failUnlessSupportsOnly (discover .OPENID_1_0_TYPE )
644+
645+ def test_openid1_1 (self ):
646+ self .endpoint .type_uris = [discover .OPENID_1_1_TYPE ]
647+ self .failUnlessSupportsOnly (discover .OPENID_1_1_TYPE )
648+
649+ def test_multiple (self ):
650+ self .endpoint .type_uris = [discover .OPENID_1_1_TYPE ,
651+ discover .OPENID_2_0_TYPE ]
652+ self .failUnlessSupportsOnly (discover .OPENID_1_1_TYPE ,
653+ discover .OPENID_2_0_TYPE )
654+
655+ def test_multipleWithProvider (self ):
656+ self .endpoint .type_uris = [discover .OPENID_1_1_TYPE ,
657+ discover .OPENID_2_0_TYPE ,
658+ discover .OPENID_IDP_2_0_TYPE ]
659+ self .failUnlessSupportsOnly (discover .OPENID_1_1_TYPE ,
660+ discover .OPENID_2_0_TYPE ,
661+ discover .OPENID_IDP_2_0_TYPE ,
662+ )
663+
612664def pyUnitTests ():
613665 return datadriven .loadTests (__name__ )
614666
0 commit comments