feat(ssh_tunnel): Rename allow_ssh_tunneling and change the default value to False (#22723)

This commit is contained in:
Antonio Rivero Martinez 2023-01-18 00:11:41 -03:00 committed by GitHub
parent c87f654901
commit ad758c0802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 28 additions and 26 deletions

View File

@ -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,

View File

@ -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}

View File

@ -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

View File

@ -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:

View File

@ -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}",

View File

@ -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,
}

View File

@ -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"

View File

@ -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"

View File

@ -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 = (

View File

@ -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,
},
},
]