File: test_xrires.py

package info (click to toggle)
python3-openid 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,668 kB
  • sloc: python: 17,486; xml: 234; makefile: 5
file content (37 lines) | stat: -rw-r--r-- 1,604 bytes parent folder | download | duplicates (4)
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
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))