Changeset c6d4701 in mod_gnutls


Ignore:
Timestamp:
Mar 10, 2021, 3:25:32 AM (6 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master
Children:
520ab08
Parents:
3d7865f
Message:

mgstest.tests.TestRequest?: Move tests to unittest

The tests previously done via doctest didn't really document
anything. Running them via unittest is more flexible and might allow
for future extensions.

Location:
test
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • test/Makefile.am

    r3d7865f rc6d4701  
    5050TEST_EXTENSIONS = .bash .py
    5151PY_LOG_COMPILER = $(PYTHON)
    52 TESTS = doctest-mgstest.py $(test_scripts)
     52TESTS = doctest-mgstest.py unittest-mgstest.py $(test_scripts)
    5353
    5454check_PROGRAMS = pgpcrc
     
    6767noinst_PYTHON = https-test-client.py mgstest/http.py mgstest/__init__.py \
    6868        mgstest/hooks.py mgstest/ocsp.py mgstest/services.py \
    69         mgstest/softhsm.py mgstest/tests.py mgstest/valgrind.py runtest.py \
    70         softhsm-init.py doctest-mgstest.py required-modules.py data/ocsp.py \
    71         check_test_ips.py
     69        mgstest/softhsm.py mgstest/tests.py mgstest/valgrind.py \
     70        mgstest/test_tests.py runtest.py \
     71        softhsm-init.py doctest-mgstest.py unittest-mgstest.py \
     72        required-modules.py data/ocsp.py check_test_ips.py
    7273
    7374# Identities in the miniature CA, server, and client environment for
  • test/mgstest/tests.py

    r3d7865f rc6d4701  
    251251
    252252    def check_headers(self, headers):
    253         """
    254         >>> r1 = TestRequest(path='/test.txt',
    255         ...                  expect={'headers': {'X-Forbidden-Header': None,
    256         ...                                      'X-Required-Header': 'Hi!'}})
    257         >>> r1.check_headers({'X-Required-Header': 'Hi!'})
    258         >>> r1.check_headers({'X-Required-Header': 'Hello!'})
    259         Traceback (most recent call last):
    260         ...
    261         mgstest.TestExpectationFailed: Unexpected value in header \
    262 X-Required-Header: 'Hello!', expected 'Hi!'
    263         >>> r1.check_headers({'X-Forbidden-Header': 'Hi!'})
    264         Traceback (most recent call last):
    265         ...
    266         mgstest.TestExpectationFailed: Unexpected value in header \
    267 X-Forbidden-Header: 'Hi!', expected None
    268         """
    269253        for name, expected in self.expect['headers'].items():
    270254            value = headers.get(name)
     
    276260
    277261    def check_body(self, body):
    278         """
    279         >>> r1 = TestRequest(path='/test.txt', method='GET', headers={}, \
    280 expect={'status': 200, 'body': {'exactly': 'test\\n'}})
    281         >>> r1.check_body('test\\n')
    282         >>> r1.check_body('xyz\\n')
    283         Traceback (most recent call last):
    284         ...
    285         mgstest.TestExpectationFailed: Unexpected body: 'xyz\\n' != 'test\\n'
    286         >>> r2 = TestRequest(path='/test.txt', method='GET', headers={}, \
    287 expect={'status': 200, 'body': {'contains': ['tes', 'est']}})
    288         >>> r2.check_body('test\\n')
    289         >>> r2.check_body('est\\n')
    290         Traceback (most recent call last):
    291         ...
    292         mgstest.TestExpectationFailed: Unexpected body: 'est\\n' \
    293 does not contain 'tes'
    294         >>> r3 = TestRequest(path='/test.txt', method='GET', headers={}, \
    295 expect={'status': 200, 'body': {'contains': 'test'}})
    296         >>> r3.check_body('test\\n')
    297         """
    298262        if 'exactly' in self.expect['body'] \
    299263           and body != self.expect['body']['exactly']:
     
    328292        connection being reset. That usually means the underlying TLS
    329293        connection failed.
    330 
    331         >>> r1 = TestRequest(path='/test.txt', method='GET', headers={}, \
    332 expect={'status': 200, 'body': {'contains': 'test'}})
    333         >>> r1.expects_conn_reset()
    334         False
    335         >>> r2 = TestRequest(path='/test.txt', method='GET', headers={}, \
    336 expect={'reset': True})
    337         >>> r2.expects_conn_reset()
    338         True
    339294        """
    340295        if 'reset' in self.expect:
Note: See TracChangeset for help on using the changeset viewer.