Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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))
Exemple #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)
Exemple #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))
Exemple #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)