(self, req, **kwargs)
| 82 | |
| 83 | class TestApp(webtest.TestApp): |
| 84 | def do_request(self, req, **kwargs): |
| 85 | self.cookiejar.clear() |
| 86 | |
| 87 | if req.environ["REQUEST_METHOD"] != "OPTIONS": |
| 88 | # Making sure endpoint handles OPTIONS method properly |
| 89 | self.options(req.environ["PATH_INFO"]) |
| 90 | |
| 91 | res = super(TestApp, self).do_request(req, **kwargs) |
| 92 | |
| 93 | if res.headers.get("Warning", None): |
| 94 | raise ResponseValidationError( |
| 95 | "Endpoint produced invalid response. Make sure the " |
| 96 | "response matches OpenAPI scheme for the endpoint." |
| 97 | ) |
| 98 | |
| 99 | if not kwargs.get("expect_errors", None): |
| 100 | try: |
| 101 | body = res.body |
| 102 | except AssertionError as e: |
| 103 | if "Iterator read after closed" in six.text_type(e): |
| 104 | body = b"" |
| 105 | else: |
| 106 | raise e |
| 107 | |
| 108 | if ( |
| 109 | six.b(SUPER_SECRET_PARAMETER) in body |
| 110 | or six.b(ANOTHER_SUPER_SECRET_PARAMETER) in body |
| 111 | ): |
| 112 | raise ResponseLeakError( |
| 113 | "Endpoint response contains secret parameter. " "Find the leak." |
| 114 | ) |
| 115 | |
| 116 | if "Access-Control-Allow-Origin" not in res.headers: |
| 117 | raise ResponseValidationError("Response missing a required CORS header") |
| 118 | |
| 119 | return res |
| 120 | |
| 121 | |
| 122 | class BaseFunctionalTest(DbTestCase): |
nothing calls this directly
no test coverage detected