Exemplo n.º 1
0
 def test_response_headers_regex_path_match(self):
     handler = core.HeadersResponseHandler()
     self.test.test_data = {'response_headers': {
         'location': '//bar//',
     }}
     self.test.response = {'location': '/foo/bar/baz'}
     self._assert_handler(handler)
Exemplo n.º 2
0
 def test_response_headers_regex(self):
     handler = core.HeadersResponseHandler()
     self.test.test_data = {'response_headers': {
         'content-type': '/text/plain/',
     }}
     self.test.response = {'content-type': 'text/plain; charset=UTF-8'}
     self._assert_handler(handler)
Exemplo n.º 3
0
 def test_response_headers_regex_path_nomatch(self):
     handler = core.HeadersResponseHandler()
     self.test.test_data = {'response_headers': {
         'location': '//bar//',
     }}
     self.test.response = {'location': '/foo/foobar/baz'}
     with self.assertRaises(AssertionError):
         self._assert_handler(handler)
Exemplo n.º 4
0
 def test_response_headers_substitute_esc_regex(self):
     handler = core.HeadersResponseHandler()
     self.test.scheme = 'git+ssh'
     self.test.test_data = {'response_headers': {
         'location': '/^$SCHEME://.*/',
     }}
     self.test.response = {'location': 'git+ssh://example.test'}
     self._assert_handler(handler)
Exemplo n.º 5
0
 def test_response_headers_substitute_regex(self):
     handler = core.HeadersResponseHandler()
     self.test.location = '/foo/bar/'
     self.test.prior = self.test
     self.test.test_data = {'response_headers': {
         'location': '/^$LOCATION/',
     }}
     self.test.response = {'location': '/foo/bar/baz'}
     self._assert_handler(handler)
Exemplo n.º 6
0
    def test_resonse_headers_stringify(self):
        handler = core.HeadersResponseHandler()
        self.test.test_data = {'response_headers': {
            'x-alpha-beta': 2.0,
        }}
        self.test.response = {'x-alpha-beta': '2.0'}
        self._assert_handler(handler)

        self.test.response = {'x-alpha-beta': 2.0}
        self._assert_handler(handler)
Exemplo n.º 7
0
 def test_response_headers_fail_header(self):
     handler = core.HeadersResponseHandler()
     self.test.test_data = {'response_headers': {
         'location': '/somewhere',
     }}
     self.test.response = {'content-type': 'application/json'}
     with self.assertRaises(AssertionError) as failure:
         self._assert_handler(handler)
     self.assertIn("'location' header not present in response:",
                   str(failure.exception))
Exemplo n.º 8
0
 def test_response_headers_substitute_noregex(self):
     handler = core.HeadersResponseHandler()
     self.test.location = '/foo/bar/'
     self.test.prior = self.test
     self.test.test_data = {'response_headers': {
         'location': '$LOCATION',
     }}
     self.test.response = {'location': '/foo/bar/baz'}
     with self.assertRaises(AssertionError):
         self._assert_handler(handler)
Exemplo n.º 9
0
 def test_response_headers_fail_data(self):
     handler = core.HeadersResponseHandler()
     self.test.test_data = {'response_headers': {
         'content-type': 'text/plain',
     }}
     self.test.response = {'content-type': 'application/json'}
     with self.assertRaises(AssertionError) as failure:
         self._assert_handler(handler)
     self.assertIn("Expect header content-type with value text/plain,"
                   " got application/json",
                   str(failure.exception))
Exemplo n.º 10
0
    def test_response_headers(self):
        handler = core.HeadersResponseHandler()
        self.test.response = {'content-type': 'text/plain'}

        self.test.test_data = {'response_headers': {
            'content-type': 'text/plain',
        }}
        self._assert_handler(handler)

        self.test.test_data = {'response_headers': {
            'Content-Type': 'text/plain',
        }}
        self._assert_handler(handler)