From a79fbb0b01e520d3ef0e648ece64d39da07ba0e5 Mon Sep 17 00:00:00 2001 From: Jeyaprakash-NK Date: Mon, 23 Sep 2024 16:30:12 +0530 Subject: [PATCH 1/4] Big Query search API change get to post --- dataproc_jupyter_plugin/controllers/bigquery.py | 2 +- src/bigQuery/bigQueryService.tsx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dataproc_jupyter_plugin/controllers/bigquery.py b/dataproc_jupyter_plugin/controllers/bigquery.py index d611814b..157a832c 100644 --- a/dataproc_jupyter_plugin/controllers/bigquery.py +++ b/dataproc_jupyter_plugin/controllers/bigquery.py @@ -141,7 +141,7 @@ async def get(self): class SearchController(APIHandler): @tornado.web.authenticated - async def get(self): + async def post(self): try: search_string = self.get_argument("search_string") type = self.get_argument("type") diff --git a/src/bigQuery/bigQueryService.tsx b/src/bigQuery/bigQueryService.tsx index 3cd3ff53..e45c27f5 100644 --- a/src/bigQuery/bigQueryService.tsx +++ b/src/bigQuery/bigQueryService.tsx @@ -407,7 +407,10 @@ export class BigQueryService { setSearchLoading(true); try { const data: any = await requestAPI( - `bigQuerySearch?search_string=${searchTerm}&type=(table|dataset)&system=bigquery` + `bigQuerySearch?search_string=${searchTerm}&type=(table|dataset)&system=bigquery`, + { + method: 'POST' + } ); setSearchResponse(data); } catch (reason) { From 0d0126a2cfc0c8d5942da961c0ffd02dc044b59e Mon Sep 17 00:00:00 2001 From: Jeyaprakash-NK Date: Mon, 23 Sep 2024 16:33:14 +0530 Subject: [PATCH 2/4] downloadOutput changed from get to post --- dataproc_jupyter_plugin/controllers/executor.py | 2 +- src/scheduler/schedulerServices.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dataproc_jupyter_plugin/controllers/executor.py b/dataproc_jupyter_plugin/controllers/executor.py index 45fc9612..73f6163e 100644 --- a/dataproc_jupyter_plugin/controllers/executor.py +++ b/dataproc_jupyter_plugin/controllers/executor.py @@ -51,7 +51,7 @@ async def post(self): class DownloadOutputController(APIHandler): @tornado.web.authenticated - async def get(self): + async def post(self): try: composer_name = self.get_argument("composer") bucket_name = self.get_argument("bucket_name") diff --git a/src/scheduler/schedulerServices.tsx b/src/scheduler/schedulerServices.tsx index 2116edc8..b675538a 100644 --- a/src/scheduler/schedulerServices.tsx +++ b/src/scheduler/schedulerServices.tsx @@ -702,7 +702,9 @@ export class SchedulerService { try { dagRunId = encodeURIComponent(dagRunId); const serviceURL = `downloadOutput?composer=${composerName}&bucket_name=${bucketName}&dag_id=${dagId}&dag_run_id=${dagRunId}`; - const formattedResponse: any = await requestAPI(serviceURL); + const formattedResponse: any = await requestAPI(serviceURL, { + method: 'POST' + }); dagRunId = decodeURIComponent(dagRunId); if (formattedResponse.status === 0) { toast.success( From f9a668b571c388fc6b78d45076b2237246cee651 Mon Sep 17 00:00:00 2001 From: Jeyaprakash-NK Date: Mon, 23 Sep 2024 16:45:42 +0530 Subject: [PATCH 3/4] test file changes for GET to POST changes --- dataproc_jupyter_plugin/tests/test_bigquery.py | 1 + dataproc_jupyter_plugin/tests/test_executor.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/dataproc_jupyter_plugin/tests/test_bigquery.py b/dataproc_jupyter_plugin/tests/test_bigquery.py index 05d5d287..b543b723 100644 --- a/dataproc_jupyter_plugin/tests/test_bigquery.py +++ b/dataproc_jupyter_plugin/tests/test_bigquery.py @@ -183,6 +183,7 @@ async def mock_config(config_field): "system": mock_system, "type": mock_type, }, + method="POST", ) assert response.code == 200 payload = json.loads(response.body)["results"][0] diff --git a/dataproc_jupyter_plugin/tests/test_executor.py b/dataproc_jupyter_plugin/tests/test_executor.py index 8544d3ba..7aae484b 100644 --- a/dataproc_jupyter_plugin/tests/test_executor.py +++ b/dataproc_jupyter_plugin/tests/test_executor.py @@ -129,6 +129,7 @@ async def mock_list_dag_run_task(*args, **kwargs): "dag_id": mock_dag_id, "dag_run_id": mock_dag_run_id, }, + method="POST", ) assert response.code == 200 payload = json.loads(response.body) @@ -149,6 +150,7 @@ async def test_invalid_composer_name(monkeypatch, jp_fetch): "dag_id": mock_dag_id, "dag_run_id": mock_dag_run_id, }, + method="POST", ) assert response.code == 200 payload = json.loads(response.body) @@ -171,6 +173,7 @@ async def test_invalid_bucket_name(monkeypatch, jp_fetch): "dag_id": mock_dag_id, "dag_run_id": mock_dag_run_id, }, + method="POST", ) assert response.code == 200 payload = json.loads(response.body) @@ -193,6 +196,7 @@ async def test_invalid_dag_id(monkeypatch, jp_fetch): "dag_id": mock_dag_id, "dag_run_id": mock_dag_run_id, }, + method="POST", ) assert response.code == 200 payload = json.loads(response.body) @@ -215,6 +219,7 @@ async def test_invalid_dag_run_id(monkeypatch, jp_fetch): "dag_id": mock_dag_id, "dag_run_id": mock_dag_run_id, }, + method="POST", ) assert response.code == 200 payload = json.loads(response.body) From 23d0d0804f5b886ec029c5495944686b26aabea0 Mon Sep 17 00:00:00 2001 From: Jeyaprakash-NK Date: Tue, 24 Sep 2024 09:54:44 +0530 Subject: [PATCH 4/4] test file review comment changes --- dataproc_jupyter_plugin/tests/test_bigquery.py | 1 + dataproc_jupyter_plugin/tests/test_executor.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/dataproc_jupyter_plugin/tests/test_bigquery.py b/dataproc_jupyter_plugin/tests/test_bigquery.py index b543b723..828a3dee 100644 --- a/dataproc_jupyter_plugin/tests/test_bigquery.py +++ b/dataproc_jupyter_plugin/tests/test_bigquery.py @@ -184,6 +184,7 @@ async def mock_config(config_field): "type": mock_type, }, method="POST", + allow_nonstandard_methods=True, ) assert response.code == 200 payload = json.loads(response.body)["results"][0] diff --git a/dataproc_jupyter_plugin/tests/test_executor.py b/dataproc_jupyter_plugin/tests/test_executor.py index 7aae484b..67638e40 100644 --- a/dataproc_jupyter_plugin/tests/test_executor.py +++ b/dataproc_jupyter_plugin/tests/test_executor.py @@ -130,6 +130,7 @@ async def mock_list_dag_run_task(*args, **kwargs): "dag_run_id": mock_dag_run_id, }, method="POST", + allow_nonstandard_methods=True, ) assert response.code == 200 payload = json.loads(response.body) @@ -151,6 +152,7 @@ async def test_invalid_composer_name(monkeypatch, jp_fetch): "dag_run_id": mock_dag_run_id, }, method="POST", + allow_nonstandard_methods=True, ) assert response.code == 200 payload = json.loads(response.body) @@ -174,6 +176,7 @@ async def test_invalid_bucket_name(monkeypatch, jp_fetch): "dag_run_id": mock_dag_run_id, }, method="POST", + allow_nonstandard_methods=True, ) assert response.code == 200 payload = json.loads(response.body) @@ -197,6 +200,7 @@ async def test_invalid_dag_id(monkeypatch, jp_fetch): "dag_run_id": mock_dag_run_id, }, method="POST", + allow_nonstandard_methods=True, ) assert response.code == 200 payload = json.loads(response.body) @@ -220,6 +224,7 @@ async def test_invalid_dag_run_id(monkeypatch, jp_fetch): "dag_run_id": mock_dag_run_id, }, method="POST", + allow_nonstandard_methods=True, ) assert response.code == 200 payload = json.loads(response.body)