From 17fb48310879ed5d29dc32851a3d1a3f502cb57f Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 25 Jan 2024 15:23:49 -0500 Subject: [PATCH] remove sslmode --- frontend/src/lib/api.ts | 5 ++--- .../scenes/data-warehouse/external/SourceModal.tsx | 12 +++++++----- .../data-warehouse/external/forms/sourceFormLogic.ts | 10 +++------- .../data-warehouse/external/sourceModalLogic.tsx | 7 ------- posthog/temporal/data_imports/external_data_job.py | 7 +++---- posthog/temporal/tests/test_external_data_job.py | 1 - posthog/warehouse/api/external_data_source.py | 9 +++------ .../warehouse/api/test/test_external_data_source.py | 5 ----- posthog/warehouse/models/external_data_schema.py | 5 +++-- 9 files changed, 21 insertions(+), 40 deletions(-) diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index eb1633181a2f6..aba1f43b325a3 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -1833,10 +1833,9 @@ const api = { dbname: string, user: string, password: string, - schema: string, - sslmode: string + schema: string ): Promise { - const queryParams = toParams({ host, port, dbname, user, password, schema, sslmode }) + const queryParams = toParams({ host, port, dbname, user, password, schema }) return await new ApiRequest() .externalDataSources() diff --git a/frontend/src/scenes/data-warehouse/external/SourceModal.tsx b/frontend/src/scenes/data-warehouse/external/SourceModal.tsx index 2ef7bec1b0109..01e37ce384332 100644 --- a/frontend/src/scenes/data-warehouse/external/SourceModal.tsx +++ b/frontend/src/scenes/data-warehouse/external/SourceModal.tsx @@ -86,11 +86,13 @@ function FirstStep(): JSX.Element { } if (config.name === 'Hubspot') { return ( - - - hubspot logo - - +
+ + + hubspot logo + + +
) } diff --git a/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts b/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts index f2a662f069e2f..7ed417510d1d7 100644 --- a/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts +++ b/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts @@ -117,10 +117,9 @@ export const sourceFormLogic = kea([ user: '', password: '', schema: '', - sslmode: '', }, }, - errors: ({ payload: { host, port, dbname, user, password, schema, sslmode } }) => ({ + errors: ({ payload: { host, port, dbname, user, password, schema } }) => ({ payload: { host: !host && 'Please enter a host.', port: !port && 'Please enter a port.', @@ -128,18 +127,16 @@ export const sourceFormLogic = kea([ user: !user && 'Please enter a user.', password: !password && 'Please enter a password.', schema: !schema && 'Please enter a schema.', - sslmode: !sslmode && 'Please enter a sslmode.', }, }), - submit: async ({ payload: { host, port, dbname, user, password, schema, sslmode }, prefix }) => { + submit: async ({ payload: { host, port, dbname, user, password, schema }, prefix }) => { const schemas = await api.externalDataSources.database_schema( host, port, dbname, user, password, - schema, - sslmode + schema ) actions.setDatabaseSchemas(schemas) @@ -151,7 +148,6 @@ export const sourceFormLogic = kea([ user, password, schema, - sslmode, }, prefix, } diff --git a/frontend/src/scenes/data-warehouse/external/sourceModalLogic.tsx b/frontend/src/scenes/data-warehouse/external/sourceModalLogic.tsx index d70e27711ad92..9c31f5f7e4811 100644 --- a/frontend/src/scenes/data-warehouse/external/sourceModalLogic.tsx +++ b/frontend/src/scenes/data-warehouse/external/sourceModalLogic.tsx @@ -117,13 +117,6 @@ export const SOURCE_DETAILS: Record = { required: true, placeholder: 'public', }, - { - name: 'sslmode', - label: 'SSL Mode', - type: 'text', - required: true, - placeholder: 'required', - }, ], }, } diff --git a/posthog/temporal/data_imports/external_data_job.py b/posthog/temporal/data_imports/external_data_job.py index 84fef4aa2755d..17be75e9ee444 100644 --- a/posthog/temporal/data_imports/external_data_job.py +++ b/posthog/temporal/data_imports/external_data_job.py @@ -28,6 +28,7 @@ from posthog.temporal.common.logger import bind_temporal_worker_logger from typing import Tuple import asyncio +from django.conf import settings @dataclasses.dataclass @@ -56,10 +57,9 @@ async def create_external_data_job_model(inputs: CreateExternalDataJobInputs) -> user = source.job_inputs.get("user") password = source.job_inputs.get("password") database = source.job_inputs.get("database") - sslmode = source.job_inputs.get("sslmode") schema = source.job_inputs.get("schema") schemas_to_sync = await sync_to_async(get_postgres_schemas)( # type: ignore - host, port, database, user, password, sslmode, schema + host, port, database, user, password, schema ) else: schemas_to_sync = list(PIPELINE_TYPE_SCHEMA_DEFAULT_MAPPING[source.source_type]) @@ -197,7 +197,6 @@ async def run_external_data_job(inputs: ExternalDataJobInputs) -> None: user = model.pipeline.job_inputs.get("user") password = model.pipeline.job_inputs.get("password") database = model.pipeline.job_inputs.get("database") - sslmode = model.pipeline.job_inputs.get("sslmode") schema = model.pipeline.job_inputs.get("schema") source = postgres_source( @@ -206,7 +205,7 @@ async def run_external_data_job(inputs: ExternalDataJobInputs) -> None: user=user, password=password, database=database, - sslmode=sslmode, + sslmode="prefer" if settings.TEST else "require", schema=schema, table_names=inputs.schemas, ) diff --git a/posthog/temporal/tests/test_external_data_job.py b/posthog/temporal/tests/test_external_data_job.py index da3589db4ac11..ad17b1dfc48c0 100644 --- a/posthog/temporal/tests/test_external_data_job.py +++ b/posthog/temporal/tests/test_external_data_job.py @@ -509,7 +509,6 @@ async def setup_job_1(): "user": settings.PG_USER, "password": settings.PG_PASSWORD, "schema": "public", - "sslmode": "disable", }, ) # type: ignore diff --git a/posthog/warehouse/api/external_data_source.py b/posthog/warehouse/api/external_data_source.py index d885ed77dbc4a..d7d2deb1b9452 100644 --- a/posthog/warehouse/api/external_data_source.py +++ b/posthog/warehouse/api/external_data_source.py @@ -229,7 +229,6 @@ def _handle_postgres_source(self, request: Request, *args: Any, **kwargs: Any) - user = payload.get("user") password = payload.get("password") - sslmode = payload.get("sslmode") schema = payload.get("schema") table_names = payload.get("schemas") @@ -249,7 +248,6 @@ def _handle_postgres_source(self, request: Request, *args: Any, **kwargs: Any) - "database": database, "user": user, "password": password, - "sslmode": sslmode, "schema": schema, }, prefix=prefix, @@ -328,13 +326,12 @@ def database_schema(self, request: Request, *arg: Any, **kwargs: Any): user = request.query_params.get("user") password = request.query_params.get("password") - sslmode = request.query_params.get("sslmode") schema = request.query_params.get("schema") - if not host or not port or not database or not user or not password or not sslmode or not schema: + if not host or not port or not database or not user or not password or not schema: return Response( status=status.HTTP_400_BAD_REQUEST, - data={"message": "Missing required parameters: host, port, database, user, password, sslmode, schema"}, + data={"message": "Missing required parameters: host, port, database, user, password, schema"}, ) # Validate internal postgres @@ -344,7 +341,7 @@ def database_schema(self, request: Request, *arg: Any, **kwargs: Any): data={"message": "Cannot use internal Postgres database"}, ) - result = get_postgres_schemas(host, port, database, user, password, sslmode, schema) + result = get_postgres_schemas(host, port, database, user, password, schema) result_mapped_to_options = [{"table": row, "should_sync": False} for row in result] return Response(status=status.HTTP_200_OK, data=result_mapped_to_options) diff --git a/posthog/warehouse/api/test/test_external_data_source.py b/posthog/warehouse/api/test/test_external_data_source.py index 6e7f6666e56a3..13f7f91e6d6d3 100644 --- a/posthog/warehouse/api/test/test_external_data_source.py +++ b/posthog/warehouse/api/test/test_external_data_source.py @@ -149,7 +149,6 @@ def test_database_schema(self): "database": settings.PG_DATABASE, "user": settings.PG_USER, "password": settings.PG_PASSWORD, - "sslmode": "disable", "schema": "public", }, ) @@ -175,7 +174,6 @@ def test_internal_postgres(self, patch_get_postgres_schemas): "database": settings.PG_DATABASE, "user": settings.PG_USER, "password": settings.PG_PASSWORD, - "sslmode": "disable", "schema": "public", }, ) @@ -192,7 +190,6 @@ def test_internal_postgres(self, patch_get_postgres_schemas): "database": settings.PG_DATABASE, "user": settings.PG_USER, "password": settings.PG_PASSWORD, - "sslmode": "disable", "schema": "public", }, ) @@ -209,7 +206,6 @@ def test_internal_postgres(self, patch_get_postgres_schemas): "database": settings.PG_DATABASE, "user": settings.PG_USER, "password": settings.PG_PASSWORD, - "sslmode": "disable", "schema": "public", }, ) @@ -226,7 +222,6 @@ def test_internal_postgres(self, patch_get_postgres_schemas): "database": settings.PG_DATABASE, "user": settings.PG_USER, "password": settings.PG_PASSWORD, - "sslmode": "disable", "schema": "public", }, ) diff --git a/posthog/warehouse/models/external_data_schema.py b/posthog/warehouse/models/external_data_schema.py index 3f5be2299d75b..fcef4ae7736ba 100644 --- a/posthog/warehouse/models/external_data_schema.py +++ b/posthog/warehouse/models/external_data_schema.py @@ -4,6 +4,7 @@ from posthog.models.utils import CreatedMetaFields, UUIDModel, sane_repr import uuid import psycopg +from django.conf import settings class ExternalDataSchema(CreatedMetaFields, UUIDModel): @@ -47,14 +48,14 @@ def sync_old_schemas_with_new_schemas(new_schemas: list, source_id: uuid.UUID, t ExternalDataSchema.objects.create(name=schema, team_id=team_id, source_id=source_id, should_sync=False) -def get_postgres_schemas(host: str, port: str, database: str, user: str, password: str, sslmode: str, schema: str): +def get_postgres_schemas(host: str, port: str, database: str, user: str, password: str, schema: str): connection = psycopg.Connection.connect( host=host, port=int(port), dbname=database, user=user, password=password, - sslmode=sslmode, + sslmode="prefer" if settings.TEST else "require", ) with connection.cursor() as cursor: