| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,7 @@ def get_response(self): | |||
| 26 | 26 | def do_HEAD(s): | |
| 27 | 27 | s.send_response(200) | |
| 28 | 28 | ||
| 29 | - def do_GET(s): | ||
| 29 | + def do_POST(s): | ||
| 30 | 30 | s.set_request() | |
| 31 | 31 | s.send_response(200) | |
| 32 | 32 | s.send_header("Content-type", "application/json") | |
@@ -37,13 +37,15 @@ def do_GET(s): | |||
| 37 | 37 | class TestUserSecrets(unittest.TestCase): | |
| 38 | 38 | SERVER_ADDRESS = urlparse(os.getenv(_KAGGLE_URL_BASE_ENV_VAR_NAME)) | |
| 39 | 39 | ||
| 40 | - def _test_client(self, client_func, expected_path, secret): | ||
| 40 | + def _test_client(self, client_func, expected_path, expected_body, secret): | ||
| 41 | 41 | _request = {} | |
| 42 | 42 | ||
| 43 | 43 | class AccessTokenHandler(UserSecretsHTTPHandler): | |
| 44 | 44 | ||
| 45 | 45 | def set_request(self): | |
| 46 | 46 | _request['path'] = self.path | |
| 47 | + content_len = int(self.headers.get('Content-Length')) | ||
| 48 | + _request['body'] = json.loads(self.rfile.read(content_len)) | ||
| 47 | 49 | _request['headers'] = self.headers | |
| 48 | 50 | ||
| 49 | 51 | def get_response(self): | |
@@ -60,11 +62,15 @@ def get_response(self): | |||
| 60 | 62 | finally: | |
| 61 | 63 | httpd.shutdown() | |
| 62 | 64 | ||
| 63 | - path, headers = _request['path'], _request['headers'] | ||
| 65 | + path, headers, body = _request['path'], _request['headers'], _request['body'] | ||
| 64 | 66 | self.assertEqual( | |
| 65 | 67 | path, | |
| 66 | 68 | expected_path, | |
| 67 | 69 | msg="Fake server did not receive the right request from the UserSecrets client.") | |
| 70 | + self.assertEqual( | ||
| 71 | + body, | ||
| 72 | + expected_body, | ||
| 73 | + msg="Fake server did not receive the right body from the UserSecrets client.") | ||
| 68 | 74 | self.assertTrue( | |
| 69 | 75 | any( | |
| 70 | 76 | k for k in headers | |
@@ -86,4 +92,4 @@ def call_get_access_token(): | |||
| 86 | 92 | secret_response = client.get_bigquery_access_token() | |
| 87 | 93 | self.assertEqual(secret_response, secret) | |
| 88 | 94 | self._test_client(call_get_access_token, | |
| 89 | - '/requests/GetUserSecretRequest?Target=1', secret) | ||
| 95 | + '/requests/GetUserSecretRequest', {'Target': 1}, secret) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments