File: test_xrires.py

package info (click to toggle)
python-openid 2.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,472 kB
  • ctags: 3,328
  • sloc: python: 16,708; xml: 234; sh: 38; makefile: 30
file content (40 lines) | stat: -rw-r--r-- 1,675 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

from unittest import TestCase
from openid.yadis import xrires

class ProxyQueryTestCase(TestCase):
    def setUp(self):
        self.proxy_url = 'http://xri.example.com/'
        self.proxy = xrires.ProxyResolver(self.proxy_url)
        self.servicetype = 'xri://+i-service*(+forwarding)*($v*1.0)'
        self.servicetype_enc = 'xri%3A%2F%2F%2Bi-service%2A%28%2Bforwarding%29%2A%28%24v%2A1.0%29'


    def test_proxy_url(self):
        st = self.servicetype
        ste = self.servicetype_enc
        args_esc = "_xrd_r=application%2Fxrds%2Bxml&_xrd_t=" + ste
        pqu = self.proxy.queryURL
        h = self.proxy_url
        self.failUnlessEqual(h + '=foo?' + args_esc, pqu('=foo', st))
        self.failUnlessEqual(h + '=foo/bar?baz&' + args_esc,
                             pqu('=foo/bar?baz', st))
        self.failUnlessEqual(h + '=foo/bar?baz=quux&' + args_esc,
                             pqu('=foo/bar?baz=quux', st))
        self.failUnlessEqual(h + '=foo/bar?mi=fa&so=la&' + args_esc,
                             pqu('=foo/bar?mi=fa&so=la', st))

        # With no service endpoint selection.
        args_esc = "_xrd_r=application%2Fxrds%2Bxml%3Bsep%3Dfalse"
        self.failUnlessEqual(h + '=foo?' + args_esc, pqu('=foo', None))


    def test_proxy_url_qmarks(self):
        st = self.servicetype
        ste = self.servicetype_enc
        args_esc = "_xrd_r=application%2Fxrds%2Bxml&_xrd_t=" + ste
        pqu = self.proxy.queryURL
        h = self.proxy_url
        self.failUnlessEqual(h + '=foo/bar??' + args_esc, pqu('=foo/bar?', st))
        self.failUnlessEqual(h + '=foo/bar????' + args_esc,
                             pqu('=foo/bar???', st))