File: test_xrires.py

package info (click to toggle)
python3-openid 3.0.2%2Bgit20140828-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,672 kB
  • ctags: 2,679
  • sloc: python: 17,137; xml: 234; sh: 15; makefile: 4
file content (40 lines) | stat: -rw-r--r-- 1,647 bytes parent folder | download | duplicates (2)
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.assertEqual(h + '=foo?' + args_esc, pqu('=foo', st))
        self.assertEqual(h + '=foo/bar?baz&' + args_esc,
                             pqu('=foo/bar?baz', st))
        self.assertEqual(h + '=foo/bar?baz=quux&' + args_esc,
                             pqu('=foo/bar?baz=quux', st))
        self.assertEqual(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.assertEqual(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.assertEqual(h + '=foo/bar??' + args_esc, pqu('=foo/bar?', st))
        self.assertEqual(h + '=foo/bar????' + args_esc,
                             pqu('=foo/bar???', st))