~gary/python-openid/python-openid-2.2.1-patched

« back to all changes in this revision

Viewing changes to openid/test/test_openidyadis.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2007-11-30 02:46:28 UTC
  • mfrom: (1.1.1 pyopenid-2.0)
  • Revision ID: launchpad@pqm.canonical.com-20071130024628-qktwsew3383iawmq
[rs=SteveA] upgrade to python-openid-2.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import unittest
2
2
from openid.consumer.discover import \
3
 
     OpenIDServiceEndpoint, OPENID_1_2_TYPE, OPENID_1_1_TYPE, OPENID_1_0_TYPE
 
3
     OpenIDServiceEndpoint, OPENID_1_1_TYPE, OPENID_1_0_TYPE
4
4
 
5
 
from yadis.services import applyFilter
 
5
from openid.yadis.services import applyFilter
6
6
 
7
7
 
8
8
XRDS_BOILERPLATE = '''\
19
19
def mkXRDS(services):
20
20
    return XRDS_BOILERPLATE % (services,)
21
21
 
22
 
def mkService(uris=None, type_uris=None, delegate=None, dent='        '):
 
22
def mkService(uris=None, type_uris=None, local_id=None, dent='        '):
23
23
    chunks = [dent, '<Service>\n']
24
24
    dent2 = dent + '    '
25
25
    if type_uris:
38
38
                chunks.extend([' priority="', str(prio), '"'])
39
39
            chunks.extend(['>', uri, '</URI>\n'])
40
40
 
41
 
    if delegate:
 
41
    if local_id:
42
42
        chunks.extend(
43
 
            [dent2, '<openid:Delegate>', delegate, '</openid:Delegate>\n'])
 
43
            [dent2, '<openid:Delegate>', local_id, '</openid:Delegate>\n'])
44
44
 
45
45
    chunks.extend([dent, '</Service>\n'])
46
46
 
77
77
    exts + ts
78
78
 
79
79
    # All non-empty sublists of the valid OpenID type URIs
80
 
    for ts in subsets([OPENID_1_0_TYPE, OPENID_1_1_TYPE, OPENID_1_2_TYPE])
 
80
    for ts in subsets([OPENID_1_0_TYPE, OPENID_1_1_TYPE])
81
81
    if ts
82
82
 
83
83
    # All combinations of extension types (including empty extenstion list)
85
85
    ]
86
86
 
87
87
# Range of valid Delegate tag values for generating test data
88
 
delegate_options = [
 
88
local_id_options = [
89
89
    None,
90
90
    'http://vanity.domain/',
91
91
    'https://somewhere/yadis/',
93
93
 
94
94
# All combinations of valid URIs, Type URIs and Delegate tags
95
95
data = [
96
 
    (uris, type_uris, delegate)
 
96
    (uris, type_uris, local_id)
97
97
    for uris in server_url_options
98
98
    for type_uris in type_uri_options
99
 
    for delegate in delegate_options
 
99
    for local_id in local_id_options
100
100
    ]
101
101
 
102
102
class OpenIDYadisTest(unittest.TestCase):
103
 
    def __init__(self, uris, type_uris, delegate):
 
103
    def __init__(self, uris, type_uris, local_id):
104
104
        unittest.TestCase.__init__(self)
105
105
        self.uris = uris
106
106
        self.type_uris = type_uris
107
 
        self.delegate = delegate
 
107
        self.local_id = local_id
108
108
 
109
109
    def shortDescription(self):
110
110
        # XXX:
116
116
        # Create an XRDS document to parse
117
117
        services = mkService(uris=self.uris,
118
118
                             type_uris=self.type_uris,
119
 
                             delegate=self.delegate)
 
119
                             local_id=self.local_id)
120
120
        self.xrds = mkXRDS(services)
121
121
 
122
122
    def runTest(self):
138
138
            seen_uris.append(endpoint.server_url)
139
139
 
140
140
            # All endpoints will have same yadis_url
141
 
            self.failUnlessEqual(self.yadis_url, endpoint.identity_url)
 
141
            self.failUnlessEqual(self.yadis_url, endpoint.claimed_id)
142
142
 
143
 
            # and delegate
144
 
            self.failUnlessEqual(self.delegate, endpoint.delegate)
 
143
            # and local_id
 
144
            self.failUnlessEqual(self.local_id, endpoint.local_id)
145
145
 
146
146
            # and types
147
147
            actual_types = list(endpoint.type_uris)