etwist/test/unittest_server.py
author Arthur Lutz <arthur.lutz@logilab.fr>
Thu, 04 Apr 2019 14:11:40 +0200
branchtls-sprint
changeset 12561 290f44d445a3
parent 1543 dca9817bb337
child 1977 606923dff11b
permissions -rw-r--r--
Reclosing branch after merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1543
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     1
from cubicweb.devtools.apptest import EnvBasedTC
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     2
from cubicweb.etwist.server import host_prefixed_baseurl
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     3
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     4
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     5
class HostPrefixedBaseURLTC(EnvBasedTC):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     6
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     7
    def _check(self, baseurl, host, waited):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     8
        self.assertEquals(host_prefixed_baseurl(baseurl, host), waited,
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     9
                          'baseurl %s called through host %s should be considered as %s'
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    10
                          % (baseurl, host, waited))
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    11
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    12
    def test1(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    13
        self._check('http://www.cubicweb.org/hg/', 'code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    14
                    'http://code.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    15
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    16
    def test2(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    17
        self._check('http://www.cubicweb.org/hg/', 'cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    18
                    'http://www.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    19
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    20
    def test3(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    21
        self._check('http://cubicweb.org/hg/', 'code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    22
                    'http://code.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    23
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    24
    def test4(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    25
        self._check('http://www.cubicweb.org/hg/', 'localhost',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    26
                    'http://www.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    27
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    28
    def test5(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    29
        self._check('http://www.cubicweb.org/cubes/', 'hg.code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    30
                    'http://hg.code.cubicweb.org/cubes/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    31
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    32
    def test6(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    33
        self._check('http://localhost:8080/hg/', 'code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    34
                    'http://localhost:8080/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    35