You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2023/01/18 03:11:50 UTC

[superset] branch master updated: feat(ssh_tunnel): Rename allow_ssh_tunneling and change the default value to False (#22723)

This is an automated email from the ASF dual-hosted git repository.

elizabeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new ad758c0802 feat(ssh_tunnel): Rename allow_ssh_tunneling and change the default value to False (#22723)
ad758c0802 is described below

commit ad758c080259970c9ea587fd8dd3f56d1dab7722
Author: Antonio Rivero Martinez <38...@users.noreply.github.com>
AuthorDate: Wed Jan 18 00:11:41 2023 -0300

    feat(ssh_tunnel): Rename allow_ssh_tunneling and change the default value to False (#22723)
---
 .../CRUD/data/database/DatabaseModal/index.test.tsx    | 18 +++++++++---------
 .../views/CRUD/data/database/DatabaseModal/index.tsx   |  6 +++---
 .../src/views/CRUD/data/database/types.ts              |  2 +-
 superset/databases/api.py                              |  2 +-
 superset/db_engine_specs/athena.py                     |  1 +
 superset/db_engine_specs/base.py                       |  6 +++---
 superset/db_engine_specs/bigquery.py                   |  1 +
 superset/db_engine_specs/gsheets.py                    |  1 +
 superset/db_engine_specs/postgres.py                   |  1 -
 tests/integration_tests/databases/api_tests.py         | 16 ++++++++--------
 10 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx
index 8457d8d174..9542450f44 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx
@@ -139,7 +139,7 @@ fetchMock.mock(AVAILABLE_DB_ENDPOINT, {
         'postgresql://user:password@host:port/dbname[?key=value&key=value...]',
       engine_information: {
         supports_file_upload: true,
-        allow_ssh_tunneling: true,
+        disable_ssh_tunneling: false,
       },
     },
     {
@@ -149,7 +149,7 @@ fetchMock.mock(AVAILABLE_DB_ENDPOINT, {
       preferred: true,
       engine_information: {
         supports_file_upload: true,
-        allow_ssh_tunneling: false,
+        disable_ssh_tunneling: false,
       },
     },
     {
@@ -202,7 +202,7 @@ fetchMock.mock(AVAILABLE_DB_ENDPOINT, {
         'mysql://user:password@host:port/dbname[?key=value&key=value...]',
       engine_information: {
         supports_file_upload: true,
-        allow_ssh_tunneling: false,
+        disable_ssh_tunneling: false,
       },
     },
     {
@@ -212,7 +212,7 @@ fetchMock.mock(AVAILABLE_DB_ENDPOINT, {
       preferred: true,
       engine_information: {
         supports_file_upload: true,
-        allow_ssh_tunneling: true,
+        disable_ssh_tunneling: false,
       },
     },
     {
@@ -222,7 +222,7 @@ fetchMock.mock(AVAILABLE_DB_ENDPOINT, {
       preferred: false,
       engine_information: {
         supports_file_upload: true,
-        allow_ssh_tunneling: false,
+        disable_ssh_tunneling: false,
       },
     },
     {
@@ -247,7 +247,7 @@ fetchMock.mock(AVAILABLE_DB_ENDPOINT, {
       sqlalchemy_uri_placeholder: 'bigquery://{project_id}',
       engine_information: {
         supports_file_upload: true,
-        allow_ssh_tunneling: false,
+        disable_ssh_tunneling: true,
       },
     },
     {
@@ -258,7 +258,7 @@ fetchMock.mock(AVAILABLE_DB_ENDPOINT, {
       preferred: false,
       engine_information: {
         supports_file_upload: false,
-        allow_ssh_tunneling: false,
+        disable_ssh_tunneling: true,
       },
     },
     {
@@ -1925,7 +1925,7 @@ describe('dbReducer', () => {
       payload: {
         engine_information: {
           supports_file_upload: true,
-          allow_ssh_tunneling: true,
+          disable_ssh_tunneling: false,
         },
         ...db,
         driver: db.driver,
@@ -1940,7 +1940,7 @@ describe('dbReducer', () => {
       configuration_method: db.configuration_method,
       engine_information: {
         supports_file_upload: true,
-        allow_ssh_tunneling: true,
+        disable_ssh_tunneling: false,
       },
       driver: db.driver,
       expose_in_sqllab: true,
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
index 39f6c15874..5f85ae0985 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -545,12 +545,12 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
   const sslForced = isFeatureEnabled(
     FeatureFlag.FORCE_DATABASE_CONNECTIONS_SSL,
   );
-  const engineAllowsSSHTunneling = (
+  const disableSSHTunnelingForEngine = (
     availableDbs?.databases?.find(
       (DB: DatabaseObject) =>
         DB.backend === db?.engine || DB.engine === db?.engine,
     ) as DatabaseObject
-  )?.engine_information?.allow_ssh_tunneling;
+  )?.engine_information?.disable_ssh_tunneling;
   const sshTunneling = isFeatureEnabled(FeatureFlag.SSH_TUNNELING);
   const hasAlert =
     connectionAlert || !!(db?.engine && engineSpecificAlertMapping[db.engine]);
@@ -1495,7 +1495,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
                 testConnection={testConnection}
                 testInProgress={testInProgress}
               >
-                {sshTunneling && engineAllowsSSHTunneling && (
+                {sshTunneling && !disableSSHTunnelingForEngine && (
                   <SSHTunnelForm
                     isEditMode={isEditMode}
                     sshTunneling={sshTunneling}
diff --git a/superset-frontend/src/views/CRUD/data/database/types.ts b/superset-frontend/src/views/CRUD/data/database/types.ts
index 07c828090f..c347948f7e 100644
--- a/superset-frontend/src/views/CRUD/data/database/types.ts
+++ b/superset-frontend/src/views/CRUD/data/database/types.ts
@@ -98,7 +98,7 @@ export type DatabaseObject = {
   // DB Engine Spec information
   engine_information?: {
     supports_file_upload?: boolean;
-    allow_ssh_tunneling?: boolean;
+    disable_ssh_tunneling?: boolean;
   };
 
   // SSH Tunnel information
diff --git a/superset/databases/api.py b/superset/databases/api.py
index e04261b847..4866cbe775 100644
--- a/superset/databases/api.py
+++ b/superset/databases/api.py
@@ -1150,7 +1150,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
                             supports_file_upload:
                               description: Whether the engine supports file uploads
                               type: boolean
-                            allow_ssh_tunneling:
+                            disable_ssh_tunneling:
                               description: Whether the engine supports SSH Tunnels
                               type: boolean
             400:
diff --git a/superset/db_engine_specs/athena.py b/superset/db_engine_specs/athena.py
index 9e1d798a7c..f4a6efca35 100644
--- a/superset/db_engine_specs/athena.py
+++ b/superset/db_engine_specs/athena.py
@@ -33,6 +33,7 @@ class AthenaEngineSpec(BaseEngineSpec):
     engine = "awsathena"
     engine_name = "Amazon Athena"
     allows_escaped_colons = False
+    disable_ssh_tunneling = True
 
     _time_grain_expressions = {
         None: "{col}",
diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index 1aab100c81..32f1846226 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -193,7 +193,7 @@ class BaseEngineSpec:  # pylint: disable=too-many-public-methods
     engine_aliases: Set[str] = set()
     drivers: Dict[str, str] = {}
     default_driver: Optional[str] = None
-    allow_ssh_tunneling = False
+    disable_ssh_tunneling = False
 
     _date_trunc_functions: Dict[str, str] = {}
     _time_grain_expressions: Dict[Optional[str], str] = {}
@@ -1697,11 +1697,11 @@ class BaseEngineSpec:  # pylint: disable=too-many-public-methods
         Construct a Dict with properties we want to expose.
 
         :returns: Dict with properties of our class like supports_file_upload
-        and allow_ssh_tunneling
+        and disable_ssh_tunneling
         """
         return {
             "supports_file_upload": cls.supports_file_upload,
-            "allow_ssh_tunneling": cls.allow_ssh_tunneling,
+            "disable_ssh_tunneling": cls.disable_ssh_tunneling,
         }
 
 
diff --git a/superset/db_engine_specs/bigquery.py b/superset/db_engine_specs/bigquery.py
index 52116d487e..6672b0b478 100644
--- a/superset/db_engine_specs/bigquery.py
+++ b/superset/db_engine_specs/bigquery.py
@@ -93,6 +93,7 @@ class BigQueryEngineSpec(BaseEngineSpec):
     engine = "bigquery"
     engine_name = "Google BigQuery"
     max_column_name_length = 128
+    disable_ssh_tunneling = True
 
     parameters_schema = BigQueryParametersSchema()
     default_driver = "bigquery"
diff --git a/superset/db_engine_specs/gsheets.py b/superset/db_engine_specs/gsheets.py
index 9438f4d566..c181ae6225 100644
--- a/superset/db_engine_specs/gsheets.py
+++ b/superset/db_engine_specs/gsheets.py
@@ -69,6 +69,7 @@ class GSheetsEngineSpec(SqliteEngineSpec):
     engine_name = "Google Sheets"
     allows_joins = True
     allows_subqueries = True
+    disable_ssh_tunneling = True
 
     parameters_schema = GSheetsParametersSchema()
     default_driver = "apsw"
diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py
index 3a6a2e17d8..286b6e80a1 100644
--- a/superset/db_engine_specs/postgres.py
+++ b/superset/db_engine_specs/postgres.py
@@ -166,7 +166,6 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
 class PostgresEngineSpec(PostgresBaseEngineSpec, BasicParametersMixin):
     engine = "postgresql"
     engine_aliases = {"postgres"}
-    allow_ssh_tunneling = True
 
     default_driver = "psycopg2"
     sqlalchemy_uri_placeholder = (
diff --git a/tests/integration_tests/databases/api_tests.py b/tests/integration_tests/databases/api_tests.py
index 4835578dc2..d4e5fb4349 100644
--- a/tests/integration_tests/databases/api_tests.py
+++ b/tests/integration_tests/databases/api_tests.py
@@ -2304,7 +2304,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "sqlalchemy_uri_placeholder": "postgresql://user:password@host:port/dbname[?key=value&key=value...]",
                     "engine_information": {
                         "supports_file_upload": True,
-                        "allow_ssh_tunneling": True,
+                        "disable_ssh_tunneling": False,
                     },
                 },
                 {
@@ -2327,7 +2327,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "sqlalchemy_uri_placeholder": "bigquery://{project_id}",
                     "engine_information": {
                         "supports_file_upload": True,
-                        "allow_ssh_tunneling": False,
+                        "disable_ssh_tunneling": True,
                     },
                 },
                 {
@@ -2379,7 +2379,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "sqlalchemy_uri_placeholder": "redshift+psycopg2://user:password@host:port/dbname[?key=value&key=value...]",
                     "engine_information": {
                         "supports_file_upload": True,
-                        "allow_ssh_tunneling": False,
+                        "disable_ssh_tunneling": False,
                     },
                 },
                 {
@@ -2402,7 +2402,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "sqlalchemy_uri_placeholder": "gsheets://",
                     "engine_information": {
                         "supports_file_upload": False,
-                        "allow_ssh_tunneling": False,
+                        "disable_ssh_tunneling": True,
                     },
                 },
                 {
@@ -2454,7 +2454,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "sqlalchemy_uri_placeholder": "mysql://user:password@host:port/dbname[?key=value&key=value...]",
                     "engine_information": {
                         "supports_file_upload": True,
-                        "allow_ssh_tunneling": False,
+                        "disable_ssh_tunneling": False,
                     },
                 },
                 {
@@ -2464,7 +2464,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "preferred": False,
                     "engine_information": {
                         "supports_file_upload": True,
-                        "allow_ssh_tunneling": False,
+                        "disable_ssh_tunneling": False,
                     },
                 },
             ]
@@ -2495,7 +2495,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "preferred": True,
                     "engine_information": {
                         "supports_file_upload": True,
-                        "allow_ssh_tunneling": False,
+                        "disable_ssh_tunneling": False,
                     },
                 },
                 {
@@ -2505,7 +2505,7 @@ class TestDatabaseApi(SupersetTestCase):
                     "preferred": False,
                     "engine_information": {
                         "supports_file_upload": True,
-                        "allow_ssh_tunneling": False,
+                        "disable_ssh_tunneling": False,
                     },
                 },
             ]